Skip to content

Commit

Permalink
Do not delete account transfer information upon rebind
Browse files Browse the repository at this point in the history
  • Loading branch information
Rian8337 committed Dec 13, 2024
1 parent 01ff94f commit b7208b2
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions src/database/utils/elainaDb/UserBind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,34 @@ export class UserBind extends Manager implements DatabaseUserBind {
{ $set: { discordid: to } },
);

// Remove the new Discord account's account transfer information.
await DatabaseManager.aliceDb.collections.accountTransfer.deleteOne({
discordId: to,
});
// Append the Discord account's account transfer information.
const transferInfo =
await DatabaseManager.aliceDb.collections.accountTransfer.getFromDiscordId(
this.discordid,
);

await DatabaseManager.aliceDb.collections.accountTransfer.updateOne(
{ discordId: this.discordid },
{ $set: { discordId: to } },
);
if (transferInfo) {
await DatabaseManager.aliceDb.collections.accountTransfer.updateOne(
{ discordId: to },
{
$addToSet: {
transferList: { $each: transferInfo.transferList },
},
$setOnInsert: {
discordId: to,
transferUid: transferInfo.transferUid,
// Assume transfer is done.
transferDone: true,
},
},
{ upsert: true },
);

// Remove the Discord account's account transfer information.
await DatabaseManager.aliceDb.collections.accountTransfer.deleteOne(
{ discordId: this.discordid },
);
}

await this.bindDb.updateOne(
{ discordid: this.discordid },
Expand Down

0 comments on commit b7208b2

Please sign in to comment.