ronantakizawa/codereview-bench huggingface dataset:
Repository: louislam/uptime-kuma
File: server/notification-providers/gtx-messaging.js (JavaScript)

Code before:
const NotificationProvider = require("./notification-provider");
const axios = require("axios");

class GtxMessaging extends NotificationProvider {
    name = "gtxmessaging";

    /**
     * @inheritDoc
     */
    async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
        const okMsg = "Sent Successfully.";

        let authKey = notification.gtxMessagingApiKey;
        let from = notification.gtxMessagingFrom.trim();
        let to = notification.gtxMessagingTo.trim();
        let text = msg.replaceAll("🔴 ", "").replaceAll("✅ ", "");

        try {

            let data = new URLSearchParams();
            data.append("from", from);
            data.append("to", to);
            data.append("text", text);

            let url = `https://rest.gtx-messaging.net/smsc/sendsms/${authKey}/json`;

            console.log(`will post url: ${url}, data:`, data);

            await axios.post(url, data);

            return okMsg;
        } catch (error) {
            this.throwGeneralAxiosError(error);
        }
    }
}

module.exports = GtxMessaging;


Review comment (suggestion):
I think This should be inlined for readability.

```suggestion
```

Code after:
const NotificationProvider = require("./notification-provider");
const axios = require("axios");

class GtxMessaging extends NotificationProvider {
    name = "gtxmessaging";

    /**
     * @inheritDoc
     */
    async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
        const okMsg = "Sent Successfully.";

        // The UP/DOWN symbols will be replaced with `???` by gtx-messaging
        const text = msg.replaceAll("🔴 ", "").replaceAll("✅ ", "");

        try {
            const data = new URLSearchParams();
            data.append("from", notification.gtxMessagingFrom.trim());
            data.append("to", notification.gtxMessagingTo.trim());
            data.append("text", text);

            const url = `https://rest.gtx-messaging.net/smsc/sendsms/${notification.gtxMessagingApiKey}/json`;

            await axios.post(url, data);

            return okMsg;
        } catch (error) {
            this.throwGeneralAxiosError(error);
        }
    }
}

module.exports = GtxMessaging;
Repository: louislam/uptime-kuma
File: server/notification-providers/gtx-messaging.js (JavaScript)

Code before:
const NotificationProvider = require("./notification-provider");
const axios = require("axios");

class GtxMessaging extends NotificationProvider {
    name = "gtxmessaging";

    /**
     * @inheritDoc
     */
    async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
        const okMsg = "Sent Successfully.";

        let authKey = notification.gtxMessagingApiKey;
        let from = notification.gtxMessagingFrom.trim();
        let to = notification.gtxMessagingTo.trim();
        let text = msg.replaceAll("🔴 ", "").replaceAll("✅ ", "");

        try {

            let data = new URLSearchParams();
            data.append("from", from);
            data.append("to", to);
            data.append("text", text);

            let url = `https://rest.gtx-messaging.net/smsc/sendsms/${authKey}/json`;

            console.log(`will post url: ${url}, data:`, data);

            await axios.post(url, data);

            return okMsg;
        } catch (error) {
            this.throwGeneralAxiosError(error);
        }
    }
}

module.exports = GtxMessaging;


Review comment (suggestion):
```suggestion
            data.append("from", notification.gtxMessagingFrom.trim());
            data.append("to", notification.gtxMessagingTo.trim());
```

Code after:
const NotificationProvider = require("./notification-provider");
const axios = require("axios");

class GtxMessaging extends NotificationProvider {
    name = "gtxmessaging";

    /**
     * @inheritDoc
     */
    async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
        const okMsg = "Sent Successfully.";

        // The UP/DOWN symbols will be replaced with `???` by gtx-messaging
        const text = msg.replaceAll("🔴 ", "").replaceAll("✅ ", "");

        try {
            const data = new URLSearchParams();
            data.append("from", notification.gtxMessagingFrom.trim());
            data.append("to", notification.gtxMessagingTo.trim());
            data.append("text", text);

            const url = `https://rest.gtx-messaging.net/smsc/sendsms/${notification.gtxMessagingApiKey}/json`;

            await axios.post(url, data);

            return okMsg;
        } catch (error) {
            this.throwGeneralAxiosError(error);
        }
    }
}

module.exports = GtxMessaging;
Repository: louislam/uptime-kuma
File: src/components/notifications/GtxMessaging.vue (Vue)

Code before:
<template>
    <div class="mb-3">
        <label for="gtxmessaging-api-key" class="form-label">{{ $t("gtxMessagingApiKey") }}</label>
        <HiddenInput id="gtxmessaging-api-key" v-model="$parent.notification.gtxMessagingApiKey" :required="true"></HiddenInput>
    </div>
    <div class="mb-3">
        <label for="gtxmessaging-from" class="form-label">{{ $t("gtxMessagingFrom") }}</label>
        <input id="gtxmessaging-from" v-model="$parent.notification.gtxMessagingFrom" type="text" class="form-control" required>
    </div>
    <div class="mb-3">
        <label for="gtxmessaging-to" class="form-label">{{ $t("gtxMessagingTo") }}</label>
        <input id="gtxmessaging-to" v-model="$parent.notification.gtxMessagingTo" type="text" pattern="^[\d-]{10,31}(@[\w\.]{1,})?$" class="form-control" required>
    </div>
    <div class="mb-3">
        <i18n-t tag="p" keypath="More info on:" style="margin-top: 8px;">
            <a href="https://www.gtx-messaging.com/en/solutions/sms-gateway-api/" target="_blank">https://www.gtx-messaging.com/en/solutions/sms-gateway-api/</a>
        </i18n-t>
    </div>
</template>

<script>
import HiddenInput from "../HiddenInput.vue";

export default {
    components: {
        HiddenInput
    }
};

Review comment (suggestion):
A general translation key already exists for this

```suggestion
        <label for="gtxmessaging-api-key" class="form-label">{{ $t("API Key") }}</label>
```

Code after:
<template>
    <div class="mb-3">
        <label for="gtxmessaging-api-key" class="form-label">{{ $t("API Key") }}</label>
        <HiddenInput id="gtxmessaging-api-key" v-model="$parent.notification.gtxMessagingApiKey" :required="true"></HiddenInput>
        <div class="form-text">
            {{ $t("gtxMessagingApiKeyHint") }}
        </div>
    </div>
    <div class="mb-3">
        <label for="gtxmessaging-from" class="form-label">{{ $t("From Phone Number / Transmission Path Originating Address (TPOA)") }}</label>
        <input id="gtxmessaging-from" v-model="$parent.notification.gtxMessagingFrom" type="text" class="form-control" required>
        <i18n-t tag="div" keypath="gtxMessagingFromHint" class="form-text">
            <template #e164>
                <a href="https://wikipedia.org/wiki/E.164">E.164</a>
            </template>
            <template #e212>
                <a href="https://wikipedia.org/wiki/E.212">E.212</a>
            </template>
            <template #e214>
                <a href="https://wikipedia.org/wiki/E.214">E.214</a>
            </template>
        </i18n-t>
    </div>
    <div class="mb-3">
        <label for="gtxmessaging-to" class="form-label">{{ $t("To Phone Number") }}</label>
        <input id="gtxmessaging-to" v-model="$parent.notification.gtxMessagingTo" type="text" pattern="^\+\d+$" class="form-control" required>
        <i18n-t tag="div" keypath="gtxMessagingToHint" class="form-text">
            <template #e164>
Repository: louislam/uptime-kuma
File: server/notification-providers/heii-oncall.js (JavaScript)

Code before:
     * @param {BeanModel} notification Message title
     * @param {string} action Trigger action (alert, resovle)
     * @param {object} payload Data for Heii On-Call
     * @returns {Promise<string>} Success message
     */
    async postNotification(notification, action, payload) {
        const config = {
            headers: {
                Accept: "application/json",
                "Content-Type": "application/json",
                Authorization: "Bearer " + notification.heiiOnCallApiKey,
            },
        };

        // Post to Heii On-Call Trigger https://heiioncall.com/docs#manual-triggers
        try {
            await axios.post(
                `${heiiOnCallBaseUrl}/triggers/${notification.heiiOnCallTriggerId}/${action}`,
                payload,
                config
            );
        } catch (error) {
            this.throwGeneralAxiosError(error);
        }

        return "Heii On-Call post sent successfully.";
    }
}

module.exports = HeiiOnCall;


Review comment (suggestion):
Looking at the other notification providers, this is more in-line with the behaviour of other providers ^^

```suggestion
        return "Sent Successfully";
```

Code after:
const { UP, DOWN, getMonitorRelativeURL } = require("../../src/util");
const { setting } = require("../util-server");

const NotificationProvider = require("./notification-provider");
const axios = require("axios");
class HeiiOnCall extends NotificationProvider {
    name = "HeiiOnCall";

    /**
     * @inheritdoc
     */
    async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
        const okMsg = "Sent Successfully.";
        const payload = heartbeatJSON || {};

        const baseURL = await setting("primaryBaseURL");
        if (baseURL && monitorJSON) {
            payload["url"] = baseURL + getMonitorRelativeURL(monitorJSON.id);
        }

        const config = {
            headers: {
                Accept: "application/json",
                "Content-Type": "application/json",
                Authorization: "Bearer " + notification.heiiOnCallApiKey,
            },
        };
        const heiiUrl = `https://heiioncall.com/triggers/${notification.heiiOnCallTriggerId}/`;
        // docs https://heiioncall.com/docs#manual-triggers
        try {
            if (!heartbeatJSON) {
                // Testing or general notification like certificate expiry
                payload["msg"] = msg;
                await axios.post(heiiUrl + "alert", payload, config);
                return okMsg;
            }

            if (heartbeatJSON.status === DOWN) {
                await axios.post(heiiUrl + "alert", payload, config);
                return okMsg;
            }
            if (heartbeatJSON.status === UP) {
                await axios.post(heiiUrl + "resolve", payload, config);
                return okMsg;
            }
        } catch (error) {
            this.throwGeneralAxiosError(error);
        }
    }
}

module.exports = HeiiOnCall;
Repository: louislam/uptime-kuma
File: src/components/notifications/HeiiOnCall.vue (Vue)

Code before:
<template>
    <div class="mb-3">
        <label for="heiioncall-apikey" class="form-label">{{ $t("API Key") }}<span
            style="color: red;"
        ><sup>*</sup></span></label>
        <HiddenInput
            id="heiioncall-apikey" v-model="$parent.notification.heiiOnCallApiKey" required="true"
            autocomplete="false"
        ></HiddenInput>
    </div>
    <div class="mb-3">
        <label for="heiioncall-trigger-id" class="form-label">{{ $t("Trigger ID") }}<span
            style="color: red;"
        ><sup>*</sup></span></label>
        <HiddenInput
            id="heiioncall-trigger-id" v-model="$parent.notification.heiiOnCallTriggerId" required="true"
            autocomplete="false"
        ></HiddenInput>
    </div>
    <div class="form-text">
        <i18n-t tag="p" keypath="wayToGetHeiiOnCallDetails" style="margin-top: 8px;">
            <a href="https://heiioncall.com/docs" target="_blank">Heii On-Call Documentation</a>
        </i18n-t>
    </div>
</template>

<script>
import HiddenInput from "../HiddenInput.vue";
export default {

Review comment (suggestion):
General note (not for this PR to fix ^^)
I really don't like that this has to be done. This is way more error prawn tan necessary.

Code after:
<template>
    <div class="mb-3">
        <label for="heiioncall-apikey" class="form-label">{{ $t("API Key") }}<span
            style="color: red;"
        ><sup>*</sup></span></label>
        <HiddenInput
            id="heiioncall-apikey" v-model="$parent.notification.heiiOnCallApiKey" required="true"
            autocomplete="false"
        ></HiddenInput>
    </div>
    <div class="mb-3">
        <label for="heiioncall-trigger-id" class="form-label">Trigger ID<span
            style="color: red;"
        ><sup>*</sup></span></label>
        <HiddenInput
            id="heiioncall-trigger-id" v-model="$parent.notification.heiiOnCallTriggerId" required="true"
            autocomplete="false"
        ></HiddenInput>
    </div>
    <i18n-t tag="p" keypath="wayToGetHeiiOnCallDetails" class="form-text mt-3">
        <template #documentation>
            <a href="https://heiioncall.com/docs" target="_blank">{{ $t("documentationOf", ["Heii On-Call"]) }}</a>
        </template>
    </i18n-t>
</template>

<script>
import HiddenInput from "../HiddenInput.vue";
export default {
Repository: louislam/uptime-kuma
File: src/components/notifications/HeiiOnCall.vue (Vue)

Code before:
<template>
    <div class="mb-3">
        <label for="heiioncall-apikey" class="form-label">{{ $t("API Key") }}<span
            style="color: red;"
        ><sup>*</sup></span></label>
        <HiddenInput
            id="heiioncall-apikey" v-model="$parent.notification.heiiOnCallApiKey" required="true"
            autocomplete="false"
        ></HiddenInput>
    </div>
    <div class="mb-3">
        <label for="heiioncall-trigger-id" class="form-label">{{ $t("Trigger ID") }}<span
            style="color: red;"
        ><sup>*</sup></span></label>
        <HiddenInput
            id="heiioncall-trigger-id" v-model="$parent.notification.heiiOnCallTriggerId" required="true"
            autocomplete="false"
        ></HiddenInput>
    </div>
    <div class="form-text">
        <i18n-t tag="p" keypath="wayToGetHeiiOnCallDetails" style="margin-top: 8px;">
            <a href="https://heiioncall.com/docs" target="_blank">Heii On-Call Documentation</a>
        </i18n-t>
    </div>
</template>

<script>
import HiddenInput from "../HiddenInput.vue";
export default {
    components: {
        HiddenInput,
    },
};
</script>


Review comment (suggestion):
I think it makes sense to allow translation of the word `documentation`

```suggestion
            <a href="https://heiioncall.com/docs" target="_blank">{{ $t("documentationOf", ["Heii On-Call"]) }}</a>
```

Code after:
<template>
    <div class="mb-3">
        <label for="heiioncall-apikey" class="form-label">{{ $t("API Key") }}<span
            style="color: red;"
        ><sup>*</sup></span></label>
        <HiddenInput
            id="heiioncall-apikey" v-model="$parent.notification.heiiOnCallApiKey" required="true"
            autocomplete="false"
        ></HiddenInput>
    </div>
    <div class="mb-3">
        <label for="heiioncall-trigger-id" class="form-label">Trigger ID<span
            style="color: red;"
        ><sup>*</sup></span></label>
        <HiddenInput
            id="heiioncall-trigger-id" v-model="$parent.notification.heiiOnCallTriggerId" required="true"
            autocomplete="false"
        ></HiddenInput>
    </div>
    <i18n-t tag="p" keypath="wayToGetHeiiOnCallDetails" class="form-text mt-3">
        <template #documentation>
            <a href="https://heiioncall.com/docs" target="_blank">{{ $t("documentationOf", ["Heii On-Call"]) }}</a>
        </template>
    </i18n-t>
</template>

<script>
import HiddenInput from "../HiddenInput.vue";
export default {
    components: {
        HiddenInput,
    },
};
</script>
Repository: louislam/uptime-kuma
File: src/components/notifications/HeiiOnCall.vue (Vue)

Code before:
<template>
    <div class="mb-3">
        <label for="heiioncall-apikey" class="form-label">{{ $t("API Key") }}<span
            style="color: red;"
        ><sup>*</sup></span></label>
        <HiddenInput
            id="heiioncall-apikey" v-model="$parent.notification.heiiOnCallApiKey" required="true"
            autocomplete="false"
        ></HiddenInput>
    </div>
    <div class="mb-3">
        <label for="heiioncall-trigger-id" class="form-label">{{ $t("Trigger ID") }}<span
            style="color: red;"
        ><sup>*</sup></span></label>
        <HiddenInput
            id="heiioncall-trigger-id" v-model="$parent.notification.heiiOnCallTriggerId" required="true"
            autocomplete="false"
        ></HiddenInput>
    </div>
    <div class="form-text">
        <i18n-t tag="p" keypath="wayToGetHeiiOnCallDetails" style="margin-top: 8px;">
            <a href="https://heiioncall.com/docs" target="_blank">Heii On-Call Documentation</a>
        </i18n-t>
    </div>
</template>

<script>
import HiddenInput from "../HiddenInput.vue";
export default {
    components: {
        HiddenInput,
    },
};
</script>


Review comment (suggestion):
Can these `div`/`p` tags be merged and could we use the `mb-3` instead of adding `style="margin-top: 8px;"`?
I think this can be simplified

Code after:
<template>
    <div class="mb-3">
        <label for="heiioncall-apikey" class="form-label">{{ $t("API Key") }}<span
            style="color: red;"
        ><sup>*</sup></span></label>
        <HiddenInput
            id="heiioncall-apikey" v-model="$parent.notification.heiiOnCallApiKey" required="true"
            autocomplete="false"
        ></HiddenInput>
    </div>
    <div class="mb-3">
        <label for="heiioncall-trigger-id" class="form-label">Trigger ID<span
            style="color: red;"
        ><sup>*</sup></span></label>
        <HiddenInput
            id="heiioncall-trigger-id" v-model="$parent.notification.heiiOnCallTriggerId" required="true"
            autocomplete="false"
        ></HiddenInput>
    </div>
    <i18n-t tag="p" keypath="wayToGetHeiiOnCallDetails" class="form-text mt-3">
        <template #documentation>
            <a href="https://heiioncall.com/docs" target="_blank">{{ $t("documentationOf", ["Heii On-Call"]) }}</a>
        </template>
    </i18n-t>
</template>

<script>
import HiddenInput from "../HiddenInput.vue";
export default {
    components: {
        HiddenInput,
    },
};
</script>
Repository: louislam/uptime-kuma
File: src/components/notifications/HeiiOnCall.vue (Vue)

Code before:
<template>
    <div class="mb-3">
        <label for="heiioncall-apikey" class="form-label">{{ $t("API Key") }}<span
            style="color: red;"
        ><sup>*</sup></span></label>
        <HiddenInput
            id="heiioncall-apikey" v-model="$parent.notification.heiiOnCallApiKey" required="true"
            autocomplete="false"
        ></HiddenInput>
    </div>
    <div class="mb-3">
        <label for="heiioncall-trigger-id" class="form-label">{{ $t("Trigger ID") }}<span
            style="color: red;"
        ><sup>*</sup></span></label>
        <HiddenInput
            id="heiioncall-trigger-id" v-model="$parent.notification.heiiOnCallTriggerId" required="true"
            autocomplete="false"
        ></HiddenInput>
    </div>
    <div class="form-text">
        <i18n-t tag="p" keypath="wayToGetHeiiOnCallDetails" style="margin-top: 8px;">
            <a href="https://heiioncall.com/docs" target="_blank">Heii On-Call Documentation</a>
        </i18n-t>
    </div>
</template>

<script>
import HiddenInput from "../HiddenInput.vue";
export default {
    components: {
        HiddenInput,
    },
};
</script>


Review comment (suggestion):
Stupid question, but is this label something where translation makes sense? 
(can Heli-Oncall switch to a different language and is this then a different text)

If yes, translation makes sense, if no, this translation can be removed ^^

Code after:
<template>
    <div class="mb-3">
        <label for="heiioncall-apikey" class="form-label">{{ $t("API Key") }}<span
            style="color: red;"
        ><sup>*</sup></span></label>
        <HiddenInput
            id="heiioncall-apikey" v-model="$parent.notification.heiiOnCallApiKey" required="true"
            autocomplete="false"
        ></HiddenInput>
    </div>
    <div class="mb-3">
        <label for="heiioncall-trigger-id" class="form-label">Trigger ID<span
            style="color: red;"
        ><sup>*</sup></span></label>
        <HiddenInput
            id="heiioncall-trigger-id" v-model="$parent.notification.heiiOnCallTriggerId" required="true"
            autocomplete="false"
        ></HiddenInput>
    </div>
    <i18n-t tag="p" keypath="wayToGetHeiiOnCallDetails" class="form-text mt-3">
        <template #documentation>
            <a href="https://heiioncall.com/docs" target="_blank">{{ $t("documentationOf", ["Heii On-Call"]) }}</a>
        </template>
    </i18n-t>
</template>

<script>
import HiddenInput from "../HiddenInput.vue";
export default {
    components: {
        HiddenInput,
    },
};
</script>
Repository: louislam/uptime-kuma
File: src/components/notifications/HeiiOnCall.vue (Vue)

Code before:
<template>
    <div class="mb-3">
        <label for="heiioncall-apikey" class="form-label">{{ $t("API Key") }}<span
            style="color: red;"
        ><sup>*</sup></span></label>
        <HiddenInput
            id="heiioncall-apikey" v-model="$parent.notification.heiiOnCallApiKey" required="true"
            autocomplete="false"
        ></HiddenInput>
    </div>
    <div class="mb-3">
        <label for="heiioncall-trigger-id" class="form-label">{{ $t("Trigger ID") }}<span
            style="color: red;"
        ><sup>*</sup></span></label>
        <HiddenInput
            id="heiioncall-trigger-id" v-model="$parent.notification.heiiOnCallTriggerId" required="true"
            autocomplete="false"
        ></HiddenInput>
    </div>
    <div class="form-text">
        <i18n-t tag="p" keypath="wayToGetHeiiOnCallDetails" style="margin-top: 8px;">
            <a href="https://heiioncall.com/docs" target="_blank">Heii On-Call Documentation</a>
        </i18n-t>
    </div>
</template>

<script>
import HiddenInput from "../HiddenInput.vue";
export default {
    components: {
        HiddenInput,
    },
};
</script>


Review comment (suggestion):
If this is translated this way, we help our translators with more context as they now can use `{documentation}` in the translation instead of `{0}`

```suggestion
            <template #documentation>
                <a href="https://heiioncall.com/docs" target="_blank">Heii On-Call Documentation</a>
            </template>
```

Code after:
<template>
    <div class="mb-3">
        <label for="heiioncall-apikey" class="form-label">{{ $t("API Key") }}<span
            style="color: red;"
        ><sup>*</sup></span></label>
        <HiddenInput
            id="heiioncall-apikey" v-model="$parent.notification.heiiOnCallApiKey" required="true"
            autocomplete="false"
        ></HiddenInput>
    </div>
    <div class="mb-3">
        <label for="heiioncall-trigger-id" class="form-label">Trigger ID<span
            style="color: red;"
        ><sup>*</sup></span></label>
        <HiddenInput
            id="heiioncall-trigger-id" v-model="$parent.notification.heiiOnCallTriggerId" required="true"
            autocomplete="false"
        ></HiddenInput>
    </div>
    <i18n-t tag="p" keypath="wayToGetHeiiOnCallDetails" class="form-text mt-3">
        <template #documentation>
            <a href="https://heiioncall.com/docs" target="_blank">{{ $t("documentationOf", ["Heii On-Call"]) }}</a>
        </template>
    </i18n-t>
</template>

<script>
import HiddenInput from "../HiddenInput.vue";
export default {
    components: {
        HiddenInput,
    },
};
</script>