Include custom serializers on all relationships

This commit is contained in:
Mouse Reeve 2020-09-29 13:19:57 -07:00
parent 8b972a577e
commit 69ef967050

View file

@ -39,6 +39,22 @@ class UserRelationship(BookWyrmModel):
base_path = self.user_subject.remote_id
return '%s#%s/%d' % (base_path, self.status, self.id)
def to_accept_activity(self):
''' generate an Accept for this follow request '''
return activitypub.Accept(
id='%s#accepts/follows/' % self.remote_id,
actor=self.user_subject.remote_id,
object=self.user_object.remote_id,
).serialize()
def to_reject_activity(self):
''' generate an Accept for this follow request '''
return activitypub.Reject(
id='%s#rejects/follows/' % self.remote_id,
actor=self.user_subject.remote_id,
object=self.user_object.remote_id,
).serialize()
class UserFollows(UserRelationship):
''' Following a user '''
@ -66,22 +82,6 @@ class UserFollowRequest(UserRelationship):
object=self.user_object.remote_id,
).serialize()
def to_accept_activity(self):
''' generate an Accept for this follow request '''
return activitypub.Accept(
id='%s#accepts/follows/' % self.remote_id,
actor=self.user_subject.remote_id,
object=self.user_object.remote_id,
).serialize()
def to_reject_activity(self):
''' generate an Accept for this follow request '''
return activitypub.Reject(
id='%s#rejects/follows/' % self.remote_id,
actor=self.user_subject.remote_id,
object=self.user_object.remote_id,
).serialize()
class UserBlocks(UserRelationship):
''' prevent another user from following you and seeing your posts '''