Skip to content

Commit

Permalink
chore: add designated survivor uuid to shared vault metadata (#2527)
Browse files Browse the repository at this point in the history
* chore: add designated survivor uuid to shared vault metadata

* fix specs
  • Loading branch information
karolsojko committed Sep 22, 2023
1 parent 2c599df commit f7d204b
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ import { SharedVaultServerHash } from '@standardnotes/responses'

export type GetSharedVaultsResponse = {
sharedVaults: SharedVaultServerHash[]
designatedSurvivors: Array<{
userUuid: string
sharedVaultUuid: string
}>
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export type AsymmetricMessageSharedVaultInvite = {
description?: string
iconString: IconType | EmojiString
fileBytesUsed: number
designatedSurvivor: string | null
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export type VaultListingSharingInfo = {
sharedVaultUuid: string
ownerUserUuid: string
fileBytesUsed: number
designatedSurvivor: string | null
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ describe('ProcessAcceptedVaultInvite', () => {
name: 'test-name',
iconString: 'safe-square',
fileBytesUsed: 0,
designatedSurvivor: null,
},
trustedContacts: [],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class ProcessAcceptedVaultInvite {
sharedVaultUuid: sharedVaultUuid,
ownerUserUuid: ownerUuid,
fileBytesUsed: metadata.fileBytesUsed,
designatedSurvivor: metadata.designatedSurvivor,
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class ConvertToSharedVault {
sharedVaultUuid: serverVaultHash.uuid,
ownerUserUuid: serverVaultHash.user_uuid,
fileBytesUsed: serverVaultHash.file_upload_bytes_used,
designatedSurvivor: null,
}
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export class CreateSharedVault {
sharedVaultUuid: serverVaultHash.uuid,
ownerUserUuid: serverVaultHash.user_uuid,
fileBytesUsed: serverVaultHash.file_upload_bytes_used,
designatedSurvivor: null,
}
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,22 @@ export class SyncLocalVaultsWithRemoteSharedVaults implements UseCaseInterface<v
}
const remoteVaults = remoteVaultsResponse.data.sharedVaults

const designatedSurvivors = remoteVaultsResponse.data.designatedSurvivors || []

for (const localVault of localVaults) {
if (!localVault.isSharedVaultListing()) {
continue
}
const remoteVault = remoteVaults.find((vault) => vault.uuid === localVault.sharing.sharedVaultUuid)
if (remoteVault) {
const designatedSurvivor = designatedSurvivors.find((survivor) => survivor.sharedVaultUuid === remoteVault.uuid)
await this.mutator.changeItem<VaultListingMutator, SharedVaultListingInterface>(localVault, (mutator) => {
/* istanbul ignore next */
mutator.sharing = {
sharedVaultUuid: remoteVault.uuid,
ownerUserUuid: remoteVault.user_uuid,
fileBytesUsed: remoteVault.file_upload_bytes_used,
designatedSurvivor: designatedSurvivor ? designatedSurvivor.userUuid : null,
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export class InviteToVault implements UseCaseInterface<SharedVaultInviteServerHa
description: params.sharedVault.description,
iconString: params.sharedVault.iconString,
fileBytesUsed: params.sharedVault.sharing.fileBytesUsed,
designatedSurvivor: params.sharedVault.sharing.designatedSurvivor,
},
},
},
Expand Down

0 comments on commit f7d204b

Please sign in to comment.