diff --git a/.github/instructions/instructions.md b/.github/instructions/instructions.md new file mode 100644 index 0000000000..b20ce941a8 --- /dev/null +++ b/.github/instructions/instructions.md @@ -0,0 +1,11 @@ +--- +applyTo: '**' +--- + +If you would like to compile or build any project. Please cd into the directory and run the following command: + +``` +npm run compile +``` + +Ths will make sure there are no type / syntax errors. \ No newline at end of file diff --git a/Common/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.ts b/Common/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.ts index 41626f1315..2de0f4714e 100644 --- a/Common/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.ts +++ b/Common/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.ts @@ -321,6 +321,10 @@ export default class MicrosoftTeamsAlertActions { // Send the input card const card = await this.buildExecuteAlertOnCallPolicyCard(actionValue, projectId); + if (!card) { + await turnContext.sendActivity("No on-call policies found in the project"); + return; + } await turnContext.sendActivity({ attachments: [{ contentType: "application/vnd.microsoft.card.adaptive", content: card }] }); return; } @@ -431,7 +435,7 @@ export default class MicrosoftTeamsAlertActions { }; } - private static async buildExecuteAlertOnCallPolicyCard(alertId: string, projectId: ObjectID): Promise { + private static async buildExecuteAlertOnCallPolicyCard(alertId: string, projectId: ObjectID): Promise { const onCallPolicies = await OnCallDutyPolicyService.findBy({ query: { projectId: projectId, @@ -452,6 +456,10 @@ export default class MicrosoftTeamsAlertActions { value: policy._id?.toString() || "", })).filter(choice => choice.title && choice.value); + if (choices.length === 0) { + return null; + } + return { type: "AdaptiveCard", $schema: "http://adaptivecards.io/schemas/adaptive-card.json", diff --git a/Common/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.ts b/Common/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.ts index 54da243d40..41752bd4a4 100644 --- a/Common/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.ts +++ b/Common/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.ts @@ -343,6 +343,10 @@ export default class MicrosoftTeamsIncidentActions { // Send the input card const card = await this.buildExecuteOnCallPolicyCard(actionValue, projectId); + if (!card) { + await turnContext.sendActivity("No on-call policies found in the project"); + return; + } await turnContext.sendActivity({ attachments: [{ contentType: "application/vnd.microsoft.card.adaptive", content: card }] }); return; } @@ -470,7 +474,7 @@ export default class MicrosoftTeamsIncidentActions { }; } - private static async buildExecuteOnCallPolicyCard(incidentId: string, projectId: ObjectID): Promise { + private static async buildExecuteOnCallPolicyCard(incidentId: string, projectId: ObjectID): Promise { const onCallPolicies = await OnCallDutyPolicyService.findBy({ query: { projectId: projectId, @@ -491,6 +495,10 @@ export default class MicrosoftTeamsIncidentActions { value: policy._id?.toString() || "", })).filter(choice => choice.title && choice.value); + if (choices.length === 0) { + return null; + } + return { type: "AdaptiveCard", $schema: "http://adaptivecards.io/schemas/adaptive-card.json",