2018-03-01 19:38:48 +00:00
|
|
|
from funkwhale_api.activity import record
|
2018-06-10 08:55:16 +00:00
|
|
|
from funkwhale_api.common import channels
|
2018-03-01 19:38:48 +00:00
|
|
|
|
|
|
|
from . import serializers
|
|
|
|
|
2018-06-09 13:36:16 +00:00
|
|
|
record.registry.register_serializer(serializers.TrackFavoriteActivitySerializer)
|
2018-03-01 19:38:48 +00:00
|
|
|
|
|
|
|
|
2018-06-09 13:36:16 +00:00
|
|
|
@record.registry.register_consumer("favorites.TrackFavorite")
|
2018-03-01 20:51:20 +00:00
|
|
|
def broadcast_track_favorite_to_instance_activity(data, obj):
|
2018-06-09 13:36:16 +00:00
|
|
|
if obj.user.privacy_level not in ["instance", "everyone"]:
|
2018-03-01 19:38:48 +00:00
|
|
|
return
|
2018-03-01 20:51:20 +00:00
|
|
|
|
2018-06-09 13:36:16 +00:00
|
|
|
channels.group_send(
|
|
|
|
"instance_activity", {"type": "event.send", "text": "", "data": data}
|
|
|
|
)
|