Skip to content

Commit

Permalink
chore: add formatting to Slack notifications if meets pilot testing c…
Browse files Browse the repository at this point in the history
…riteria (#3944)
  • Loading branch information
jessicamcinchak authored Nov 13, 2024
1 parent 2c8eaf3 commit dee5e1a
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion api.planx.uk/modules/webhooks/service/sendNotification/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,40 @@ export const sendSlackNotification = async (
if (disability) message += " [Exempt]";
if (resubmission) message += " [Resubmission]";

await slack.send(":incoming_envelope: " + message);
// Prefix message with a custom emoji if this submission fits November 2024 ODP Pilot testing criteria
const pilotCouncils = [
"barnet",
"buckinghamshire",
"camden",
"lambeth",
"medway",
];
// Message app types are a bit messy - Uniform won't have app type at all so we id by system because only accepts LDCs,
// BOPS will have internal ID with app type prefix, Email & S3 will have full PlanX service name
const pilotServices = [
"uniform",
"happ",
"ldc",
"apply for planning permission",
"apply for a lawful development certificate",
];

let isPilotEvent = false;
pilotCouncils.forEach((council) => {
pilotServices.forEach((service) => {
if (
message?.toLowerCase()?.includes(council) &&
message?.toLowerCase()?.includes(service)
) {
isPilotEvent = true;
}
});
});

const baseMessage = ":incoming_envelope: " + message;
message = isPilotEvent ? ":large_orange_square: " + baseMessage : baseMessage;

await slack.send(message);
return message;
};

Expand Down

0 comments on commit dee5e1a

Please sign in to comment.