fixing : "message" : "Mail service not enabled" (#12349)

Fix Gmail API error handling for "Mail service not enabled" scenarios
Add proper await

Improves Gmail API error handling by properly detecting "Mail service
not enabled" errors and classifying them as INSUFFICIENT_PERMISSIONS
instead of TEMPORARY_ERROR


Fixes https://github.com/twentyhq/twenty/issues/12260
### Refernce :


https://stackoverflow.com/questions/31692720/gmail-api-returning-status-code-400-error-mail-service-not-enabled
This commit is contained in:
Guillim
2025-05-28 13:49:19 +02:00
committed by GitHub
parent a4f190b913
commit 0a0fb976bf
3 changed files with 18 additions and 3 deletions
@@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common';
import { assertUnreachable } from 'twenty-shared/utils';
import { ConnectedAccountProvider } from 'twenty-shared/types';
import { assertUnreachable } from 'twenty-shared/utils';
import { TwentyORMManager } from 'src/engine/twenty-orm/twenty-orm.manager';
import {
@@ -74,11 +74,11 @@ export class ConnectedAccountRefreshTokensService {
try {
switch (connectedAccount.provider) {
case ConnectedAccountProvider.GOOGLE:
return this.googleAPIRefreshAccessTokenService.refreshAccessToken(
return await this.googleAPIRefreshAccessTokenService.refreshAccessToken(
refreshToken,
);
case ConnectedAccountProvider.MICROSOFT:
return this.microsoftAPIRefreshAccessTokenService.refreshTokens(
return await this.microsoftAPIRefreshAccessTokenService.refreshTokens(
refreshToken,
);
default: