mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-01-16 23:00:51 +00:00
refactor: improve markdown formatting in notifications and update query id handling
This commit is contained in:
parent
ae0553a1e5
commit
63b560ad93
6 changed files with 24 additions and 10 deletions
|
|
@ -134,8 +134,8 @@ export class Service extends DatabaseService<Model> {
|
|||
_updatedItemIds: Array<ObjectID>,
|
||||
): Promise<OnUpdate<Model>> {
|
||||
// if status is updtaed then check if this on-call is related to the incident, if yes, then add to incident feed.
|
||||
if (onUpdate.updateBy.data.status && onUpdate.updateBy.query.id) {
|
||||
const id: ObjectID = onUpdate.updateBy.query.id! as ObjectID;
|
||||
if (onUpdate.updateBy.data.status && onUpdate.updateBy.query._id) {
|
||||
const id: ObjectID = onUpdate.updateBy.query._id! as ObjectID;
|
||||
|
||||
const onCalldutyPolicyExecutionLog: Model | null = await this.findOneById(
|
||||
{
|
||||
|
|
@ -177,7 +177,12 @@ export class Service extends DatabaseService<Model> {
|
|||
projectId: onCalldutyPolicyExecutionLog.projectId!,
|
||||
incidentFeedEventType: IncidentFeedEventType.OnCallPolicy,
|
||||
displayColor: Yellow500,
|
||||
feedInfoInMarkdown: `**On Call Policy Status Updated: ** On Call Policy **${onCallPolicy.name}** status updated to **${onCalldutyPolicyExecutionLog.status}**. ${onCalldutyPolicyExecutionLog.statusMessage}`,
|
||||
moreInformationInMarkdown: `**Status:** ${onCalldutyPolicyExecutionLog.status}
|
||||
|
||||
**Message:** ${onCalldutyPolicyExecutionLog.statusMessage}`,
|
||||
feedInfoInMarkdown: `**On Call Policy Status Updated:**
|
||||
|
||||
On-call policy **${onCallPolicy.name}** status updated to **${onCalldutyPolicyExecutionLog.status}**`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ export class Service extends DatabaseService<Model> {
|
|||
? this.getColorBasedOnStatus(status)
|
||||
: Blue500;
|
||||
|
||||
const feedInfoInMarkdown: string = `
|
||||
The On Call Policy "${onCallDutyPolicyExecutionLogTimeline.onCallDutyPolicy.name}" has been triggered. The escalation rule "${onCallDutyPolicyExecutionLogTimeline.onCallDutyPolicyEscalationRule?.name}" ${onCallDutyPolicyExecutionLogTimeline.onCallDutySchedule?.name ? String(" and schedule " + onCallDutyPolicyExecutionLogTimeline.onCallDutySchedule?.name) : ""} were applied. The user "${onCallDutyPolicyExecutionLogTimeline.alertSentToUser?.name}" (${onCallDutyPolicyExecutionLogTimeline.alertSentToUser?.email}) was alerted. The current status is "${status}" with the message: "${onCallDutyPolicyExecutionLogTimeline.statusMessage}". ${onCallDutyPolicyExecutionLogTimeline.userBelongsToTeam?.name ? "The user belongs to the team " + onCallDutyPolicyExecutionLogTimeline.userBelongsToTeam?.name : ""} ${onCallDutyPolicyExecutionLogTimeline.isAcknowledged ? "The alert was acknowledged at " + onCallDutyPolicyExecutionLogTimeline.acknowledgedAt : ""}
|
||||
`;
|
||||
const feedInfoInMarkdown: string = `**On-call alert ${status} to ${onCallDutyPolicyExecutionLogTimeline.alertSentToUser?.name?.toString().trim()}**
|
||||
|
||||
The on-call policy **${onCallDutyPolicyExecutionLogTimeline.onCallDutyPolicy.name}** has been triggered. The escalation rule **${onCallDutyPolicyExecutionLogTimeline.onCallDutyPolicyEscalationRule?.name}** ${onCallDutyPolicyExecutionLogTimeline.onCallDutySchedule?.name ? String(" and schedule **" + onCallDutyPolicyExecutionLogTimeline.onCallDutySchedule?.name + "**") : ""} were applied. The user **${onCallDutyPolicyExecutionLogTimeline.alertSentToUser?.name}** (${onCallDutyPolicyExecutionLogTimeline.alertSentToUser?.email}) was alerted. The status of this alert is **${status}** with the message: \`${onCallDutyPolicyExecutionLogTimeline.statusMessage}\`. ${onCallDutyPolicyExecutionLogTimeline.userBelongsToTeam?.name ? "The alert was sent because the user belogs to the team **" + onCallDutyPolicyExecutionLogTimeline.userBelongsToTeam?.name + "**" : ""} ${onCallDutyPolicyExecutionLogTimeline.isAcknowledged ? "The alert was acknowledged at **" + onCallDutyPolicyExecutionLogTimeline.acknowledgedAt + "**" : ""}`;
|
||||
|
||||
logger.debug("Feed Info in Markdown: " + feedInfoInMarkdown);
|
||||
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ export class Service extends DatabaseService<Model> {
|
|||
data: {
|
||||
status: UserNotificationExecutionStatus.Error, // now the worker will pick this up and complete this or mark this as failed.
|
||||
statusMessage:
|
||||
"No notification rules found. Please add rules in User Settings > On-Call Rules.",
|
||||
"No notification rules found for this user. User should add the rules in User Settings > On-Call Rules.",
|
||||
},
|
||||
props: {
|
||||
isRoot: true,
|
||||
|
|
@ -158,7 +158,7 @@ export class Service extends DatabaseService<Model> {
|
|||
data: {
|
||||
status: OnCallDutyExecutionLogTimelineStatus.Error,
|
||||
statusMessage:
|
||||
"No notification rules found. Please add rules in User Settings > On-Call Rules.",
|
||||
"No notification rules found for this user. User should add the rules in User Settings > On-Call Rules.",
|
||||
},
|
||||
props: {
|
||||
isRoot: true,
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import Icon from "../Icon/Icon";
|
|||
import IconProp from "../../../Types/Icon/IconProp";
|
||||
import Color from "../../../Types/Color";
|
||||
|
||||
export interface ComponentProps {
|
||||
export interface FeedItemProps {
|
||||
key: string;
|
||||
textInMarkdown: string;
|
||||
element?: ReactElement;
|
||||
|
|
@ -26,6 +26,11 @@ export interface ComponentProps {
|
|||
color: Color;
|
||||
}
|
||||
|
||||
|
||||
export interface ComponentProps extends FeedItemProps {
|
||||
isLastItem?: boolean;
|
||||
}
|
||||
|
||||
const FeedItem: FunctionComponent<ComponentProps> = (
|
||||
props: ComponentProps,
|
||||
): ReactElement => {
|
||||
|
|
|
|||
4
Common/UI/index.d.ts
vendored
Normal file
4
Common/UI/index.d.ts
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
declare module "*.png";
|
||||
declare module "*.svg";
|
||||
declare module "*.jpg";
|
||||
declare module "*.gif";
|
||||
|
|
@ -134,7 +134,7 @@ const Settings: FunctionComponent<PageComponentProps> = (): ReactElement => {
|
|||
description: options.description,
|
||||
}}
|
||||
noItemsMessage={
|
||||
"No notification rules found. Please add one to receive notifications."
|
||||
"No notification rules found for this user. Please add one to receive notifications."
|
||||
}
|
||||
formFields={[
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue