2023-09-04 23:06:59 +01:00
|
|
|
from cloudevents.http import CloudEvent
|
|
|
|
import functions_framework
|
|
|
|
|
|
|
|
# Register a CloudEvent function with the Functions Framework
|
|
|
|
@functions_framework.cloud_event
|
|
|
|
def update_tag(event: CloudEvent):
|
2020-02-03 09:44:33 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
logger = logging.getLogger('music')
|
|
|
|
|
2023-09-04 23:06:59 +01:00
|
|
|
attr = event.get_data()['message']['attributes']
|
|
|
|
|
|
|
|
if 'username' in attr and 'tag_id' in attr:
|
2020-06-30 16:38:06 +01:00
|
|
|
|
2023-09-04 23:06:59 +01:00
|
|
|
from music.tasks.update_tag import update_tag as do_update_tag
|
|
|
|
do_update_tag(user=attr['username'], tag=attr["tag_id"])
|
2020-06-30 16:38:06 +01:00
|
|
|
|
2020-02-03 09:44:33 +00:00
|
|
|
else:
|
2023-09-04 23:06:59 +01:00
|
|
|
logger.error('no parameters in event attributes')
|