diff --git a/packages/feedback-service/package-lock.json b/packages/feedback-service/package-lock.json index 46c1c2aae..577d34d9f 100644 --- a/packages/feedback-service/package-lock.json +++ b/packages/feedback-service/package-lock.json @@ -21,13 +21,13 @@ "clean-webpack-plugin": "4.0.0", "cookie-parser": "1.4.5", "cors": "2.8.5", - "dotenv": "10.0.0", "dotenv-safe": "8.2.0", "ejs": "3.1.6", "errorhandler": "1.5.1", "express": "4.17.1", "graphql": "16.0.1", "https-proxy-agent": "^5.0.0", + "ioredis": "^5.3.2", "lodash": "4.17.21", "method-override": "3.0.0", "mongoose": "5.13.9", @@ -3718,14 +3718,6 @@ "node": ">=8" } }, - "node_modules/dotenv": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", - "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", - "engines": { - "node": ">=10" - } - }, "node_modules/dotenv-safe": { "version": "8.2.0", "resolved": "https://registry.npmjs.org/dotenv-safe/-/dotenv-safe-8.2.0.tgz", @@ -12377,11 +12369,6 @@ } } }, - "dotenv": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", - "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==" - }, "dotenv-safe": { "version": "8.2.0", "resolved": "https://registry.npmjs.org/dotenv-safe/-/dotenv-safe-8.2.0.tgz", diff --git a/packages/feedback-service/package.json b/packages/feedback-service/package.json index a1efd3bcb..c0f8fe171 100644 --- a/packages/feedback-service/package.json +++ b/packages/feedback-service/package.json @@ -57,13 +57,13 @@ "clean-webpack-plugin": "4.0.0", "cookie-parser": "1.4.5", "cors": "2.8.5", - "dotenv": "10.0.0", "dotenv-safe": "8.2.0", "ejs": "3.1.6", "errorhandler": "1.5.1", "express": "4.17.1", "graphql": "16.0.1", "https-proxy-agent": "^5.0.0", + "ioredis": "^5.3.2", "lodash": "4.17.21", "method-override": "3.0.0", "mongoose": "5.13.9", diff --git a/packages/feedback-service/src/helpers.ts b/packages/feedback-service/src/helpers.ts index 656b9fb1d..99503a05b 100644 --- a/packages/feedback-service/src/helpers.ts +++ b/packages/feedback-service/src/helpers.ts @@ -319,23 +319,27 @@ async function manageSearchIndex(data: any, mode: string) { function createEmailTemplate( userInfo: any, feedback: FeedbackType, - app: App, + projectId: string, config: FeedbackConfigType, ) { + const appName = projectId.split( '/' )[ 1 ] ?? projectId; + const emailBody = ` Hi ${userInfo[0].cn},

-We have received the ${feedback.category.toLowerCase()} for the ${ - app.name -}

+We have received the ${feedback.category.toLowerCase()} for the ${appName}

Summary: ${feedback.summary}

URL: ${new URL(process.env.FEEDBACK_CLIENT as string).origin}${ - (feedback.stackInfo as any)?.path -}

+ (feedback.stackInfo as any)?.path + }

-${ feedback.ticketUrl ? `A ticket has opened for the reported ${feedback.category.toLowerCase()} and you can track the progress at ${ +${ feedback.ticketUrl -}

` : ''} + ? `A ticket has opened for the reported ${feedback.category.toLowerCase()} and you can track the progress at ${ + feedback.ticketUrl + }

` + : '' +} Thanks

P.S.: This is an automated email. Please do not reply. @@ -347,7 +351,7 @@ P.S.: This is an automated email. Please do not reply. to: userInfo[0].mail, subject: `${feedback.error ? feedback.error : feedback.experience} - ${ feedback.category.charAt(0) + feedback.category.substring(1).toLowerCase() - } reported for ${app.name}.`, + } reported for ${appName}.`, body: emailBody, }; return emailData; diff --git a/packages/feedback-service/src/jobs/createGithubIssue.ts b/packages/feedback-service/src/jobs/createGithubIssue.ts index 70c875698..ebf2dc9e5 100644 --- a/packages/feedback-service/src/jobs/createGithubIssue.ts +++ b/packages/feedback-service/src/jobs/createGithubIssue.ts @@ -1,9 +1,9 @@ import {Worker} from 'bullmq'; -import {redisConfiguration} from '../lib/queue'; import {WorkerProps} from '.'; import {processIntegrationInput} from '../helpers'; import axios from 'axios'; import logger from '../lib/logger'; +import { redisConnection } from '../lib/redis'; export const GITHUB_JOB_NAME = 'createGithubIssue'; export const createGithubIssue = new Worker( @@ -59,5 +59,7 @@ export const createGithubIssue = new Worker( }); return githubResponse; }, - redisConfiguration + { + connection: redisConnection, + } ); diff --git a/packages/feedback-service/src/jobs/createGitlabIssue.ts b/packages/feedback-service/src/jobs/createGitlabIssue.ts index fa2ebb583..47cedb3ba 100644 --- a/packages/feedback-service/src/jobs/createGitlabIssue.ts +++ b/packages/feedback-service/src/jobs/createGitlabIssue.ts @@ -1,9 +1,9 @@ import {Worker} from 'bullmq'; -import {redisConfiguration} from '../lib/queue'; import {processIntegrationInput} from '../helpers'; import {WorkerProps} from '.'; import axios from 'axios'; import logger from '../lib/logger'; +import { redisConnection } from '../lib/redis'; export const GITLAB_JOB_NAME = 'createGitlabIssue'; export const createGitlabIssue = new Worker( @@ -61,5 +61,7 @@ export const createGitlabIssue = new Worker( }); return gitlabResponse; }, - redisConfiguration + { + connection: redisConnection, + } ); diff --git a/packages/feedback-service/src/jobs/createJira.ts b/packages/feedback-service/src/jobs/createJira.ts index f9cf1b981..435c67963 100644 --- a/packages/feedback-service/src/jobs/createJira.ts +++ b/packages/feedback-service/src/jobs/createJira.ts @@ -1,5 +1,5 @@ import {Worker} from 'bullmq'; -import {redisConfiguration} from '../lib/queue'; +import {redisConnection} from '../lib/redis'; import {processIntegrationInput, proxyAgent} from '../helpers'; import axios from 'axios'; import {WorkerProps} from '.'; @@ -58,7 +58,9 @@ export const createJira = new Worker( throw err; } }, - redisConfiguration + { + connection: redisConnection, + } ); createJira.on('active', (job) => { diff --git a/packages/feedback-service/src/lib/queue.ts b/packages/feedback-service/src/lib/queue.ts index a4163c699..e1c3df6c2 100644 --- a/packages/feedback-service/src/lib/queue.ts +++ b/packages/feedback-service/src/lib/queue.ts @@ -1,15 +1,9 @@ -import { Queue, QueueOptions } from 'bullmq'; +import { Queue } from 'bullmq'; import { JIRA_JOB_NAME } from '../jobs/createJira'; import { GITLAB_JOB_NAME } from '../jobs/createGitlabIssue'; import { GITHUB_JOB_NAME } from '../jobs/createGithubIssue'; +import { redisConnection } from './redis'; -export const redisConfiguration: QueueOptions = { - connection: { - host: process.env.REDIS_HOST, - port: Number.parseInt(process.env.REDIS_PORT ?? '6379'), - } -} - -export const jiraQueue = new Queue(JIRA_JOB_NAME, redisConfiguration); -export const gitlabQueue = new Queue(GITLAB_JOB_NAME, redisConfiguration); -export const githubQueue = new Queue(GITHUB_JOB_NAME, redisConfiguration); +export const jiraQueue = new Queue(JIRA_JOB_NAME, { connection: redisConnection }); +export const gitlabQueue = new Queue(GITLAB_JOB_NAME, { connection: redisConnection }); +export const githubQueue = new Queue(GITHUB_JOB_NAME, { connection: redisConnection }); diff --git a/packages/feedback-service/src/lib/redis.ts b/packages/feedback-service/src/lib/redis.ts new file mode 100644 index 000000000..b3fde4fe7 --- /dev/null +++ b/packages/feedback-service/src/lib/redis.ts @@ -0,0 +1,8 @@ +require('events').defaultMaxListeners = 70; +import {Redis} from 'ioredis'; + +export const redisConnection = new Redis({ + host: process.env.REDIS_HOST, + port: Number.parseInt(process.env.REDIS_PORT ?? '6379'), + maxRetriesPerRequest: null, +});