forked from mirrors/bookwyrm
Fixes unfollow
This commit is contained in:
parent
d022fef625
commit
08dc5b4d86
2 changed files with 12 additions and 3 deletions
|
@ -5,7 +5,7 @@ from django.db.models import Q
|
|||
from django.dispatch import receiver
|
||||
|
||||
from bookwyrm import activitypub
|
||||
from .activitypub_mixin import ActivitypubMixin, ActivityMixin
|
||||
from .activitypub_mixin import ActivitypubMixin, ActivityMixin, generate_activity
|
||||
from .base_model import BookWyrmModel
|
||||
from . import fields
|
||||
|
||||
|
@ -56,10 +56,20 @@ class UserRelationship(BookWyrmModel):
|
|||
return '%s#%s/%d' % (base_path, status, self.id)
|
||||
|
||||
|
||||
class UserFollows(ActivitypubMixin, UserRelationship):
|
||||
class UserFollows(ActivityMixin, UserRelationship):
|
||||
''' Following a user '''
|
||||
status = 'follows'
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
''' never broadcast a creation (that's handled by "accept"), only a
|
||||
deletion (an unfollow, as opposed to "reject" and undo pending) '''
|
||||
super().save(*args, broadcast=False, **kwargs)
|
||||
|
||||
def to_activity(self):
|
||||
''' overrides default to manually set serializer '''
|
||||
return activitypub.Follow(**generate_activity(self))
|
||||
|
||||
|
||||
@classmethod
|
||||
def from_request(cls, follow_request):
|
||||
''' converts a follow request into a follow relationship '''
|
||||
|
|
|
@ -104,7 +104,6 @@ class BookViews(TestCase):
|
|||
request.user = self.local_user
|
||||
self.remote_user.followers.add(self.local_user)
|
||||
self.assertEqual(self.remote_user.followers.count(), 1)
|
||||
# need to see if this ACTUALLY broadcasts
|
||||
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay') \
|
||||
as mock:
|
||||
views.unfollow(request)
|
||||
|
|
Loading…
Reference in a new issue