diff --git a/packages/domain-events/src/Domain/Event/GoogleDriveBackupFailedEvent.ts b/packages/domain-events/src/Domain/Event/GoogleDriveBackupFailedEvent.ts deleted file mode 100644 index d0571a6b2..000000000 --- a/packages/domain-events/src/Domain/Event/GoogleDriveBackupFailedEvent.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { DomainEventInterface } from './DomainEventInterface' - -import { GoogleDriveBackupFailedEventPayload } from './GoogleDriveBackupFailedEventPayload' - -export interface GoogleDriveBackupFailedEvent extends DomainEventInterface { - type: 'GOOGLE_DRIVE_BACKUP_FAILED' - payload: GoogleDriveBackupFailedEventPayload -} diff --git a/packages/domain-events/src/Domain/Event/GoogleDriveBackupFailedEventPayload.ts b/packages/domain-events/src/Domain/Event/GoogleDriveBackupFailedEventPayload.ts deleted file mode 100644 index 6514ce713..000000000 --- a/packages/domain-events/src/Domain/Event/GoogleDriveBackupFailedEventPayload.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface GoogleDriveBackupFailedEventPayload { - muteCloudEmailsSettingUuid: string - extensionSettingUuid?: string - email: string -} diff --git a/packages/domain-events/src/Domain/index.ts b/packages/domain-events/src/Domain/index.ts index 0c84acd89..d0123724d 100644 --- a/packages/domain-events/src/Domain/index.ts +++ b/packages/domain-events/src/Domain/index.ts @@ -34,8 +34,6 @@ export * from './Event/FileRemovedEvent' export * from './Event/FileRemovedEventPayload' export * from './Event/FileUploadedEvent' export * from './Event/FileUploadedEventPayload' -export * from './Event/GoogleDriveBackupFailedEvent' -export * from './Event/GoogleDriveBackupFailedEventPayload' export * from './Event/ItemDumpedEvent' export * from './Event/ItemDumpedEventPayload' export * from './Event/ItemRevisionCreationRequestedEvent' diff --git a/packages/syncing-server/src/Domain/Email/GoogleDriveBackupFailed.ts b/packages/syncing-server/src/Domain/Email/GoogleDriveBackupFailed.ts new file mode 100644 index 000000000..bc2340f35 --- /dev/null +++ b/packages/syncing-server/src/Domain/Email/GoogleDriveBackupFailed.ts @@ -0,0 +1,9 @@ +import { html } from './google-drive-backup-failed.html' + +export function getSubject(): string { + return 'Failed Daily Backup to Google Drive Sync' +} + +export function getBody(): string { + return html +} diff --git a/packages/syncing-server/src/Domain/Email/google-drive-backup-failed.html.ts b/packages/syncing-server/src/Domain/Email/google-drive-backup-failed.html.ts new file mode 100644 index 000000000..4654d40e9 --- /dev/null +++ b/packages/syncing-server/src/Domain/Email/google-drive-backup-failed.html.ts @@ -0,0 +1,19 @@ +export const html = `

Hello,

+

We recently tried backing up your data to Google Drive Sync, but an issue prevented us from + doing + so.

+

+ The usual cause is an expired or revoked token from your sync provider. Please follow + these + instructions + to use CloudLink on the web or desktop Standard Notes application to uninstall then reinstall this sync provider. +

+

+ We apologize for any inconvenience this may cause. + If you have any questions, please feel free to reply directly to this email. +

+

+ Thanks, +
SN
+

+Mute these emails` diff --git a/packages/syncing-server/src/Domain/Event/DomainEventFactory.ts b/packages/syncing-server/src/Domain/Event/DomainEventFactory.ts index 93b5f9da9..2619ee3c8 100644 --- a/packages/syncing-server/src/Domain/Event/DomainEventFactory.ts +++ b/packages/syncing-server/src/Domain/Event/DomainEventFactory.ts @@ -5,7 +5,7 @@ import { DuplicateItemSyncedEvent, EmailArchiveExtensionSyncedEvent, EmailBackupAttachmentCreatedEvent, - GoogleDriveBackupFailedEvent, + EmailRequestedEvent, ItemDumpedEvent, ItemRevisionCreationRequestedEvent, ItemsSyncedEvent, @@ -149,21 +149,24 @@ export class DomainEventFactory implements DomainEventFactoryInterface { } } - createGoogleDriveBackupFailedEvent(muteCloudEmailsSettingUuid: string, email: string): GoogleDriveBackupFailedEvent { + createEmailRequestedEvent(dto: { + userEmail: string + messageIdentifier: string + level: string + body: string + subject: string + }): EmailRequestedEvent { return { - type: 'GOOGLE_DRIVE_BACKUP_FAILED', + type: 'EMAIL_REQUESTED', createdAt: this.timer.getUTCDate(), meta: { correlation: { - userIdentifier: email, + userIdentifier: dto.userEmail, userIdentifierType: 'email', }, origin: DomainEventService.SyncingServer, }, - payload: { - muteCloudEmailsSettingUuid, - email, - }, + payload: dto, } } diff --git a/packages/syncing-server/src/Domain/Event/DomainEventFactoryInterface.ts b/packages/syncing-server/src/Domain/Event/DomainEventFactoryInterface.ts index 87e3dd442..ac39cea79 100644 --- a/packages/syncing-server/src/Domain/Event/DomainEventFactoryInterface.ts +++ b/packages/syncing-server/src/Domain/Event/DomainEventFactoryInterface.ts @@ -3,7 +3,7 @@ import { DuplicateItemSyncedEvent, EmailArchiveExtensionSyncedEvent, EmailBackupAttachmentCreatedEvent, - GoogleDriveBackupFailedEvent, + EmailRequestedEvent, ItemDumpedEvent, ItemRevisionCreationRequestedEvent, ItemsSyncedEvent, @@ -16,7 +16,13 @@ import { export interface DomainEventFactoryInterface { createUserContentSizeRecalculationRequestedEvent(userUuid: string): UserContentSizeRecalculationRequestedEvent createDropboxBackupFailedEvent(muteCloudEmailsSettingUuid: string, email: string): DropboxBackupFailedEvent - createGoogleDriveBackupFailedEvent(muteCloudEmailsSettingUuid: string, email: string): GoogleDriveBackupFailedEvent + createEmailRequestedEvent(dto: { + userEmail: string + messageIdentifier: string + level: string + body: string + subject: string + }): EmailRequestedEvent createOneDriveBackupFailedEvent(muteCloudEmailsSettingUuid: string, email: string): OneDriveBackupFailedEvent createItemsSyncedEvent(dto: { userUuid: string diff --git a/packages/syncing-server/src/Domain/Extension/ExtensionsHttpService.ts b/packages/syncing-server/src/Domain/Extension/ExtensionsHttpService.ts index 9b583c62d..957cf1e62 100644 --- a/packages/syncing-server/src/Domain/Extension/ExtensionsHttpService.ts +++ b/packages/syncing-server/src/Domain/Extension/ExtensionsHttpService.ts @@ -1,5 +1,6 @@ import { KeyParamsData } from '@standardnotes/responses' import { DomainEventInterface, DomainEventPublisherInterface } from '@standardnotes/domain-events' +import { EmailLevel } from '@standardnotes/domain-core' import { AxiosInstance } from 'axios' import { inject, injectable } from 'inversify' import { Logger } from 'winston' @@ -10,6 +11,7 @@ import { ItemRepositoryInterface } from '../Item/ItemRepositoryInterface' import { ExtensionName } from './ExtensionName' import { ExtensionsHttpServiceInterface } from './ExtensionsHttpServiceInterface' import { SendItemsToExtensionsServerDTO } from './SendItemsToExtensionsServerDTO' +import { getBody, getSubject } from '../Email/GoogleDriveBackupFailed' @injectable() export class ExtensionsHttpService implements ExtensionsHttpServiceInterface { @@ -121,7 +123,13 @@ export class ExtensionsHttpService implements ExtensionsHttpServiceInterface { case 'DROPBOX': return this.domainEventFactory.createDropboxBackupFailedEvent(muteCloudEmailsSettingUuid, email) case 'GOOGLE_DRIVE': - return this.domainEventFactory.createGoogleDriveBackupFailedEvent(muteCloudEmailsSettingUuid, email) + return this.domainEventFactory.createEmailRequestedEvent({ + userEmail: email, + level: EmailLevel.LEVELS.FailedCloudBackup, + body: getBody(), + messageIdentifier: 'FAILED_GOOGLE_DRIVE_BACKUP', + subject: getSubject(), + }) case 'ONE_DRIVE': return this.domainEventFactory.createOneDriveBackupFailedEvent(muteCloudEmailsSettingUuid, email) }