[Outlook integration] part 2 : GetMessages (#9612)
### Introducing - mock files in order to setup unit test on parsing outlook messages - special spec files for development purposes : dev.spec files. They are CI skipped with xdescribe but very useful for iterating on new messages format - main functionality : getMessages. We use microsoft default client to do so, using the $batch endpoint to group calls by 20 ### documentation final touch to add troubleshooting tips
This commit is contained in:
@ -17,6 +17,8 @@ export class EmailAliasManagerService {
|
||||
let handleAliases: string[];
|
||||
|
||||
switch (connectedAccount.provider) {
|
||||
case 'microsoft':
|
||||
return;
|
||||
case 'google':
|
||||
handleAliases =
|
||||
await this.googleEmailAliasManagerService.getHandleAliases(
|
||||
|
||||
@ -20,6 +20,7 @@ export class RefreshAccessTokenService {
|
||||
workspaceId: string,
|
||||
): Promise<string> {
|
||||
const refreshToken = connectedAccount.refreshToken;
|
||||
let accessToken: string;
|
||||
|
||||
if (!refreshToken) {
|
||||
throw new RefreshAccessTokenException(
|
||||
@ -28,33 +29,39 @@ export class RefreshAccessTokenService {
|
||||
);
|
||||
}
|
||||
|
||||
let accessToken: string;
|
||||
switch (connectedAccount.provider) {
|
||||
case 'microsoft':
|
||||
return '';
|
||||
case 'google': {
|
||||
try {
|
||||
accessToken = await this.refreshAccessToken(
|
||||
connectedAccount,
|
||||
refreshToken,
|
||||
);
|
||||
} catch (error) {
|
||||
throw new RefreshAccessTokenException(
|
||||
`Error refreshing access token for connected account ${connectedAccount.id} in workspace ${workspaceId}: ${error.message}`,
|
||||
RefreshAccessTokenExceptionCode.REFRESH_ACCESS_TOKEN_FAILED,
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
accessToken = await this.refreshAccessToken(
|
||||
connectedAccount,
|
||||
refreshToken,
|
||||
);
|
||||
} catch (error) {
|
||||
throw new RefreshAccessTokenException(
|
||||
`Error refreshing access token for connected account ${connectedAccount.id} in workspace ${workspaceId}: ${error.message}`,
|
||||
RefreshAccessTokenExceptionCode.REFRESH_ACCESS_TOKEN_FAILED,
|
||||
);
|
||||
const connectedAccountRepository =
|
||||
await this.twentyORMManager.getRepository<ConnectedAccountWorkspaceEntity>(
|
||||
'connectedAccount',
|
||||
);
|
||||
|
||||
await connectedAccountRepository.update(
|
||||
{ id: connectedAccount.id },
|
||||
{
|
||||
accessToken,
|
||||
},
|
||||
);
|
||||
|
||||
return accessToken;
|
||||
}
|
||||
default:
|
||||
throw new Error('Provider not supported for access token refresh');
|
||||
}
|
||||
|
||||
const connectedAccountRepository =
|
||||
await this.twentyORMManager.getRepository<ConnectedAccountWorkspaceEntity>(
|
||||
'connectedAccount',
|
||||
);
|
||||
|
||||
await connectedAccountRepository.update(
|
||||
{ id: connectedAccount.id },
|
||||
{
|
||||
accessToken,
|
||||
},
|
||||
);
|
||||
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
async refreshAccessToken(
|
||||
|
||||
Reference in New Issue
Block a user