From 1b4c1ef87e80715d0e0fbbd25b9f263f460fb4c3 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 14 Oct 2024 23:49:24 -0400 Subject: [PATCH] fix Firefish --- mastodon/models/mastodon.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mastodon/models/mastodon.py b/mastodon/models/mastodon.py index e15a6cefd..e6012016c 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