2018-04-01 22:11:46 +02:00
|
|
|
ACTIVITY_TYPES = [
|
2018-06-09 15:36:16 +02:00
|
|
|
"Accept",
|
|
|
|
|
"Add",
|
|
|
|
|
"Announce",
|
|
|
|
|
"Arrive",
|
|
|
|
|
"Block",
|
|
|
|
|
"Create",
|
|
|
|
|
"Delete",
|
|
|
|
|
"Dislike",
|
|
|
|
|
"Flag",
|
|
|
|
|
"Follow",
|
|
|
|
|
"Ignore",
|
|
|
|
|
"Invite",
|
|
|
|
|
"Join",
|
|
|
|
|
"Leave",
|
|
|
|
|
"Like",
|
|
|
|
|
"Listen",
|
|
|
|
|
"Move",
|
|
|
|
|
"Offer",
|
|
|
|
|
"Question",
|
|
|
|
|
"Reject",
|
|
|
|
|
"Read",
|
|
|
|
|
"Remove",
|
|
|
|
|
"TentativeReject",
|
|
|
|
|
"TentativeAccept",
|
|
|
|
|
"Travel",
|
|
|
|
|
"Undo",
|
|
|
|
|
"Update",
|
|
|
|
|
"View",
|
2018-04-01 22:11:46 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OBJECT_TYPES = [
|
2018-06-09 15:36:16 +02:00
|
|
|
"Article",
|
|
|
|
|
"Audio",
|
|
|
|
|
"Collection",
|
|
|
|
|
"Document",
|
|
|
|
|
"Event",
|
|
|
|
|
"Image",
|
|
|
|
|
"Note",
|
|
|
|
|
"OrderedCollection",
|
|
|
|
|
"Page",
|
|
|
|
|
"Place",
|
|
|
|
|
"Profile",
|
|
|
|
|
"Relationship",
|
|
|
|
|
"Tombstone",
|
|
|
|
|
"Video",
|
2018-04-03 21:30:15 +02:00
|
|
|
] + ACTIVITY_TYPES
|
2018-04-01 22:11:46 +02:00
|
|
|
|
2018-04-07 15:34:35 +02:00
|
|
|
|
2018-04-02 18:07:46 +02:00
|
|
|
def deliver(activity, on_behalf_of, to=[]):
|
2018-06-10 10:39:47 +02:00
|
|
|
from . import tasks
|
|
|
|
|
|
2018-06-09 15:36:16 +02:00
|
|
|
return tasks.send.delay(activity=activity, actor_id=on_behalf_of.pk, to=to)
|
2018-04-03 19:48:50 +02:00
|
|
|
|
|
|
|
|
|
2018-04-10 21:25:35 +02:00
|
|
|
def accept_follow(follow):
|
2018-06-10 10:39:47 +02:00
|
|
|
from . import serializers
|
|
|
|
|
|
2018-04-10 21:25:35 +02:00
|
|
|
serializer = serializers.AcceptFollowSerializer(follow)
|
2018-06-09 15:36:16 +02:00
|
|
|
return deliver(serializer.data, to=[follow.actor.url], on_behalf_of=follow.target)
|