1
0
Fork 0
* update User model to allow for moved_to and also_known_as values
* allow users to add aliases (also_known_as) in UI
* allow users to move account to another one (moved_to)
* redirect webfinger to the new account after a move
* present notification to followers inviting to follow at new account

Note: unlike Mastodon we're not running any unfollow/autofollow action here: users can decide for themselves
This makes undoing moves easier.

TODO

There is still a bug with incoming Moves, at least from Mastodon.
This seems to be something to do with Update activities (rather than Move, strictly).
This commit is contained in:
Hugh Rundle 2023-09-18 21:21:04 +10:00
parent e7ba6a3141
commit 5b051631ec
No known key found for this signature in database
GPG key ID: A7E35779918253F9
24 changed files with 521 additions and 138 deletions

View file

@ -40,4 +40,6 @@ class Person(ActivityObject):
manuallyApprovesFollowers: str = False
discoverable: str = False
hideFollows: str = False
movedTo: str = None
alsoKnownAs: dict[str] = None
type: str = "Person"

View file

@ -75,6 +75,9 @@ class Update(Verb):
"""update a model instance from the dataclass"""
if not self.object:
return
# BUG: THIS IS THROWING A DUPLIATE USERNAME ERROR WHEN WE GET AN "UPDATE" AFTER/BEFORE A "MOVE"
# FROM MASTODON - BUT ONLY SINCE WE ADDED MOVEUSER
# is it something to do with the updated User model?
self.object.to_model(
allow_create=False, allow_external_connections=allow_external_connections
)
@ -232,27 +235,23 @@ class Announce(Verb):
"""boost"""
self.to_model(allow_external_connections=allow_external_connections)
@dataclass(init=False)
class Move(Verb):
"""a user moving an object"""
# note the spec example for target and origin is an object but
# Mastodon uses a URI string and TBH this makes more sense
# Is there a way we can account for either format?
object: str
type: str = "Move"
target: str
origin: str
origin: str = None
target: str = None
def action(self, allow_external_connections=True):
"""move"""
# we need to work out whether the object is a user or something else.
object_is_user = True # TODO!
object_is_user = resolve_remote_id(remote_id=self.object, model="User")
if object_is_user:
self.to_model(object_is_user=True allow_external_connections=allow_external_connections)
model = apps.get_model("bookwyrm.MoveUser")
self.to_model(model=model)
else:
self.to_model(object_is_user=False allow_external_connections=allow_external_connections)
return