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

Code before:
        }

        if (msg != null && heartbeatJSON != null && heartbeatJSON["status"] === DOWN) {
            let title = "UptimeKuma Monitor Down";
            return await this.postNotification(title, msg, barkEndpoint);
        }

        if (msg != null) {
            let title = "UptimeKuma Message";
            return await this.postNotification(title, msg, barkEndpoint);
        }
    }

    /**
     * Add additional parameter for better on device styles (iOS 15
     * optimized)
     * @param {string} postUrl URL to append parameters to
     * @returns {string}
     */
    appendAdditionalParameters(notification, postUrl) {
        // grouping all our notifications
        if (notification.barkGroup != null) {
            postUrl += "&group=" + notification.barkGroup;
        } else {
            postUrl += "&group=" + "UptimeKuma";
            // default group
        }
        // set icon to uptime kuma icon, 11kb should be fine
        postUrl += "&icon=" + barkNotificationAvatar;
        // picked a sound, this should follow system's mute status when arrival
        if (notification.barkSound != null) {
            postUrl += "&sound=" + notification.barkSound;
        } else {
            postUrl += "&sound=" + "telegraph";
            // default sound
        }
        return postUrl;
    }

    /**
     * Check if result is successful
     * @param {Object} result Axios response object
     * @throws {Error} The status code is not in range 2xx
     */
    checkResult(result) {
        if (result.status == null) {
            throw new Error("Bark notification failed with invalid response!");
        }
        if (result.status < 200 || result.status >= 300) {
            throw new Error("Bark notification failed with status code " + result.status);
        }

Review comment (suggestion):
```suggestion
            // default group
            postUrl += "&group=" + "UptimeKuma";
```

Code after:
        }

        if (msg != null && heartbeatJSON != null && heartbeatJSON["status"] === DOWN) {
            let title = "UptimeKuma Monitor Down";
            return await this.postNotification(title, msg, barkEndpoint);
        }

        if (msg != null) {
            let title = "UptimeKuma Message";
            return await this.postNotification(title, msg, barkEndpoint);
        }
    }

    /**
     * Add additional parameter for better on device styles (iOS 15
     * optimized)
     * @param {string} postUrl URL to append parameters to
     * @returns {string}
     */
    appendAdditionalParameters(notification, postUrl) {
        // set icon to uptime kuma icon, 11kb should be fine
        postUrl += "&icon=" + barkNotificationAvatar;
        // grouping all our notifications
        if (notification.barkGroup != null) {
            postUrl += "&group=" + notification.barkGroup;
        } else {
            // default name
            postUrl += "&group=" + "UptimeKuma";
        }
        // picked a sound, this should follow system's mute status when arrival
        if (notification.barkSound != null) {
            postUrl += "&sound=" + notification.barkSound;
        } else {
            // default sound
            postUrl += "&sound=" + "telegraph";
        }
        return postUrl;
    }

    /**
     * Check if result is successful
     * @param {Object} result Axios response object
     * @throws {Error} The status code is not in range 2xx
     */
    checkResult(result) {
        if (result.status == null) {
            throw new Error("Bark notification failed with invalid response!");
        }
        if (result.status < 200 || result.status >= 300) {
            throw new Error("Bark notification failed with status code " + result.status);
        }