Skip to content

Commit

Permalink
๐Ÿ‘€ :: chore :: delete slack
Browse files Browse the repository at this point in the history
  • Loading branch information
soyeonkim0227 committed Dec 8, 2023
1 parent 7d3c20f commit ec81067
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 103 deletions.
20 changes: 10 additions & 10 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { RedisModule } from '@liaoliaots/nestjs-redis';
import { UserModule } from './user/user.module';
import { ProfileModule } from './profile/profile.module';
import { ChatModule } from './chat/chat.module';
import { SlackModule } from 'nestjs-slack-webhook';
import slackConfig from './config/slack.config';
// import { SlackModule } from 'nestjs-slack-webhook';
// import slackConfig from './config/slack.config';
import { configDotenv } from 'dotenv';

configDotenv()
Expand All @@ -18,16 +18,16 @@ configDotenv()
envFilePath: `${process.cwd()}/.${process.env.NODE_ENV}.env`,
cache: true, // ์บ์‹ฑ
isGlobal: true, // ์ „์—ญ
load: [slackConfig],
load: [], // slackConfig
}),
SlackModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: async (config: ConfigService) => ({
url: config.get<string>('SLACK'),
// SlackModule.forRootAsync({
// imports: [ConfigModule],
// inject: [ConfigService],
// useFactory: async (config: ConfigService) => ({
// url: config.get<string>('SLACK'),

}),
}),
// }),
// }),
TypeOrmModule.forRoot({
// TypeORM
type: 'mysql',
Expand Down
16 changes: 8 additions & 8 deletions src/config/slack.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { registerAs } from "@nestjs/config";
import { SlackOptions } from "nestjs-slack-webhook";
// import { registerAs } from "@nestjs/config";
// import { SlackOptions } from "nestjs-slack-webhook";

export default registerAs(
'slack',
(): SlackOptions => ({
url: process.env.SLACK,
}),
);
// export default registerAs(
// 'slack',
// (): SlackOptions => ({
// url: process.env.SLACK,
// }),
// );
52 changes: 26 additions & 26 deletions src/user/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,32 +182,32 @@ export class UserController {
})
}

@ApiOperation({
summary: "๋ฌธ์˜ API",
description: "๋ถˆ๋งŒ ์‚ฌํ•ญ / ์—…๋ฐ์ดํŠธ ๊ฑด์˜ / ์˜ค๋ฅ˜ ๋“ฑ ๋ฐœ์ƒ ์‹œ ๋ฌธ์˜ํ•  ์ˆ˜ ์žˆ์Œ"
})
@ApiHeader({ name: "authorization", required: true })
@ApiBody({
type: QuestionDto,
})
@ApiCreatedResponse({
status: 201,
description: "๋ฌธ์˜ ์™„๋ฃŒ"
})
@ApiNotFoundResponse({
status: 404,
description: "์ฐพ์„ ์ˆ˜ ์—†๋Š” ์‚ฌ์šฉ์ž"
})
@Post('question')
async question(@Headers('authorization') accesstoken: string, @Body() questionDto: QuestionDto): Promise<object>{
const data = await this.userService.question(accesstoken, questionDto);

return Object.assign({
data,
statusCode: 201,
statusMsg: "๋ฌธ์˜๊ฐ€ ์™„๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค."
})
}
// @ApiOperation({
// summary: "๋ฌธ์˜ API",
// description: "๋ถˆ๋งŒ ์‚ฌํ•ญ / ์—…๋ฐ์ดํŠธ ๊ฑด์˜ / ์˜ค๋ฅ˜ ๋“ฑ ๋ฐœ์ƒ ์‹œ ๋ฌธ์˜ํ•  ์ˆ˜ ์žˆ์Œ"
// })
// @ApiHeader({ name: "authorization", required: true })
// @ApiBody({
// type: QuestionDto,
// })
// @ApiCreatedResponse({
// status: 201,
// description: "๋ฌธ์˜ ์™„๋ฃŒ"
// })
// @ApiNotFoundResponse({
// status: 404,
// description: "์ฐพ์„ ์ˆ˜ ์—†๋Š” ์‚ฌ์šฉ์ž"
// })
// @Post('question')
// async question(@Headers('authorization') accesstoken: string, @Body() questionDto: QuestionDto): Promise<object>{
// const data = await this.userService.question(accesstoken, questionDto);

// return Object.assign({
// data,
// statusCode: 201,
// statusMsg: "๋ฌธ์˜๊ฐ€ ์™„๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค."
// })
// }

@ApiOperation({
summary: "๋ฆฌํ”„๋ ˆ์‹œ ํ† ํฐ ๊ฒ€์ฆ",
Expand Down
118 changes: 59 additions & 59 deletions src/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,63 +271,63 @@ export class UserService {
*
* ๋ฌธ์˜ํ•˜๊ธฐ
*/
async question(accesstoken: string, question: QuestionDto): Promise<object> {
const webhook = new IncomingWebhook(process.env.SLACK); // ์›นํ›… ์ƒ์„ฑ

const { userID } = await this.validateAccess(accesstoken); // ์•ก์„ธ์Šค ํ† ํฐ ๊ฒ€์ฆ

const thisUser = await this.userEntity.findOneBy({ userID }); // ์œ ์ € ์ฐพ๊ธฐ

if (!thisUser) throw new NotFoundException(); // ์—†์œผ๋ฉด NotFoundException

const thisQuestion = await this.questionEntity.save({
userID,
user: thisUser,
title: question.title,
content: question.content
})

const payload = {
"attachments": [
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": question.title
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": question.content
},
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": `*date*:${Date.now().toString()}\n*userID*: ${userID}\n*userName*: ${thisUser.name}\n*userEmail*: ${thisUser.email}`
}
},
{
"type": "divider"
}
]
}
]
}

await webhook.send(payload);

return thisQuestion;
}
// async question(accesstoken: string, question: QuestionDto): Promise<object> {
// const webhook = new IncomingWebhook(process.env.SLACK); // ์›นํ›… ์ƒ์„ฑ

// const { userID } = await this.validateAccess(accesstoken); // ์•ก์„ธ์Šค ํ† ํฐ ๊ฒ€์ฆ

// const thisUser = await this.userEntity.findOneBy({ userID }); // ์œ ์ € ์ฐพ๊ธฐ

// if (!thisUser) throw new NotFoundException(); // ์—†์œผ๋ฉด NotFoundException

// const thisQuestion = await this.questionEntity.save({
// userID,
// user: thisUser,
// title: question.title,
// content: question.content
// })

// const payload = {
// "attachments": [
// {
// "blocks": [
// {
// "type": "header",
// "text": {
// "type": "plain_text",
// "text": question.title
// }
// },
// {
// "type": "divider"
// },
// {
// "type": "section",
// "text": {
// "type": "mrkdwn",
// "text": question.content
// },
// },
// {
// "type": "divider"
// },
// {
// "type": "section",
// "text": {
// "type": "mrkdwn",
// "text": `*date*:${Date.now().toString()}\n*userID*: ${userID}\n*userName*: ${thisUser.name}\n*userEmail*: ${thisUser.email}`
// }
// },
// {
// "type": "divider"
// }
// ]
// }
// ]
// }

// await webhook.send(payload);

// return thisQuestion;
// }
}

0 comments on commit ec81067

Please sign in to comment.