Skip to content

Commit

Permalink
chore: improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustrb committed Oct 21, 2024
1 parent 7d7c08e commit f391fbb
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { IWorkspaceCredentials } from '@rocket.chat/core-typings';
import { WorkspaceCredentials } from '@rocket.chat/models';

import { SystemLogger } from '../../../../server/lib/logger/system';
import { workspaceScopes } from '../oauthScopes';
import { getWorkspaceAccessTokenWithScope } from './getWorkspaceAccessTokenWithScope';
import { retrieveRegistrationStatus } from './retrieveRegistrationStatus';
Expand Down Expand Up @@ -31,9 +32,14 @@ export async function getWorkspaceAccessToken(forceNew = false, scope = '', save

const workspaceCredentials = await WorkspaceCredentials.getCredentialByScope(scopes);
if (workspaceCredentials && !hasWorkspaceAccessTokenExpired(workspaceCredentials) && !forceNew) {
SystemLogger.debug(
`Workspace Credentials cache hit using scopes: ${scopes}. Avoiding generating a new access token from cloud services.`,
);
return workspaceCredentials.accessToken;
}

SystemLogger.debug(`Workspace credentials cache miss using scopes: ${scopes}, fetching new access token from cloud services.`);

const accessToken = await getWorkspaceAccessTokenWithScope(scope, throwOnError);

if (save) {
Expand Down

0 comments on commit f391fbb

Please sign in to comment.