generated from xgeekshq/oss-template
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: send board phase to slack (#1156)
- Loading branch information
1 parent
02a1da9
commit 3d16fb8
Showing
19 changed files
with
263 additions
and
17 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
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
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
15 changes: 15 additions & 0 deletions
15
backend/src/modules/communication/applications/slack-send-message-channel.application.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,15 @@ | ||
import { ChatHandlerInterface } from 'src/modules/communication/interfaces/chat.handler.interface'; | ||
import { SlackMessageDto } from '../dto/slack.message.dto'; | ||
import { SendMessageApplicationInterface } from '../interfaces/SendMessageApplication.interface'; | ||
|
||
export class SlackSendMessageApplication implements SendMessageApplicationInterface { | ||
constructor(private readonly chatHandler: ChatHandlerInterface) {} | ||
|
||
public async execute(data: SlackMessageDto): Promise<void> { | ||
await this.postMessageOnChannel(data); | ||
} | ||
|
||
private async postMessageOnChannel(data: SlackMessageDto): Promise<void> { | ||
this.chatHandler.postMessage(data.slackChannelId, data.message); | ||
} | ||
} |
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
33 changes: 33 additions & 0 deletions
33
backend/src/modules/communication/consumers/slack-send-message.consumer.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,33 @@ | ||
import { Process, Processor } from '@nestjs/bull'; | ||
import { SlackSendMessageProducer } from '../producers/slack-send-message-channel.producer'; | ||
import { SlackMessageType } from 'src/modules/communication/dto/types'; | ||
import { TYPES } from 'src/modules/communication/interfaces/types'; | ||
import { Job } from 'bull'; | ||
import { Inject, Logger } from '@nestjs/common'; | ||
import { SlackCommunicationEventListeners } from './slack-communication-event-listeners'; | ||
import { SendMessageApplicationInterface } from '../interfaces/SendMessageApplication.interface'; | ||
|
||
@Processor(SlackSendMessageProducer.QUEUE_NAME) | ||
export class SlackSendMessageConsumer extends SlackCommunicationEventListeners< | ||
SlackMessageType, | ||
SlackMessageType | ||
> { | ||
constructor( | ||
@Inject(TYPES.application.SlackSendMessageApplication) | ||
private readonly application: SendMessageApplicationInterface | ||
) { | ||
const logger = new Logger(SlackSendMessageProducer.name); | ||
super(logger); | ||
} | ||
|
||
@Process() | ||
override async communication(job: Job<SlackMessageType>) { | ||
const { slackChannelId } = job.data; | ||
|
||
this.logger.verbose( | ||
`execute communication for board with id: "${slackChannelId}" and Job id: "${job.id}" (pid ${process.pid})` | ||
); | ||
|
||
this.application.execute(job.data); | ||
} | ||
} |
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,9 @@ | ||
export class SlackMessageDto { | ||
slackChannelId!: string; | ||
message!: string; | ||
|
||
constructor(slackChannelId: string, message: string) { | ||
this.slackChannelId = slackChannelId; | ||
this.message = message; | ||
} | ||
} |
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
5 changes: 5 additions & 0 deletions
5
backend/src/modules/communication/interfaces/SendMessageApplication.interface.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,5 @@ | ||
import { SlackMessageType } from '../dto/types'; | ||
|
||
export interface SendMessageApplicationInterface { | ||
execute(data: SlackMessageType): Promise<void>; | ||
} |
5 changes: 5 additions & 0 deletions
5
backend/src/modules/communication/interfaces/send-message.service.interface.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,5 @@ | ||
import { SlackMessageType } from '../dto/types'; | ||
|
||
export interface SendMessageServiceInterface { | ||
execute(data: SlackMessageType): Promise<void>; | ||
} |
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.