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 run_user_playlist_new(event: CloudEvent):
|
2020-06-30 16:38:06 +01: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 'name' in attr:
|
2020-06-30 16:38:06 +01:00
|
|
|
|
2023-09-04 23:06:59 +01:00
|
|
|
from music.tasks.run_user_playlist import run_user_playlist as do_run_user_playlist
|
|
|
|
do_run_user_playlist(user=attr['username'], playlist=attr["name"])
|
2020-06-30 16:38:06 +01:00
|
|
|
|
|
|
|
else:
|
2023-09-04 23:06:59 +01:00
|
|
|
logger.error('no parameters in event attributes')
|