def handle_follow(activity): ''' someone wants to follow a local user ''' try: relationship = activitypub.Follow(**activity).to_model( models.UserFollowRequest) except django.db.utils.IntegrityError as err: if err.__cause__.diag.constraint_name != 'userfollowrequest_unique': raise relationship = models.UserFollowRequest.objects.get( remote_id=activity['id']) # send the accept normally for a duplicate request if not relationship.user_object.manually_approves_followers: relationship.accept()
def handle_follow(activity): ''' someone wants to follow a local user ''' try: relationship = activitypub.Follow(**activity).to_model( models.UserFollowRequest) except django.db.utils.IntegrityError as err: if err.__cause__.diag.constraint_name != 'userfollowrequest_unique': raise relationship = models.UserFollowRequest.objects.get( remote_id=activity['id']) # send the accept normally for a duplicate request manually_approves = relationship.user_object.manually_approves_followers status_builder.create_notification( relationship.user_object, 'FOLLOW_REQUEST' if manually_approves else 'FOLLOW', related_user=relationship.user_subject) if not manually_approves: outgoing.handle_accept(relationship)
def to_activity(self): # pylint: disable=arguments-differ """overrides default to manually set serializer""" return activitypub.Follow(**generate_activity(self))
def to_activity(self): """ overrides default to manually set serializer """ return activitypub.Follow(**generate_activity(self))