mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
feat: optimize emoji reaction handling by checking supported emojis before database queries
This commit is contained in:
@@ -42,6 +42,10 @@ import UserMiddleware from "../Middleware/UserAuthorization";
|
||||
import CommonAPI from "./CommonAPI";
|
||||
import SlackUtil from "../Utils/Workspace/Slack/Slack";
|
||||
import DatabaseCommonInteractionProps from "../../Types/BaseDatabase/DatabaseCommonInteractionProps";
|
||||
import {
|
||||
PrivateNoteEmojis,
|
||||
PublicNoteEmojis,
|
||||
} from "../Utils/Workspace/Slack/Actions/ActionTypes";
|
||||
|
||||
export default class SlackAPI {
|
||||
public getRouter(): ExpressRouter {
|
||||
@@ -782,6 +786,18 @@ export default class SlackAPI {
|
||||
messageTs: (event["item"] as JSONObject)?.["ts"] as string,
|
||||
};
|
||||
|
||||
// OPTIMIZATION: Quick check if this is a supported emoji before any DB queries
|
||||
const isSupportedEmoji: boolean =
|
||||
PrivateNoteEmojis.includes(reactionData.reaction) ||
|
||||
PublicNoteEmojis.includes(reactionData.reaction);
|
||||
|
||||
if (!isSupportedEmoji) {
|
||||
logger.debug(
|
||||
`Emoji "${reactionData.reaction}" is not supported. Skipping.`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Process emoji reactions for Incidents, Alerts, and Scheduled Maintenance
|
||||
* Each handler will silently ignore if the channel is not linked to their resource type
|
||||
|
||||
Reference in New Issue
Block a user