feat(syncing-server): add deleting outbound messages

Co-authored-by: Mo <[email protected]>
This commit is contained in:
Karol Sójko
2023-07-27 08:06:56 +02:00
co-authored by Mo
parent c79a5dc94b
commit e8ba49ecca
9 changed files with 70 additions and 9 deletions
@@ -38,6 +38,10 @@ export class HomeServerSharedVaultInvitesController extends BaseHttpController {
'sync.shared-vault-invites.delete-inbound',
this.deleteInboundUserInvites.bind(this),
)
this.controllerContainer.register(
'sync.shared-vault-invites.delete-outbound',
this.deleteOutboundUserInvites.bind(this),
)
this.controllerContainer.register(
'sync.shared-vault-invites.get-outbound',
this.getOutboundUserInvites.bind(this),
@@ -172,6 +176,27 @@ export class HomeServerSharedVaultInvitesController extends BaseHttpController {
})
}
async deleteOutboundUserInvites(_request: Request, response: Response): Promise<results.JsonResult> {
const result = await this.deleteSharedVaultInvitesSentByUserUseCase.execute({
userUuid: response.locals.user.uuid,
})
if (result.isFailed()) {
return this.json(
{
error: {
message: result.getError(),
},
},
HttpStatusCode.BadRequest,
)
}
return this.json({
success: true,
})
}
async getOutboundUserInvites(_request: Request, response: Response): Promise<results.JsonResult> {
const result = await this.getSharedVaultInvitesSentByUserUseCase.execute({
senderUuid: response.locals.user.uuid,
@@ -72,6 +72,11 @@ export class InversifyExpressSharedVaultInvitesController extends HomeServerShar
return super.deleteInboundUserInvites(request, response)
}
@httpDelete('/invites/outbound')
override async deleteOutboundUserInvites(request: Request, response: Response): Promise<results.JsonResult> {
return super.deleteOutboundUserInvites(request, response)
}
@httpGet('/invites/outbound')
override async getOutboundUserInvites(request: Request, response: Response): Promise<results.JsonResult> {
return super.getOutboundUserInvites(request, response)