diff --git a/mastodon/models/mastodon.py b/mastodon/models/mastodon.py index e15a6cef..e6012016 100644 --- a/mastodon/models/mastodon.py +++ b/mastodon/models/mastodon.py @@ -592,6 +592,17 @@ def authenticate(domain, access_token, refresh_token) -> "MastodonAccount | None uid=mastodon_account.uid, domain=mastodon_account.domain, ).first() + if not existing_account: + existing_account = MastodonAccount.objects.filter( + handle=mastodon_account.handle, + domain=mastodon_account.domain, + ).first() + if existing_account: + # this is only needed if server is Firefish + logger.warning( + f"USER ID CHANGED: {existing_account.uid} -> {mastodon_account.uid} for {existing_account.handle}" + ) + existing_account.uid = mastodon_account.uid if existing_account: existing_account.access_token = mastodon_account.access_token existing_account.refresh_token = mastodon_account.refresh_token