Refacto environment service (#4473)
* Refacto environment service * Remove environment variable type
This commit is contained in:
@ -48,8 +48,8 @@ export class GoogleAPIsRefreshAccessTokenService {
|
||||
const response = await axios.post(
|
||||
'https://oauth2.googleapis.com/token',
|
||||
{
|
||||
client_id: this.environmentService.getAuthGoogleClientId(),
|
||||
client_secret: this.environmentService.getAuthGoogleClientSecret(),
|
||||
client_id: this.environmentService.get('AUTH_GOOGLE_CLIENT_ID'),
|
||||
client_secret: this.environmentService.get('AUTH_GOOGLE_CLIENT_SECRET'),
|
||||
refresh_token: refreshToken,
|
||||
grant_type: 'refresh_token',
|
||||
},
|
||||
|
||||
@ -23,10 +23,12 @@ export class GoogleCalendarClientProvider {
|
||||
}
|
||||
|
||||
private async getOAuth2Client(refreshToken: string): Promise<OAuth2Client> {
|
||||
const googleCalendarClientId =
|
||||
this.environmentService.getAuthGoogleClientId();
|
||||
const googleCalendarClientSecret =
|
||||
this.environmentService.getAuthGoogleClientSecret();
|
||||
const googleCalendarClientId = this.environmentService.get(
|
||||
'AUTH_GOOGLE_CLIENT_ID',
|
||||
);
|
||||
const googleCalendarClientSecret = this.environmentService.get(
|
||||
'AUTH_GOOGLE_CLIENT_SECRET',
|
||||
);
|
||||
|
||||
const oAuth2Client = new google.auth.OAuth2(
|
||||
googleCalendarClientId,
|
||||
|
||||
@ -21,9 +21,9 @@ export class GmailClientProvider {
|
||||
}
|
||||
|
||||
private async getOAuth2Client(refreshToken: string): Promise<OAuth2Client> {
|
||||
const gmailClientId = this.environmentService.getAuthGoogleClientId();
|
||||
const gmailClientId = this.environmentService.get('AUTH_GOOGLE_CLIENT_ID');
|
||||
const gmailClientSecret =
|
||||
this.environmentService.getAuthGoogleClientSecret();
|
||||
this.environmentService.get('AUTH_GOOGLE_CLIENT_SECRET');
|
||||
|
||||
const oAuth2Client = new google.auth.OAuth2(
|
||||
gmailClientId,
|
||||
|
||||
@ -45,9 +45,9 @@ export class CleanInactiveWorkspaceJob
|
||||
private readonly environmentService: EnvironmentService,
|
||||
) {
|
||||
this.inactiveDaysBeforeDelete =
|
||||
this.environmentService.getInactiveDaysBeforeDelete();
|
||||
this.environmentService.get('WORKSPACE_INACTIVE_DAYS_BEFORE_DELETION');
|
||||
this.inactiveDaysBeforeEmail =
|
||||
this.environmentService.getInactiveDaysBeforeEmail();
|
||||
this.environmentService.get('WORKSPACE_INACTIVE_DAYS_BEFORE_NOTIFICATION');
|
||||
}
|
||||
|
||||
async getMostRecentUpdatedAt(
|
||||
@ -133,8 +133,8 @@ export class CleanInactiveWorkspaceJob
|
||||
|
||||
this.emailService.send({
|
||||
to: workspaceMember.email,
|
||||
bcc: this.environmentService.getEmailSystemAddress(),
|
||||
from: `${this.environmentService.getEmailFromName()} <${this.environmentService.getEmailFromAddress()}>`,
|
||||
bcc: this.environmentService.get('EMAIL_SYSTEM_ADDRESS'),
|
||||
from: `${this.environmentService.get('EMAIL_FROM_NAME')} <${this.environmentService.get('EMAIL_FROM_ADDRESS')}>`,
|
||||
subject: 'Action Needed to Prevent Workspace Deletion',
|
||||
html,
|
||||
text,
|
||||
@ -179,8 +179,8 @@ export class CleanInactiveWorkspaceJob
|
||||
});
|
||||
|
||||
await this.emailService.send({
|
||||
to: this.environmentService.getEmailSystemAddress(),
|
||||
from: `${this.environmentService.getEmailFromName()} <${this.environmentService.getEmailFromAddress()}>`,
|
||||
to: this.environmentService.get('EMAIL_SYSTEM_ADDRESS'),
|
||||
from: `${this.environmentService.get('EMAIL_FROM_NAME')} <${this.environmentService.get('EMAIL_FROM_ADDRESS')}>`,
|
||||
subject: 'Action Needed to Delete Workspaces',
|
||||
html,
|
||||
text,
|
||||
|
||||
@ -307,7 +307,7 @@ export class WorkspaceQueryRunnerService {
|
||||
): Promise<Record[] | undefined> {
|
||||
const { workspaceId, objectMetadataItem } = options;
|
||||
const maximumRecordAffected =
|
||||
this.environmentService.getMutationMaximumRecordAffected();
|
||||
this.environmentService.get('MUTATION_MAXIMUM_RECORD_AFFECTED');
|
||||
const query = await this.workspaceQueryBuilderFactory.updateMany(args, {
|
||||
...options,
|
||||
atMost: maximumRecordAffected,
|
||||
@ -339,7 +339,7 @@ export class WorkspaceQueryRunnerService {
|
||||
): Promise<Record[] | undefined> {
|
||||
const { workspaceId, objectMetadataItem } = options;
|
||||
const maximumRecordAffected =
|
||||
this.environmentService.getMutationMaximumRecordAffected();
|
||||
this.environmentService.get('MUTATION_MAXIMUM_RECORD_AFFECTED');
|
||||
const query = await this.workspaceQueryBuilderFactory.deleteMany(args, {
|
||||
...options,
|
||||
atMost: maximumRecordAffected,
|
||||
|
||||
Reference in New Issue
Block a user