Bettertyping (#10725)
To get better at catching errors on providers (It will ease also my coming PR to send microsoft messages using workflow)
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
import { assertUnreachable, ConnectedAccountProvider } from 'twenty-shared';
|
||||
|
||||
import { TwentyORMManager } from 'src/engine/twenty-orm/twenty-orm.manager';
|
||||
import { GoogleEmailAliasManagerService } from 'src/modules/connected-account/email-alias-manager/drivers/google/google-email-alias-manager.service';
|
||||
import { MicrosoftEmailAliasManagerService } from 'src/modules/connected-account/email-alias-manager/drivers/microsoft/microsoft-email-alias-manager.service';
|
||||
@ -19,20 +21,21 @@ export class EmailAliasManagerService {
|
||||
let handleAliases: string[];
|
||||
|
||||
switch (connectedAccount.provider) {
|
||||
case 'microsoft':
|
||||
case ConnectedAccountProvider.MICROSOFT:
|
||||
handleAliases =
|
||||
await this.microsoftEmailAliasManagerService.getHandleAliases(
|
||||
connectedAccount,
|
||||
);
|
||||
break;
|
||||
case 'google':
|
||||
case ConnectedAccountProvider.GOOGLE:
|
||||
handleAliases =
|
||||
await this.googleEmailAliasManagerService.getHandleAliases(
|
||||
connectedAccount,
|
||||
);
|
||||
break;
|
||||
default:
|
||||
throw new Error(
|
||||
assertUnreachable(
|
||||
connectedAccount.provider,
|
||||
`Email alias manager for provider ${connectedAccount.provider} is not implemented`,
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
import { OAuth2Client } from 'google-auth-library';
|
||||
import { ConnectedAccountProvider } from 'twenty-shared';
|
||||
|
||||
import { GoogleOAuth2ClientManagerService } from 'src/modules/connected-account/oauth2-client-manager/drivers/google/google-oauth2-client-manager.service';
|
||||
import { ConnectedAccountWorkspaceEntity } from 'src/modules/connected-account/standard-objects/connected-account.workspace-entity';
|
||||
@ -20,7 +21,7 @@ export class OAuth2ClientManagerService {
|
||||
const { refreshToken } = connectedAccount;
|
||||
|
||||
switch (connectedAccount.provider) {
|
||||
case 'google':
|
||||
case ConnectedAccountProvider.GOOGLE:
|
||||
return this.googleOAuth2ClientManagerService.getOAuth2Client(
|
||||
refreshToken,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user