Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release candidate v0.19.0 #86

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,760 changes: 1,562 additions & 198 deletions package-lock.json

Large diffs are not rendered by default.

15 changes: 10 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,27 @@
"typescript": "^4.8.3"
},
"dependencies": {
"@types/express": "^4.16.1",
"@types/express": "^4.17.21",
"@types/mustache": "^0.8.32",
"@types/node": "^12.0.2",
"@types/request": "^2.48.1",
"body-parser": "^1.20.2",
"axios": "1.6.8",
"express": "^4.19.2",
"axios": "^1.7.7",
"body-parser": "^1.20.3",
"express": "^4.21.0",
"js-yaml": "^3.13.1",
"json-rules-engine": "^2.3.6",
"moment-timezone": "^0.5.31",
"mustache": "^3.0.1",
"nats": "2.10.0",
"notifme-sdk": "^1.14.1",
"notifme-sdk": "^1.16.13",
"pg": "^8.2.1",
"reflect-metadata": "^0.1.13",
"typeorm": "0.3.17",
"winston": "^3.2.1"
},
"overrides": {
"node-gcm": {
"axios": "1.7.7"
}
}
}
4 changes: 4 additions & 0 deletions src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,7 @@ export enum EVENT_TYPE {
ScoopNotification = 9,
}

export enum ENV_TYPE_INT{
AllExistingAndFutureProdEnvs = -2,
AllExistingAndFutureNonProdEnvs = -1
}
8 changes: 4 additions & 4 deletions src/destination/destinationHandlers/sesHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,13 @@ export class SESService implements Handler {
if(event.eventTypeId===4 || event.eventTypeId === EVENT_TYPE.ImagePromotion){
let commentDisplayStyle = (event.payload.imageComment === "") ? 'none' : 'inline';
let tagDisplayStyle = (event.payload.imageTagNames === null) ? 'none' : 'inline';
json = Mustache.render(template, { ...parsedEvent, commentDisplayStyle ,tagDisplayStyle});
json = Mustache.render(Mustache.escape(template), { ...parsedEvent, commentDisplayStyle ,tagDisplayStyle});
}else if(event.eventTypeId===5){
let commentDisplayStyle = (event.payload.protectConfigComment === "") ? 'none' : 'inline';
json = Mustache.render(template, { ...parsedEvent, commentDisplayStyle });
json = Mustache.render(Mustache.escape(template), { ...parsedEvent, commentDisplayStyle });
}
else{
json = Mustache.render(template, parsedEvent)
json = Mustache.render(Mustache.escape(template), parsedEvent)
}

const res = await sdk.send(
Expand Down Expand Up @@ -218,4 +218,4 @@ export class SESService implements Handler {
let eventLog = this.eventLogBuilder.buildEventLog(event, p.dest, false, setting);
this.eventLogRepository.saveEventLog(eventLog);
}
}
}
6 changes: 3 additions & 3 deletions src/destination/destinationHandlers/slackHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ export class SlackService implements Handler {
if (event.eventTypeId == EVENT_TYPE.ScoopNotification){
const date = moment(event.eventTime);
event.payload.scoopNotificationConfig.data.interceptedAt = date.unix();
jsons = Mustache.render(template, event.payload.scoopNotificationConfig.data);
jsons = Mustache.render(Mustache.escape(template), event.payload.scoopNotificationConfig.data);
}else{
let parsedEvent = this.mh.parseEvent(event as Event, true);
jsons = Mustache.render(template, parsedEvent);
jsons = Mustache.render(Mustache.escape(template), parsedEvent);
}

let j = JSON.parse(jsons)
Expand Down Expand Up @@ -162,4 +162,4 @@ export class SlackService implements Handler {
let eventLog = this.eventLogBuilder.buildEventLog(event, p.dest, false, setting);
this.eventLogRepository.saveEventLog(eventLog);
}
}
}
8 changes: 4 additions & 4 deletions src/destination/destinationHandlers/smtpHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,12 @@ export class SMTPService implements Handler {
if(event.eventTypeId===4){
let commentDisplayStyle = (event.payload.imageComment === "") ? 'none' : 'inline';
let tagDisplayStyle = (event.payload.imageTagNames === null) ? 'none' : 'inline';
json = Mustache.render(template, { ...parsedEvent, commentDisplayStyle ,tagDisplayStyle});
json = Mustache.render(Mustache.escape(template), { ...parsedEvent, commentDisplayStyle ,tagDisplayStyle});
}else if(event.eventTypeId===5){
let commentDisplayStyle = (event.payload.protectConfigComment === "") ? 'none' : 'inline';
json = Mustache.render(template, { ...parsedEvent, commentDisplayStyle });
json = Mustache.render(Mustache.escape(template), { ...parsedEvent, commentDisplayStyle });
}else{
json = Mustache.render(template, parsedEvent)
json = Mustache.render(Mustache.escape(template), parsedEvent)
}
const res = await sdk.send(
{
Expand Down Expand Up @@ -233,4 +233,4 @@ export class SMTPService implements Handler {
let eventLog = this.eventLogBuilder.buildEventLog(event, p.dest, false, setting);
this.eventLogRepository.saveEventLog(eventLog);
}
}
}
24 changes: 12 additions & 12 deletions src/destination/destinationHandlers/webhookHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
* limitations under the License.
*/

import {Event, Handler} from '../../notification/service/notificationService';
import axios from 'axios';
import Engine from 'json-rules-engine';
import moment from "moment-timezone";
import Mustache from 'mustache';
import Engine from 'json-rules-engine'
import {EventLogBuilder} from "../../common/eventLogBuilder"
import {EventLogRepository} from '../../repository/notifierEventLogRepository';
import { EventLogBuilder } from "../../common/eventLogBuilder";
import { MustacheHelper } from '../../common/mustacheHelper';
import { EVENT_TYPE } from "../../common/types";
import { NotificationSettings } from "../../entities/notificationSettings";
import { WebhookConfig } from '../../entities/webhookconfig';
import {NotificationSettings} from "../../entities/notificationSettings";
import { Event, Handler } from '../../notification/service/notificationService';
import { EventLogRepository } from '../../repository/notifierEventLogRepository';
import { WebhookConfigRepository } from '../../repository/webhookConfigRepository';
import {MustacheHelper} from '../../common/mustacheHelper';
import axios from 'axios';
import {EVENT_TYPE, WebhookParsedEvent} from "../../common/types";
import moment from "moment-timezone";

export class WebhookService implements Handler{
eventLogRepository: EventLogRepository
Expand Down Expand Up @@ -113,10 +113,10 @@ export class WebhookService implements Handler{
if (event.eventTypeId == EVENT_TYPE.ScoopNotification){
const date = moment(event.eventTime);
event.payload.scoopNotificationConfig.data.interceptedAt = date.unix();
jsons = Mustache.render(template, event.payload.scoopNotificationConfig.data);
jsons = Mustache.render(Mustache.escape(template), event.payload.scoopNotificationConfig.data);
}else {
let parsedEvent = this.mh.parseEventForWebhook(event as Event);
jsons = Mustache.render(template, parsedEvent);
jsons = Mustache.render(Mustache.escape(template), parsedEvent);
}

let j = JSON.parse(jsons);
Expand Down Expand Up @@ -149,4 +149,4 @@ export class WebhookService implements Handler{
this.eventLogRepository.saveEventLog(eventLog);
}

}
}
5 changes: 3 additions & 2 deletions src/notification/service/notificationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class NotificationService {
throw new CustomError("Event is not valid", 400)
}

const settingsResults=await this.notificationSettingsRepository.findByEventSource(event.pipelineType, event.pipelineId, event.eventTypeId, event.appId, event.envId, event.teamId);
const settingsResults=await this.notificationSettingsRepository.findByEventSource(event.pipelineType, event.pipelineId, event.eventTypeId, event.appId, event.envId, event.teamId, event.clusterId, event.isProdEnv);
this.logger.info('notificationSettingsRepository.findByEventSource')
if (!settingsResults || settingsResults.length == 0) {
this.logger.info("no notification settings found for event " + event.correlationId);
Expand Down Expand Up @@ -253,7 +253,8 @@ class Event {
appId: number
envId: number
teamId: number
clusterId: number
isProdEnv: boolean
baseUrl?: string
}

export {NotificationService, Event}
Loading
Loading