mirror of
https://github.com/standardnotes/server
synced 2026-07-14 00:01:54 -04:00
26 lines
972 B
TypeScript
26 lines
972 B
TypeScript
import { inject, injectable } from 'inversify'
|
|
import TYPES from '../../../Bootstrap/Types'
|
|
import { AnalyticsEntityRepositoryInterface } from '../../Entity/AnalyticsEntityRepositoryInterface'
|
|
import { UseCaseInterface } from '../UseCaseInterface'
|
|
import { GetUserAnalyticsIdDTO } from './GetUserAnalyticsIdDTO'
|
|
import { GetUserAnalyticsIdResponse } from './GetUserAnalyticsIdResponse'
|
|
|
|
@injectable()
|
|
export class GetUserAnalyticsId implements UseCaseInterface {
|
|
constructor(
|
|
@inject(TYPES.AnalyticsEntityRepository) private analyticsEntityRepository: AnalyticsEntityRepositoryInterface,
|
|
) {}
|
|
|
|
async execute(dto: GetUserAnalyticsIdDTO): Promise<GetUserAnalyticsIdResponse> {
|
|
const analyticsEntity = await this.analyticsEntityRepository.findOneByUserUuid(dto.userUuid)
|
|
|
|
if (analyticsEntity === null) {
|
|
throw new Error(`Could not find analytics entity for user ${dto.userUuid}`)
|
|
}
|
|
|
|
return {
|
|
analyticsId: analyticsEntity.id,
|
|
}
|
|
}
|
|
}
|