mirror of
https://github.com/standardnotes/server
synced 2026-10-13 00:13:41 -04:00
feat(syncing-server): add deleting outbound messages
Co-authored-by: Mo <[email protected]>
This commit is contained in:
+12
@@ -24,6 +24,7 @@ describe('DeleteSharedVaultInvitesSentByUser', () => {
|
||||
|
||||
sharedVaultInviteRepository = {} as jest.Mocked<SharedVaultInviteRepositoryInterface>
|
||||
sharedVaultInviteRepository.findBySenderUuidAndSharedVaultUuid = jest.fn().mockReturnValue([sharedVaultInvite])
|
||||
sharedVaultInviteRepository.findBySenderUuid = jest.fn().mockReturnValue([sharedVaultInvite])
|
||||
|
||||
declineInviteToSharedVault = {} as jest.Mocked<DeclineInviteToSharedVault>
|
||||
declineInviteToSharedVault.execute = jest.fn().mockReturnValue(Result.ok())
|
||||
@@ -75,4 +76,15 @@ describe('DeleteSharedVaultInvitesSentByUser', () => {
|
||||
|
||||
expect(result.isFailed()).toBeTruthy()
|
||||
})
|
||||
|
||||
it('should decline all invites by user to all shared vaults', async () => {
|
||||
const useCase = createUseCase()
|
||||
|
||||
const result = await useCase.execute({
|
||||
userUuid: '00000000-0000-0000-0000-000000000000',
|
||||
})
|
||||
|
||||
expect(result.isFailed()).toBeFalsy()
|
||||
expect(declineInviteToSharedVault.execute).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
+14
-8
@@ -16,16 +16,22 @@ export class DeleteSharedVaultInvitesSentByUser implements UseCaseInterface<void
|
||||
}
|
||||
const userUuid = userUuidOrError.getValue()
|
||||
|
||||
const sharedVaultUuidOrError = Uuid.create(dto.sharedVaultUuid)
|
||||
if (sharedVaultUuidOrError.isFailed()) {
|
||||
return Result.fail(sharedVaultUuidOrError.getError())
|
||||
let inboundInvites = []
|
||||
if (dto.sharedVaultUuid !== undefined) {
|
||||
const sharedVaultUuidOrError = Uuid.create(dto.sharedVaultUuid)
|
||||
if (sharedVaultUuidOrError.isFailed()) {
|
||||
return Result.fail(sharedVaultUuidOrError.getError())
|
||||
}
|
||||
const sharedVaultUuid = sharedVaultUuidOrError.getValue()
|
||||
|
||||
inboundInvites = await this.sharedVaultInviteRepository.findBySenderUuidAndSharedVaultUuid({
|
||||
senderUuid: userUuid,
|
||||
sharedVaultUuid,
|
||||
})
|
||||
} else {
|
||||
inboundInvites = await this.sharedVaultInviteRepository.findBySenderUuid(userUuid)
|
||||
}
|
||||
const sharedVaultUuid = sharedVaultUuidOrError.getValue()
|
||||
|
||||
const inboundInvites = await this.sharedVaultInviteRepository.findBySenderUuidAndSharedVaultUuid({
|
||||
senderUuid: userUuid,
|
||||
sharedVaultUuid,
|
||||
})
|
||||
for (const invite of inboundInvites) {
|
||||
const result = await this.declineInviteToSharedVault.execute({
|
||||
inviteUuid: invite.id.toString(),
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
export interface DeleteSharedVaultInvitesSentByUserDTO {
|
||||
userUuid: string
|
||||
sharedVaultUuid: string
|
||||
sharedVaultUuid?: string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user