Skip to content

Commit

Permalink
hotfix(feedback): email subject fix (#1740)
Browse files Browse the repository at this point in the history
  • Loading branch information
deshmukhmayur authored Sep 1, 2023
2 parents 04c106f + 95c80c3 commit c32a58d
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 41 deletions.
15 changes: 1 addition & 14 deletions packages/feedback-service/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/feedback-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
22 changes: 13 additions & 9 deletions packages/feedback-service/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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},<br/><br/>
We have received the ${feedback.category.toLowerCase()} for the ${
app.name
}<br/><br/>
We have received the ${feedback.category.toLowerCase()} for the ${appName}<br/><br/>
Summary: ${feedback.summary}<br/><br/>
URL: ${new URL(process.env.FEEDBACK_CLIENT as string).origin}${
(feedback.stackInfo as any)?.path
}<br/><br/>
(feedback.stackInfo as any)?.path
}<br/><br/>
${ feedback.ticketUrl ? `A ticket has opened for the reported ${feedback.category.toLowerCase()} and you can track the progress at ${
${
feedback.ticketUrl
}<br/><br/>` : ''}
? `A ticket has opened for the reported ${feedback.category.toLowerCase()} and you can track the progress at ${
feedback.ticketUrl
}<br/><br/>`
: ''
}
Thanks<br/><br/>
P.S.: This is an automated email. Please do not reply.
Expand All @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions packages/feedback-service/src/jobs/createGithubIssue.ts
Original file line number Diff line number Diff line change
@@ -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<WorkerProps>(
Expand Down Expand Up @@ -59,5 +59,7 @@ export const createGithubIssue = new Worker<WorkerProps>(
});
return githubResponse;
},
redisConfiguration
{
connection: redisConnection,
}
);
6 changes: 4 additions & 2 deletions packages/feedback-service/src/jobs/createGitlabIssue.ts
Original file line number Diff line number Diff line change
@@ -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<WorkerProps>(
Expand Down Expand Up @@ -61,5 +61,7 @@ export const createGitlabIssue = new Worker<WorkerProps>(
});
return gitlabResponse;
},
redisConfiguration
{
connection: redisConnection,
}
);
6 changes: 4 additions & 2 deletions packages/feedback-service/src/jobs/createJira.ts
Original file line number Diff line number Diff line change
@@ -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 '.';
Expand Down Expand Up @@ -58,7 +58,9 @@ export const createJira = new Worker<WorkerProps>(
throw err;
}
},
redisConfiguration
{
connection: redisConnection,
}
);

createJira.on('active', (job) => {
Expand Down
16 changes: 5 additions & 11 deletions packages/feedback-service/src/lib/queue.ts
Original file line number Diff line number Diff line change
@@ -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 });
8 changes: 8 additions & 0 deletions packages/feedback-service/src/lib/redis.ts
Original file line number Diff line number Diff line change
@@ -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,
});

0 comments on commit c32a58d

Please sign in to comment.