mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-05 04:19:24 +02:00
Broadcast library updates (name, description, visibility) over federation
This commit is contained in:
parent
51457aa889
commit
4976981926
8 changed files with 185 additions and 1 deletions
|
@ -195,6 +195,45 @@ def outbox_delete_library(context):
|
|||
}
|
||||
|
||||
|
||||
@outbox.register({"type": "Update", "object.type": "Library"})
|
||||
def outbox_update_library(context):
|
||||
library = context["library"]
|
||||
serializer = serializers.ActivitySerializer(
|
||||
{"type": "Update", "object": serializers.LibrarySerializer(library).data}
|
||||
)
|
||||
|
||||
yield {
|
||||
"type": "Update",
|
||||
"actor": library.actor,
|
||||
"payload": with_recipients(
|
||||
serializer.data, to=[{"type": "followers", "target": library}]
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
@inbox.register({"type": "Update", "object.type": "Library"})
|
||||
def inbox_update_library(payload, context):
|
||||
actor = context["actor"]
|
||||
library_id = payload["object"].get("id")
|
||||
if not library_id:
|
||||
logger.debug("Discarding deletion of empty library")
|
||||
return
|
||||
|
||||
if not actor.libraries.filter(fid=library_id).exists():
|
||||
logger.debug("Discarding deletion of unkwnown library %s", library_id)
|
||||
return
|
||||
|
||||
serializer = serializers.LibrarySerializer(data=payload["object"])
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
else:
|
||||
logger.debug(
|
||||
"Discarding update of library %s because of payload errors: %s",
|
||||
library_id,
|
||||
serializer.errors,
|
||||
)
|
||||
|
||||
|
||||
@inbox.register({"type": "Delete", "object.type": "Audio"})
|
||||
def inbox_delete_audio(payload, context):
|
||||
actor = context["actor"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue