mirror of
https://github.com/standardnotes/server
synced 2026-07-14 00:01:54 -04:00
feat: add auth server package
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import { inject, injectable } from 'inversify'
|
||||
import { Repository } from 'typeorm'
|
||||
import TYPES from '../../Bootstrap/Types'
|
||||
|
||||
import { InvitationStatus } from '../../Domain/SharedSubscription/InvitationStatus'
|
||||
import { SharedSubscriptionInvitation } from '../../Domain/SharedSubscription/SharedSubscriptionInvitation'
|
||||
import { SharedSubscriptionInvitationRepositoryInterface } from '../../Domain/SharedSubscription/SharedSubscriptionInvitationRepositoryInterface'
|
||||
|
||||
@injectable()
|
||||
export class MySQLSharedSubscriptionInvitationRepository implements SharedSubscriptionInvitationRepositoryInterface {
|
||||
constructor(
|
||||
@inject(TYPES.ORMSharedSubscriptionInvitationRepository)
|
||||
private ormRepository: Repository<SharedSubscriptionInvitation>,
|
||||
) {}
|
||||
|
||||
async save(sharedSubscriptionInvitation: SharedSubscriptionInvitation): Promise<SharedSubscriptionInvitation> {
|
||||
return this.ormRepository.save(sharedSubscriptionInvitation)
|
||||
}
|
||||
|
||||
async findByInviterEmail(inviterEmail: string): Promise<SharedSubscriptionInvitation[]> {
|
||||
return this.ormRepository
|
||||
.createQueryBuilder('invitation')
|
||||
.where('invitation.inviter_identifier = :inviterEmail', {
|
||||
inviterEmail,
|
||||
})
|
||||
.getMany()
|
||||
}
|
||||
|
||||
async countByInviterEmailAndStatus(inviterEmail: string, statuses: InvitationStatus[]): Promise<number> {
|
||||
return this.ormRepository
|
||||
.createQueryBuilder('invitation')
|
||||
.where('invitation.inviter_identifier = :inviterEmail AND invitation.status IN (:...statuses)', {
|
||||
inviterEmail,
|
||||
statuses,
|
||||
})
|
||||
.getCount()
|
||||
}
|
||||
|
||||
async findOneByUuid(uuid: string): Promise<SharedSubscriptionInvitation | null> {
|
||||
return this.ormRepository
|
||||
.createQueryBuilder('invitation')
|
||||
.where('invitation.uuid = :uuid', {
|
||||
uuid,
|
||||
})
|
||||
.getOne()
|
||||
}
|
||||
|
||||
async findOneByUuidAndStatus(uuid: string, status: InvitationStatus): Promise<SharedSubscriptionInvitation | null> {
|
||||
return this.ormRepository
|
||||
.createQueryBuilder('invitation')
|
||||
.where('invitation.uuid = :uuid AND invitation.status = :status', {
|
||||
uuid,
|
||||
status,
|
||||
})
|
||||
.getOne()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user