-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
5629 update blocklist for messaging v2 #5756
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
3ccb098
remove old logic
bosiraphael f8176be
reset FULL_MESSAGES_LIST_FETCH_PENDING
bosiraphael e45c863
Merge branch 'main' into 5629-update-blocklist-for-messaging-v2
bosiraphael 80aa19c
blocklist is working
bosiraphael 5fc783a
add subdomainsdeletion for blocklist
bosiraphael fa301b9
update deleted event
bosiraphael 3114e6d
update updated listener
bosiraphael faf07f4
Merge branch '5629-update-blocklist-for-messaging-v2' of github.com:t…
bosiraphael 554987a
update isEmailBlocklisted.util
bosiraphael 0ab8d95
update tests
bosiraphael 9bde162
Merge branch 'main' into 5629-update-blocklist-for-messaging-v2
bosiraphael 5542ca6
import emails from channel even if domain is blocklisted
bosiraphael 142d958
add test
bosiraphael bd14add
modify deleteByMessageParticipantHandleAndMessageChannelIdsAndRoles
bosiraphael b450aea
line break
bosiraphael c64cd80
seems to work
bosiraphael File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 5 additions & 2 deletions
7
...enty-server/src/modules/calendar-messaging-participant/utils/is-email-blocklisted.util.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 0 additions & 58 deletions
58
...src/modules/messaging/blocklist-manager/jobs/messaging-blocklist-reimport-messages.job.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,21 +6,28 @@ import { ObjectRecordDeleteEvent } from 'src/engine/integrations/event-emitter/t | |
import { MessageQueue } from 'src/engine/integrations/message-queue/message-queue.constants'; | ||
import { MessageQueueService } from 'src/engine/integrations/message-queue/services/message-queue.service'; | ||
import { BlocklistWorkspaceEntity } from 'src/modules/connected-account/standard-objects/blocklist.workspace-entity'; | ||
import { | ||
BlocklistReimportMessagesJob, | ||
BlocklistReimportMessagesJobData, | ||
} from 'src/modules/messaging/blocklist-manager/jobs/messaging-blocklist-reimport-messages.job'; | ||
import { | ||
BlocklistItemDeleteMessagesJobData, | ||
BlocklistItemDeleteMessagesJob, | ||
} from 'src/modules/messaging/blocklist-manager/jobs/messaging-blocklist-item-delete-messages.job'; | ||
import { ObjectRecordUpdateEvent } from 'src/engine/integrations/event-emitter/types/object-record-update.event'; | ||
import { InjectObjectMetadataRepository } from 'src/engine/object-metadata-repository/object-metadata-repository.decorator'; | ||
import { ConnectedAccountRepository } from 'src/modules/connected-account/repositories/connected-account.repository'; | ||
import { ConnectedAccountWorkspaceEntity } from 'src/modules/connected-account/standard-objects/connected-account.workspace-entity'; | ||
import { MessageChannelRepository } from 'src/modules/messaging/common/repositories/message-channel.repository'; | ||
import { MessagingChannelSyncStatusService } from 'src/modules/messaging/common/services/messaging-channel-sync-status.service'; | ||
import { MessageChannelWorkspaceEntity } from 'src/modules/messaging/common/standard-objects/message-channel.workspace-entity'; | ||
|
||
@Injectable() | ||
export class MessagingBlocklistListener { | ||
constructor( | ||
@Inject(MessageQueue.messagingQueue) | ||
private readonly messageQueueService: MessageQueueService, | ||
@InjectObjectMetadataRepository(ConnectedAccountWorkspaceEntity) | ||
private readonly connectedAccountRepository: ConnectedAccountRepository, | ||
private readonly messagingChannelSyncStatusService: MessagingChannelSyncStatusService, | ||
@InjectObjectMetadataRepository(MessageChannelWorkspaceEntity) | ||
private readonly messageChannelRepository: MessageChannelRepository, | ||
) {} | ||
|
||
@OnEvent('blocklist.created') | ||
|
@@ -40,35 +47,65 @@ export class MessagingBlocklistListener { | |
async handleDeletedEvent( | ||
payload: ObjectRecordDeleteEvent<BlocklistWorkspaceEntity>, | ||
) { | ||
await this.messageQueueService.add<BlocklistReimportMessagesJobData>( | ||
BlocklistReimportMessagesJob.name, | ||
{ | ||
workspaceId: payload.workspaceId, | ||
workspaceMemberId: payload.properties.before.workspaceMember.id, | ||
handle: payload.properties.before.handle, | ||
}, | ||
const workspaceMemberId = payload.properties.before.workspaceMember.id; | ||
const workspaceId = payload.workspaceId; | ||
|
||
const connectedAccount = | ||
await this.connectedAccountRepository.getAllByWorkspaceMemberId( | ||
workspaceMemberId, | ||
workspaceId, | ||
); | ||
|
||
if (!connectedAccount || connectedAccount.length === 0) { | ||
return; | ||
} | ||
|
||
const messageChannel = | ||
await this.messageChannelRepository.getByConnectedAccountId( | ||
connectedAccount[0].id, | ||
workspaceId, | ||
); | ||
|
||
await this.messagingChannelSyncStatusService.resetAndScheduleFullMessageListFetch( | ||
messageChannel[0].id, | ||
workspaceId, | ||
); | ||
} | ||
|
||
@OnEvent('blocklist.updated') | ||
async handleUpdatedEvent( | ||
payload: ObjectRecordUpdateEvent<BlocklistWorkspaceEntity>, | ||
) { | ||
const workspaceMemberId = payload.properties.before.workspaceMember.id; | ||
const workspaceId = payload.workspaceId; | ||
|
||
await this.messageQueueService.add<BlocklistItemDeleteMessagesJobData>( | ||
BlocklistItemDeleteMessagesJob.name, | ||
{ | ||
workspaceId: payload.workspaceId, | ||
workspaceId, | ||
blocklistItemId: payload.recordId, | ||
}, | ||
); | ||
|
||
await this.messageQueueService.add<BlocklistReimportMessagesJobData>( | ||
BlocklistReimportMessagesJob.name, | ||
{ | ||
workspaceId: payload.workspaceId, | ||
workspaceMemberId: payload.properties.after.workspaceMember.id, | ||
handle: payload.properties.before.handle, | ||
}, | ||
const connectedAccount = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looks like duplicated code here |
||
await this.connectedAccountRepository.getAllByWorkspaceMemberId( | ||
workspaceMemberId, | ||
workspaceId, | ||
); | ||
|
||
if (!connectedAccount || connectedAccount.length === 0) { | ||
return; | ||
} | ||
|
||
const messageChannel = | ||
await this.messageChannelRepository.getByConnectedAccountId( | ||
connectedAccount[0].id, | ||
workspaceId, | ||
); | ||
|
||
await this.messagingChannelSyncStatusService.resetAndScheduleFullMessageListFetch( | ||
messageChannel[0].id, | ||
workspaceId, | ||
); | ||
} | ||
} |
15 changes: 13 additions & 2 deletions
15
...enty-server/src/modules/messaging/blocklist-manager/messaging-blocklist-manager.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,19 @@ | ||
import { Module } from '@nestjs/common'; | ||
|
||
import { BlocklistItemDeleteMessagesJob } from 'src/modules/messaging/blocklist-manager/jobs/messaging-blocklist-item-delete-messages.job'; | ||
import { MessagingBlocklistListener } from 'src/modules/messaging/blocklist-manager/listeners/messaging-blocklist.listener'; | ||
import { MessagingCommonModule } from 'src/modules/messaging/common/messaging-common.module'; | ||
import { MessagingMessageCleanerModule } from 'src/modules/messaging/message-cleaner/messaging-message-cleaner.module'; | ||
|
||
@Module({ | ||
imports: [], | ||
providers: [], | ||
imports: [MessagingCommonModule, MessagingMessageCleanerModule], | ||
providers: [ | ||
MessagingBlocklistListener, | ||
{ | ||
provide: BlocklistItemDeleteMessagesJob.name, | ||
useClass: BlocklistItemDeleteMessagesJob, | ||
}, | ||
], | ||
exports: [], | ||
}) | ||
export class MessagingBlocklistManagerModule {} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it feels wrong that getAll is returning only one connectedAccount but we will change this once we have the ORM