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:
@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user