6382 create a command to add a uservar in the key value pair table for every account which needs to reconnect (#6553)

Closes #6382

Create SetUserVarsAccountsToReconnectCommand.
This command loops on all workspaces and:
- deletes all user vars with deprecated key `ACCOUNTS_TO_RECONNECT`
- creates a key value pair of type `USER_VAR` with a key of
`ACCOUNTS_TO_RECONNECT_INSUFFICIENT_PERMISSIONS` for all connect
accounts with a message channel or calendar channel with status
`FAILED_INSUFFICIENT_PERMISSIONS`
This commit is contained in:
bosiraphael
2024-08-07 11:43:18 +02:00
committed by GitHub
parent 2abb6adb61
commit 5a72b949d7
9 changed files with 220 additions and 62 deletions

View File

@ -64,4 +64,31 @@ export class AccountsToReconnectService {
value: updatedAccountsToReconnect,
});
}
public async addAccountToReconnectByKey(
key: AccountsToReconnectKeys,
userId: string,
workspaceId: string,
connectedAccountId: string,
) {
const accountsToReconnect =
(await this.userVarsService.get({
userId,
workspaceId,
key,
})) ?? [];
if (accountsToReconnect.includes(connectedAccountId)) {
return;
}
accountsToReconnect.push(connectedAccountId);
await this.userVarsService.set({
userId,
workspaceId,
key,
value: accountsToReconnect,
});
}
}