2
0
Fork 0

Early return

This commit is contained in:
Bart Schuurmans 2024-04-25 15:51:32 +02:00
parent 7604d0acdb
commit a6c2ce15dd

View file

@ -48,16 +48,16 @@ class MoveUser(Move):
"""update user info and broadcast it""" """update user info and broadcast it"""
# only allow if the source is listed in the target's alsoKnownAs # only allow if the source is listed in the target's alsoKnownAs
if self.user in self.target.also_known_as.all(): if self.user not in self.target.also_known_as.all():
raise PermissionDenied()
self.user.also_known_as.add(self.target.id) self.user.also_known_as.add(self.target.id)
self.user.update_active_date() self.user.update_active_date()
self.user.moved_to = self.target.remote_id self.user.moved_to = self.target.remote_id
self.user.save(update_fields=["moved_to"]) self.user.save(update_fields=["moved_to"])
if self.user.local: if self.user.local:
kwargs[ kwargs["broadcast"] = True # Only broadcast if we are initiating the Move
"broadcast"
] = True # Only broadcast if we are initiating the Move
super().save(*args, **kwargs) super().save(*args, **kwargs)
@ -66,6 +66,3 @@ class MoveUser(Move):
Notification.notify( Notification.notify(
follower, self.user, notification_type=NotificationType.MOVE follower, self.user, notification_type=NotificationType.MOVE
) )
else:
raise PermissionDenied()