diff --git a/.yarn/cache/@standardnotes-domain-core-npm-1.25.0-51a2ed924b-f99196f620.zip b/.yarn/cache/@standardnotes-domain-core-npm-1.25.0-51a2ed924b-f99196f620.zip new file mode 100644 index 00000000000..aa20e6ae09b Binary files /dev/null and b/.yarn/cache/@standardnotes-domain-core-npm-1.25.0-51a2ed924b-f99196f620.zip differ diff --git a/packages/api/package.json b/packages/api/package.json index 17d59d117c7..76f037330c0 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -36,7 +36,7 @@ }, "dependencies": { "@standardnotes/common": "^1.50.0", - "@standardnotes/domain-core": "^1.24.0", + "@standardnotes/domain-core": "^1.25.0", "@standardnotes/models": "workspace:*", "@standardnotes/responses": "workspace:*", "@standardnotes/utils": "workspace:*", diff --git a/packages/desktop/package.json b/packages/desktop/package.json index 80908d8a5c1..81c8c92bf04 100644 --- a/packages/desktop/package.json +++ b/packages/desktop/package.json @@ -35,7 +35,7 @@ }, "dependencies": { "@electron/remote": "^2.0.9", - "@standardnotes/domain-core": "^1.24.0", + "@standardnotes/domain-core": "^1.25.0", "@standardnotes/electron-clear-data": "1.1.1", "@standardnotes/web": "workspace:*", "axios": "^1.1.3", diff --git a/packages/encryption/package.json b/packages/encryption/package.json index 605cfe6836d..205d6ec6e3b 100644 --- a/packages/encryption/package.json +++ b/packages/encryption/package.json @@ -29,7 +29,7 @@ }, "dependencies": { "@standardnotes/common": "^1.50.0", - "@standardnotes/domain-core": "^1.24.0", + "@standardnotes/domain-core": "^1.25.0", "@standardnotes/models": "workspace:*", "@standardnotes/responses": "workspace:*", "@standardnotes/sncrypto-common": "workspace:*", diff --git a/packages/features/package.json b/packages/features/package.json index a8a4a82f1ca..4d0b28b57d1 100644 --- a/packages/features/package.json +++ b/packages/features/package.json @@ -26,7 +26,7 @@ }, "dependencies": { "@standardnotes/common": "^1.50.0", - "@standardnotes/domain-core": "^1.24.0", + "@standardnotes/domain-core": "^1.25.0", "reflect-metadata": "^0.1.13" }, "devDependencies": { diff --git a/packages/models/package.json b/packages/models/package.json index 3e1452bd76b..62407b72a5a 100644 --- a/packages/models/package.json +++ b/packages/models/package.json @@ -23,7 +23,7 @@ }, "dependencies": { "@standardnotes/common": "^1.50.0", - "@standardnotes/domain-core": "^1.24.0", + "@standardnotes/domain-core": "^1.25.0", "@standardnotes/features": "workspace:*", "@standardnotes/responses": "workspace:*", "@standardnotes/sncrypto-common": "workspace:^", diff --git a/packages/models/src/Domain/Abstract/TransferPayload/Interfaces/TypeCheck.ts b/packages/models/src/Domain/Abstract/TransferPayload/Interfaces/TypeCheck.ts index 9466a6d9679..b8c96e1686f 100644 --- a/packages/models/src/Domain/Abstract/TransferPayload/Interfaces/TypeCheck.ts +++ b/packages/models/src/Domain/Abstract/TransferPayload/Interfaces/TypeCheck.ts @@ -26,5 +26,7 @@ export function isDeletedTransferPayload(payload: TransferPayload): payload is D export function isCorruptTransferPayload(payload: TransferPayload): boolean { const invalidDeletedState = payload.deleted === true && payload.content != undefined - return payload.uuid == undefined || invalidDeletedState || payload.content_type === ContentType.TYPES.Unknown + const contenTypeOrError = ContentType.create(payload.content_type) + + return payload.uuid == undefined || invalidDeletedState || contenTypeOrError.isFailed() } diff --git a/packages/services/package.json b/packages/services/package.json index c37e931db6c..93def928ba1 100644 --- a/packages/services/package.json +++ b/packages/services/package.json @@ -18,7 +18,7 @@ "dependencies": { "@standardnotes/api": "workspace:^", "@standardnotes/common": "^1.50.0", - "@standardnotes/domain-core": "^1.24.0", + "@standardnotes/domain-core": "^1.25.0", "@standardnotes/encryption": "workspace:^", "@standardnotes/features": "workspace:^", "@standardnotes/files": "workspace:^", diff --git a/packages/services/src/Domain/SharedVaults/SharedVaultService.ts b/packages/services/src/Domain/SharedVaults/SharedVaultService.ts index 92ac053010d..a0c6d789299 100644 --- a/packages/services/src/Domain/SharedVaults/SharedVaultService.ts +++ b/packages/services/src/Domain/SharedVaults/SharedVaultService.ts @@ -1,6 +1,6 @@ import { DiscardItemsLocally } from './../UseCase/DiscardItemsLocally' import { UserKeyPairChangedEventData } from './../Session/UserKeyPairChangedEventData' -import { ClientDisplayableError } from '@standardnotes/responses' +import { ClientDisplayableError, isErrorResponse } from '@standardnotes/responses' import { DecryptedItemInterface, PayloadEmitSource, @@ -10,6 +10,7 @@ import { KeySystemRootKeyStorageMode, EmojiString, IconType, + VaultListingMutator, } from '@standardnotes/models' import { SharedVaultServiceInterface } from './SharedVaultServiceInterface' import { SharedVaultServiceEvent, SharedVaultServiceEventPayload } from './SharedVaultServiceEvent' @@ -32,6 +33,8 @@ import { ContentType, NotificationType, Uuid } from '@standardnotes/domain-core' import { HandleKeyPairChange } from '../Contacts/UseCase/HandleKeyPairChange' import { FindContact } from '../Contacts/UseCase/FindContact' import { GetOwnedSharedVaults } from './UseCase/GetOwnedSharedVaults' +import { MutatorClientInterface } from '../Mutator/MutatorClientInterface' +import { SharedVaultServerInterface } from '@standardnotes/api' export class SharedVaultService extends AbstractService @@ -40,6 +43,8 @@ export class SharedVaultService constructor( private items: ItemManagerInterface, private session: SessionsClientInterface, + private mutator: MutatorClientInterface, + private sharedVaultServer: SharedVaultServerInterface, private _getVault: GetVault, private _getOwnedSharedVaults: GetOwnedSharedVaults, private _createSharedVault: CreateSharedVault, @@ -88,7 +93,7 @@ export class SharedVaultService break } case NotificationServiceEvent.NotificationReceived: - await this.handleUserEvent(event.payload as NotificationServiceEventPayload) + await this.handleNotification(event.payload as NotificationServiceEventPayload) break case SyncEvent.ReceivedRemoteSharedVaults: void this.notifyEventSync(SharedVaultServiceEvent.SharedVaultStatusChanged) @@ -96,7 +101,7 @@ export class SharedVaultService } } - private async handleUserEvent(event: NotificationServiceEventPayload): Promise { + private async handleNotification(event: NotificationServiceEventPayload): Promise { switch (event.eventPayload.props.type.value) { case NotificationType.TYPES.RemovedFromSharedVault: { const vault = this._getVault.execute({ @@ -114,6 +119,34 @@ export class SharedVaultService } break } + case NotificationType.TYPES.SharedVaultFileRemoved: + case NotificationType.TYPES.SharedVaultFileUploaded: { + const vaultOrError = this._getVault.execute({ + sharedVaultUuid: event.eventPayload.props.sharedVaultUuid.value, + }) + if (vaultOrError.isFailed()) { + return + } + const vault = vaultOrError.getValue() + + const serverResult = await this.sharedVaultServer.getSharedVaults() + if (!isErrorResponse(serverResult)) { + const remoteSharedVault = serverResult.data.sharedVaults.find( + (sharedVault) => sharedVault.uuid === vault.uuid, + ) + if (remoteSharedVault) { + await this.mutator.changeItem(vault, (mutator) => { + mutator.sharing = { + sharedVaultUuid: remoteSharedVault.uuid, + ownerUserUuid: remoteSharedVault.user_uuid, + fileBytesUsed: remoteSharedVault.file_upload_bytes_used, + } + }) + } + } + + break + } } } diff --git a/packages/snjs/lib/Application/Dependencies/Dependencies.ts b/packages/snjs/lib/Application/Dependencies/Dependencies.ts index 9cb6cacb39b..d1e074e8934 100644 --- a/packages/snjs/lib/Application/Dependencies/Dependencies.ts +++ b/packages/snjs/lib/Application/Dependencies/Dependencies.ts @@ -834,6 +834,8 @@ export class Dependencies { return new SharedVaultService( this.get(TYPES.ItemManager), this.get(TYPES.SessionManager), + this.get(TYPES.MutatorService), + this.get(TYPES.SharedVaultServer), this.get(TYPES.GetVault), this.get(TYPES.GetOwnedSharedVaults), this.get(TYPES.CreateSharedVault), diff --git a/packages/snjs/package.json b/packages/snjs/package.json index e572d5aac81..572b7135e7f 100644 --- a/packages/snjs/package.json +++ b/packages/snjs/package.json @@ -37,7 +37,7 @@ "@babel/preset-env": "*", "@standardnotes/api": "workspace:*", "@standardnotes/common": "^1.50.0", - "@standardnotes/domain-core": "^1.24.0", + "@standardnotes/domain-core": "^1.25.0", "@standardnotes/domain-events": "^2.108.1", "@standardnotes/encryption": "workspace:*", "@standardnotes/features": "workspace:*", diff --git a/packages/ui-services/package.json b/packages/ui-services/package.json index a1050bcdc10..c0c6ff877bd 100644 --- a/packages/ui-services/package.json +++ b/packages/ui-services/package.json @@ -16,7 +16,7 @@ }, "dependencies": { "@standardnotes/common": "^1.50.0", - "@standardnotes/domain-core": "^1.24.0", + "@standardnotes/domain-core": "^1.25.0", "@standardnotes/features": "workspace:^", "@standardnotes/filepicker": "workspace:^", "@standardnotes/models": "workspace:^", diff --git a/yarn.lock b/yarn.lock index 2dee2e964cd..f9838782efb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4140,7 +4140,7 @@ __metadata: resolution: "@standardnotes/api@workspace:packages/api" dependencies: "@standardnotes/common": ^1.50.0 - "@standardnotes/domain-core": ^1.24.0 + "@standardnotes/domain-core": ^1.25.0 "@standardnotes/models": "workspace:*" "@standardnotes/responses": "workspace:*" "@standardnotes/utils": "workspace:*" @@ -4290,7 +4290,7 @@ __metadata: "@babel/core": "*" "@babel/preset-env": "*" "@electron/remote": ^2.0.9 - "@standardnotes/domain-core": ^1.24.0 + "@standardnotes/domain-core": ^1.25.0 "@standardnotes/electron-clear-data": 1.1.1 "@standardnotes/web": "workspace:*" "@types/fs-extra": ^11.0.1 @@ -4333,7 +4333,7 @@ __metadata: languageName: unknown linkType: soft -"@standardnotes/domain-core@npm:^1.24.0, @standardnotes/domain-core@npm:^1.24.1": +"@standardnotes/domain-core@npm:^1.24.1": version: 1.24.1 resolution: "@standardnotes/domain-core@npm:1.24.1" dependencies: @@ -4342,6 +4342,15 @@ __metadata: languageName: node linkType: hard +"@standardnotes/domain-core@npm:^1.25.0": + version: 1.25.0 + resolution: "@standardnotes/domain-core@npm:1.25.0" + dependencies: + uuid: ^9.0.0 + checksum: f99196f6209a05a50e84371d3a59cf870937a5589f4ba4caab0f2eb17c2cfa733142b18ca8788016c81ca609d1f5a0461e51bcf159a67d631e249a04a5568244 + languageName: node + linkType: hard + "@standardnotes/domain-events@npm:^2.108.1": version: 2.113.1 resolution: "@standardnotes/domain-events@npm:2.113.1" @@ -4385,7 +4394,7 @@ __metadata: dependencies: "@standardnotes/common": ^1.50.0 "@standardnotes/config": 2.4.3 - "@standardnotes/domain-core": ^1.24.0 + "@standardnotes/domain-core": ^1.25.0 "@standardnotes/models": "workspace:*" "@standardnotes/responses": "workspace:*" "@standardnotes/sncrypto-common": "workspace:*" @@ -4420,7 +4429,7 @@ __metadata: resolution: "@standardnotes/features@workspace:packages/features" dependencies: "@standardnotes/common": ^1.50.0 - "@standardnotes/domain-core": ^1.24.0 + "@standardnotes/domain-core": ^1.25.0 "@types/jest": ^29.2.3 "@typescript-eslint/eslint-plugin": "*" eslint: "*" @@ -4626,7 +4635,7 @@ __metadata: resolution: "@standardnotes/models@workspace:packages/models" dependencies: "@standardnotes/common": ^1.50.0 - "@standardnotes/domain-core": ^1.24.0 + "@standardnotes/domain-core": ^1.25.0 "@standardnotes/features": "workspace:*" "@standardnotes/responses": "workspace:*" "@standardnotes/sncrypto-common": "workspace:^" @@ -4712,7 +4721,7 @@ __metadata: dependencies: "@standardnotes/api": "workspace:^" "@standardnotes/common": ^1.50.0 - "@standardnotes/domain-core": ^1.24.0 + "@standardnotes/domain-core": ^1.25.0 "@standardnotes/encryption": "workspace:^" "@standardnotes/features": "workspace:^" "@standardnotes/files": "workspace:^" @@ -4811,7 +4820,7 @@ __metadata: "@babel/preset-env": "*" "@standardnotes/api": "workspace:*" "@standardnotes/common": ^1.50.0 - "@standardnotes/domain-core": ^1.24.0 + "@standardnotes/domain-core": ^1.25.0 "@standardnotes/domain-events": ^2.108.1 "@standardnotes/encryption": "workspace:*" "@standardnotes/features": "workspace:*" @@ -4936,7 +4945,7 @@ __metadata: resolution: "@standardnotes/ui-services@workspace:packages/ui-services" dependencies: "@standardnotes/common": ^1.50.0 - "@standardnotes/domain-core": ^1.24.0 + "@standardnotes/domain-core": ^1.25.0 "@standardnotes/features": "workspace:^" "@standardnotes/filepicker": "workspace:^" "@standardnotes/models": "workspace:^"