Files
standardnotes-server/packages/syncing-server/src/Domain/UseCase/Sharing/GetUserItemSharesUseCase.ts
T
2023-05-12 10:28:18 -05:00

34 lines
897 B
TypeScript

import { ItemShare } from '../../ItemShare/Model/ItemShare'
import { ItemShareServiceInterface } from '../../ItemShare/Service/ItemShareServiceInterface'
import { UseCaseInterface } from '../UseCaseInterface'
export type GetUserItemSharesResponse =
| {
success: true
itemShares: ItemShare[]
}
| {
success: false
message: string
}
export class GetUserItemSharesUseCase implements UseCaseInterface {
constructor(private itemShareService: ItemShareServiceInterface) {}
async execute(dto: { userUuid: string }): Promise<GetUserItemSharesResponse> {
const result = await this.itemShareService.getUserItemShares(dto.userUuid)
if (result === null) {
return {
success: false,
message: `Could not get user item shares for user ${dto.userUuid}`,
}
}
return {
success: true,
itemShares: result,
}
}
}