Repository: louislam/uptime-kuma
File: server/notification-providers/slack.js (JavaScript)

Code before:
            }

            const baseURL = await setting("primaryBaseURL");

            // Check if templating is enabled
            if (notification.slackUseTemplate) {
                const renderedText = await this.renderTemplate(
                    notification.slackTemplate,
                    msg,
                    monitorJSON,
                    heartbeatJSON
                );

                let data = {
                    text: renderedText,
                    channel: notification.slackchannel,
                    username: notification.slackusername,
                    icon_emoji: notification.slackiconemo,
                };

                await axios.post(notification.slackwebhookURL, data, config);
                return okMsg;
            }

            const includeGroupName =
                notification.slackIncludeGroupName === true || notification.slackIncludeGroupName === "true";

            const groupPath =
                includeGroupName && monitorJSON?.path?.length > 1 ? monitorJSON.path.slice(0, -1).join(" / ") : "";

            const title = monitorJSON?.name || "Uptime Kuma Alert";
            let data = {
                text: msg,
                channel: notification.slackchannel,
                username: notification.slackusername,
                icon_emoji: notification.slackiconemo,
                attachments: [],
            };

            if (notification.slackrichmessage) {
                data.attachments.push({
                    color: heartbeatJSON["status"] === UP ? "#2eb886" : "#e01e5a",
                    blocks: this.buildBlocks(baseURL, monitorJSON, heartbeatJSON, title, msg, includeGroupName),
                });
            } else {
                // Include group name in plain text messages if enabled
                if (includeGroupName && groupPath) {
                    data.text = `_${groupPath}_\n${title}\n${msg}`;
                } else {
                    data.text = `${title}\n${msg}`;
                }

Review comment (suggestion):
Not sure why this is done this way.
I think you mean this, right?

```suggestion
            const includeGroupName = notification.slackIncludeGroupName ?? true;
```

Also, please set this default in the frontend.
To do this, check how other notification providers do this in the mounted hook.

Code after:
            }

            const baseURL = await setting("primaryBaseURL");

            // Check if templating is enabled
            if (notification.slackUseTemplate) {
                const renderedText = await this.renderTemplate(
                    notification.slackTemplate,
                    msg,
                    monitorJSON,
                    heartbeatJSON
                );

                let data = {
                    text: renderedText,
                    channel: notification.slackchannel,
                    username: notification.slackusername,
                    icon_emoji: notification.slackiconemo,
                };

                await axios.post(notification.slackwebhookURL, data, config);
                return okMsg;
            }

            const includeGroupName = notification.slackIncludeGroupName ?? true;

            const groupPath =
                includeGroupName && monitorJSON?.path?.length > 1 ? monitorJSON.path.slice(0, -1).join(" / ") : "";

            const title = monitorJSON?.name || "Uptime Kuma Alert";
            let data = {
                text: msg,
                channel: notification.slackchannel,
                username: notification.slackusername,
                icon_emoji: notification.slackiconemo,
                attachments: [],
            };

            if (notification.slackrichmessage) {
                data.attachments.push({
                    color: heartbeatJSON["status"] === UP ? "#2eb886" : "#e01e5a",
                    blocks: this.buildBlocks(baseURL, monitorJSON, heartbeatJSON, title, msg, includeGroupName),
                });
            } else {
                // Include group name in plain text messages if enabled
                if (includeGroupName && groupPath) {
                    data.text = `_${groupPath}_\n${title}\n${msg}`;
                } else {
                    data.text = `${title}\n${msg}`;
                }
            }