forked from twentyhq/twenty
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
5951 create a command to trigger the import of a single message (twen…
…tyhq#5962) Closes twentyhq#5951 --------- Co-authored-by: Charles Bochet <charles@twenty.com>
- Loading branch information
1 parent
f370128
commit a001bf1
Showing
6 changed files
with
224 additions
and
106 deletions.
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
69 changes: 69 additions & 0 deletions
69
...ules/messaging/message-import-manager/commands/messaging-single-message-import.command.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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { Command, CommandRunner, Option } from 'nest-commander'; | ||
|
||
import { InjectMessageQueue } from 'src/engine/integrations/message-queue/decorators/message-queue.decorator'; | ||
import { MessageQueue } from 'src/engine/integrations/message-queue/message-queue.constants'; | ||
import { MessageQueueService } from 'src/engine/integrations/message-queue/services/message-queue.service'; | ||
import { | ||
MessagingAddSingleMessageToCacheForImportJob, | ||
MessagingAddSingleMessageToCacheForImportJobData, | ||
} from 'src/modules/messaging/message-import-manager/jobs/messaging-add-single-message-to-cache-for-import.job'; | ||
|
||
type MessagingSingleMessageImportCommandOptions = { | ||
messageExternalId: string; | ||
messageChannelId: string; | ||
workspaceId: string; | ||
}; | ||
|
||
@Command({ | ||
name: 'messaging:single-message-import', | ||
description: 'Enqueue a job to schedule the import of a single message', | ||
}) | ||
export class MessagingSingleMessageImportCommand extends CommandRunner { | ||
constructor( | ||
@InjectMessageQueue(MessageQueue.messagingQueue) | ||
private readonly messageQueueService: MessageQueueService, | ||
) { | ||
super(); | ||
} | ||
|
||
async run( | ||
_passedParam: string[], | ||
options: MessagingSingleMessageImportCommandOptions, | ||
): Promise<void> { | ||
await this.messageQueueService.add<MessagingAddSingleMessageToCacheForImportJobData>( | ||
MessagingAddSingleMessageToCacheForImportJob.name, | ||
{ | ||
messageExternalId: options.messageExternalId, | ||
messageChannelId: options.messageChannelId, | ||
workspaceId: options.workspaceId, | ||
}, | ||
); | ||
} | ||
|
||
@Option({ | ||
flags: '-m, --message-external-id [message_external_id]', | ||
description: 'Message external ID', | ||
required: true, | ||
}) | ||
parseMessageId(value: string): string { | ||
return value; | ||
} | ||
|
||
@Option({ | ||
flags: '-M, --message-channel-id [message_channel_id]', | ||
description: 'Message channel ID', | ||
required: true, | ||
}) | ||
parseMessageChannelId(value: string): string { | ||
return value; | ||
} | ||
|
||
@Option({ | ||
flags: '-w, --workspace-id [workspace_id]', | ||
description: 'Workspace ID', | ||
required: true, | ||
}) | ||
parseWorkspaceId(value: string): string { | ||
return value; | ||
} | ||
} |
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
Oops, something went wrong.