4002 prevent user from creating twice the same blocklist item (#5213)

Closes #4002
This commit is contained in:
bosiraphael
2024-04-30 14:36:33 +02:00
committed by GitHub
parent 3a61c922f1
commit 7c605fc2f9
12 changed files with 297 additions and 53 deletions

View File

@ -50,4 +50,21 @@ export class BlocklistRepository {
transactionManager,
);
}
public async getByWorkspaceMemberIdAndHandle(
workspaceMemberId: string,
handle: string,
workspaceId: string,
transactionManager?: EntityManager,
): Promise<ObjectRecord<BlocklistObjectMetadata>[]> {
const dataSourceSchema =
this.workspaceDataSourceService.getSchemaName(workspaceId);
return await this.workspaceDataSourceService.executeRawQuery(
`SELECT * FROM ${dataSourceSchema}."blocklist" WHERE "workspaceMemberId" = $1 AND "handle" = $2`,
[workspaceMemberId, handle],
workspaceId,
transactionManager,
);
}
}