mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 10:39:17 +02:00
Fix #858: Broadcast/handle rejected follows
This commit is contained in:
parent
191f28f79c
commit
cd109ddeb6
7 changed files with 120 additions and 13 deletions
|
@ -82,6 +82,37 @@ def outbox_accept(context):
|
|||
}
|
||||
|
||||
|
||||
@outbox.register({"type": "Reject"})
|
||||
def outbox_reject_follow(context):
|
||||
follow = context["follow"]
|
||||
if follow._meta.label == "federation.LibraryFollow":
|
||||
actor = follow.target.actor
|
||||
else:
|
||||
actor = follow.target
|
||||
payload = serializers.RejectFollowSerializer(follow, context={"actor": actor}).data
|
||||
yield {
|
||||
"actor": actor,
|
||||
"type": "Reject",
|
||||
"payload": with_recipients(payload, to=[follow.actor]),
|
||||
"object": follow,
|
||||
"related_object": follow.target,
|
||||
}
|
||||
|
||||
|
||||
@inbox.register({"type": "Reject"})
|
||||
def inbox_reject_follow(payload, context):
|
||||
serializer = serializers.RejectFollowSerializer(data=payload, context=context)
|
||||
if not serializer.is_valid(raise_exception=context.get("raise_exception", False)):
|
||||
logger.debug(
|
||||
"Discarding invalid follow reject from %s: %s",
|
||||
context["actor"].fid,
|
||||
serializer.errors,
|
||||
)
|
||||
return
|
||||
|
||||
serializer.save()
|
||||
|
||||
|
||||
@inbox.register({"type": "Undo", "object.type": "Follow"})
|
||||
def inbox_undo_follow(payload, context):
|
||||
serializer = serializers.UndoFollowSerializer(data=payload, context=context)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue