Skip to content

Commit

Permalink
fix: invalidate bluesky credentials when account is deactivated
Browse files Browse the repository at this point in the history
  • Loading branch information
thilobillerbeck committed Nov 17, 2024
1 parent 198dcee commit 52dae21
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions lib/tasks/mastodonToBluesky.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,40 @@ export default async function taskMastodonToBluesky() {
}
}

let result = await blueskyClient.post(postBsky);
try {
let result = await blueskyClient.post(postBsky);

if (repRef.root === undefined) repRef.root = result;
repRef.parent = result;
if (repRef.root === undefined) repRef.root = result;
repRef.parent = result;
} catch (err) {
if(err.error === "AccountDeactivated") {
logSchedulerEvent(
user.name,
user.mastodonInstance.url,
"REPOSTER",
`Account deactivated, invalidating creds`
);

db.user.update({
where: {
id: user.id
},
data: {
blueskySession: null,
blueskySessionEvent: null,
blueskyToken: null,
blueskyHandle: null
}
}).then(() => {
logSchedulerEvent(user.name, user.mastodonInstance.url, "AGENT", "bluesky creds invalidated")
}).catch((err) => {
logSchedulerEvent(user.name, user.mastodonInstance.url, "AGENT", "could not clear creds")
console.error(err)
})

return;
}
}
}

repostsInThisRun[post.id] = repRef;
Expand Down

0 comments on commit 52dae21

Please sign in to comment.