mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 01:49:17 +02:00
Removed too complex FollowRequest model, we now use an aproved field on Follow
This commit is contained in:
parent
c97db31cb1
commit
0b2fe8439a
14 changed files with 480 additions and 306 deletions
|
@ -6,8 +6,10 @@ import uuid
|
|||
from django.conf import settings
|
||||
|
||||
from funkwhale_api.common import session
|
||||
from funkwhale_api.common import utils as funkwhale_utils
|
||||
|
||||
from . import models
|
||||
from . import serializers
|
||||
from . import signing
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -85,66 +87,9 @@ def deliver(activity, on_behalf_of, to=[]):
|
|||
logger.debug('Remote answered with %s', response.status_code)
|
||||
|
||||
|
||||
def get_follow(follow_id, follower, followed):
|
||||
return {
|
||||
'@context': [
|
||||
'https://www.w3.org/ns/activitystreams',
|
||||
'https://w3id.org/security/v1',
|
||||
{}
|
||||
],
|
||||
'actor': follower.url,
|
||||
'id': follower.url + '#follows/{}'.format(follow_id),
|
||||
'object': followed.url,
|
||||
'type': 'Follow'
|
||||
}
|
||||
|
||||
|
||||
def get_undo(id, actor, object):
|
||||
return {
|
||||
'@context': [
|
||||
'https://www.w3.org/ns/activitystreams',
|
||||
'https://w3id.org/security/v1',
|
||||
{}
|
||||
],
|
||||
'type': 'Undo',
|
||||
'id': id + '/undo',
|
||||
'actor': actor.url,
|
||||
'object': object,
|
||||
}
|
||||
|
||||
|
||||
def get_accept_follow(accept_id, accept_actor, follow, follow_actor):
|
||||
return {
|
||||
"@context": [
|
||||
"https://www.w3.org/ns/activitystreams",
|
||||
"https://w3id.org/security/v1",
|
||||
{}
|
||||
],
|
||||
"id": accept_actor.url + '#accepts/follows/{}'.format(
|
||||
accept_id),
|
||||
"type": "Accept",
|
||||
"actor": accept_actor.url,
|
||||
"object": {
|
||||
"id": follow['id'],
|
||||
"type": "Follow",
|
||||
"actor": follow_actor.url,
|
||||
"object": accept_actor.url
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def accept_follow(target, follow, actor):
|
||||
accept_uuid = uuid.uuid4()
|
||||
accept = get_accept_follow(
|
||||
accept_id=accept_uuid,
|
||||
accept_actor=target,
|
||||
follow=follow,
|
||||
follow_actor=actor)
|
||||
def accept_follow(follow):
|
||||
serializer = serializers.AcceptFollowSerializer(follow)
|
||||
deliver(
|
||||
accept,
|
||||
to=[actor.url],
|
||||
on_behalf_of=target)
|
||||
return models.Follow.objects.get_or_create(
|
||||
actor=actor,
|
||||
target=target,
|
||||
)
|
||||
serializer.data,
|
||||
to=[follow.actor.url],
|
||||
on_behalf_of=follow.target)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue