4746 create created listener on blocklist (#5031)
Closes #4746 for messaging. I will create another PR to implement the listener on calendar.
This commit is contained in:
@ -67,6 +67,40 @@ export class MessageChannelMessageAssociationRepository {
|
||||
);
|
||||
}
|
||||
|
||||
public async deleteByMessageParticipantHandleAndMessageChannelIds(
|
||||
messageParticipantHandle: string,
|
||||
messageChannelIds: string[],
|
||||
workspaceId: string,
|
||||
transactionManager?: EntityManager,
|
||||
) {
|
||||
const dataSourceSchema =
|
||||
this.workspaceDataSourceService.getSchemaName(workspaceId);
|
||||
|
||||
const messageChannelMessageAssociationIdsToDelete =
|
||||
await this.workspaceDataSourceService.executeRawQuery(
|
||||
`SELECT "messageChannelMessageAssociation".id
|
||||
FROM ${dataSourceSchema}."messageChannelMessageAssociation" "messageChannelMessageAssociation"
|
||||
JOIN ${dataSourceSchema}."message" ON "messageChannelMessageAssociation"."messageId" = ${dataSourceSchema}."message"."id"
|
||||
JOIN ${dataSourceSchema}."messageParticipant" "messageParticipant" ON ${dataSourceSchema}."message"."id" = "messageParticipant"."messageId"
|
||||
WHERE "messageParticipant"."handle" = $1 AND "messageParticipant"."role"= ANY($2) AND "messageChannelMessageAssociation"."messageChannelId" = ANY($3)`,
|
||||
[messageParticipantHandle, ['from', 'to'], messageChannelIds],
|
||||
workspaceId,
|
||||
transactionManager,
|
||||
);
|
||||
|
||||
const messageChannelMessageAssociationIdsToDeleteArray =
|
||||
messageChannelMessageAssociationIdsToDelete.map(
|
||||
(messageChannelMessageAssociation: { id: string }) =>
|
||||
messageChannelMessageAssociation.id,
|
||||
);
|
||||
|
||||
await this.deleteByIds(
|
||||
messageChannelMessageAssociationIdsToDeleteArray,
|
||||
workspaceId,
|
||||
transactionManager,
|
||||
);
|
||||
}
|
||||
|
||||
public async getByMessageChannelIds(
|
||||
messageChannelIds: string[],
|
||||
workspaceId: string,
|
||||
|
||||
@ -137,6 +137,27 @@ export class MessageChannelRepository {
|
||||
);
|
||||
}
|
||||
|
||||
public async getIdsByWorkspaceMemberId(
|
||||
workspaceMemberId: string,
|
||||
workspaceId: string,
|
||||
transactionManager?: EntityManager,
|
||||
): Promise<ObjectRecord<MessageChannelObjectMetadata>[]> {
|
||||
const dataSourceSchema =
|
||||
this.workspaceDataSourceService.getSchemaName(workspaceId);
|
||||
|
||||
const messageChannelIds =
|
||||
await this.workspaceDataSourceService.executeRawQuery(
|
||||
`SELECT "messageChannel".id FROM ${dataSourceSchema}."messageChannel" "messageChannel"
|
||||
JOIN ${dataSourceSchema}."connectedAccount" ON "messageChannel"."connectedAccountId" = ${dataSourceSchema}."connectedAccount"."id"
|
||||
WHERE ${dataSourceSchema}."connectedAccount"."accountOwnerId" = $1`,
|
||||
[workspaceMemberId],
|
||||
workspaceId,
|
||||
transactionManager,
|
||||
);
|
||||
|
||||
return messageChannelIds;
|
||||
}
|
||||
|
||||
public async updateSyncStatus(
|
||||
id: string,
|
||||
syncStatus: MessageChannelSyncStatus,
|
||||
|
||||
Reference in New Issue
Block a user