mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-29 13:01:08 +00:00
Reverse user_subject & user_object.
In the relationships table: user_subject should be the user doing the following. user_object should be the user who is followed. This fixes a bug where unfollowing a user deletes the relationship in both directions.
This commit is contained in:
parent
d6e48f9a21
commit
592c2b7dfd
3 changed files with 5 additions and 5 deletions
|
@ -201,8 +201,8 @@ def handle_incoming_follow(activity):
|
||||||
# TODO: allow users to manually approve requests
|
# TODO: allow users to manually approve requests
|
||||||
try:
|
try:
|
||||||
models.UserRelationship.objects.create(
|
models.UserRelationship.objects.create(
|
||||||
user_subject=to_follow,
|
user_subject=user,
|
||||||
user_object=user,
|
user_object=to_follow,
|
||||||
status='follow_request',
|
status='follow_request',
|
||||||
relationship_id=activity['id']
|
relationship_id=activity['id']
|
||||||
)
|
)
|
||||||
|
|
|
@ -38,7 +38,7 @@ class User(AbstractUser):
|
||||||
'self',
|
'self',
|
||||||
symmetrical=False,
|
symmetrical=False,
|
||||||
through='UserRelationship',
|
through='UserRelationship',
|
||||||
through_fields=('user_subject', 'user_object'),
|
through_fields=('user_object', 'user_subject'),
|
||||||
related_name='following'
|
related_name='following'
|
||||||
)
|
)
|
||||||
favorites = models.ManyToManyField(
|
favorites = models.ManyToManyField(
|
||||||
|
|
|
@ -88,8 +88,8 @@ def handle_outgoing_follow(user, to_follow):
|
||||||
def handle_outgoing_unfollow(user, to_unfollow):
|
def handle_outgoing_unfollow(user, to_unfollow):
|
||||||
''' someone local wants to follow someone '''
|
''' someone local wants to follow someone '''
|
||||||
relationship = models.UserRelationship.objects.get(
|
relationship = models.UserRelationship.objects.get(
|
||||||
user_object=user,
|
user_subject=user,
|
||||||
user_subject=to_unfollow
|
user_object=to_unfollow
|
||||||
)
|
)
|
||||||
activity = activitypub.get_unfollow(relationship)
|
activity = activitypub.get_unfollow(relationship)
|
||||||
errors = broadcast(user, activity, [to_unfollow.inbox])
|
errors = broadcast(user, activity, [to_unfollow.inbox])
|
||||||
|
|
Loading…
Reference in a new issue