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

Code before:
                let config = {
                    headers: {
                        "Content-Type": "application/x-www-form-urlencoded",
                    }
                };

                let sendMethod;
                let recipientType;
                let duration;
                let voiceId;

                if (notification.smseagleRecipientType === "smseagle-contact") {
                    recipientType = "contactname";
                    sendMethod = "/send_tocontact";
                } else if (notification.smseagleRecipientType === "smseagle-group") {
                    recipientType = "groupname";
                    sendMethod = "/send_togroup";
                } else if (notification.smseagleRecipientType === "smseagle-to") {
                    recipientType = "to";
                    sendMethod = "/send_sms";
                    if (notification.smseagleMsgType !== "smseagle-sms") {
                        if (notification.smseagleDuration) {
                            duration = notification.smseagleDuration;
                        } else {
                            duration = 10;
                        }

                        if (notification.smseagleMsgType === "smseagle-ring") {
                            sendMethod = "/ring_call";
                        } else if (notification.smseagleMsgType === "smseagle-tts") {
                            sendMethod = "/tts_call";
                        } else if (notification.smseagleMsgType === "smseagle-tts-advanced") {
                            sendMethod = "/tts_adv_call";
                            voiceId = notification.smseagleTtsModel ? notification.smseagleTtsModel : 1;
                        }
                    }
                }

                const url = new URL(notification.smseagleUrl + "/http_api" + sendMethod);

                url.searchParams.append("access_token", notification.smseagleToken);
                url.searchParams.append(recipientType, notification.smseagleRecipient);
                if (![ "smseagle-ring", "smseagle-tts", "smseagle-tts-advanced" ].includes(notification.smseagleRecipientType)) {
                    url.searchParams.append("unicode", (notification.smseagleEncoding) ? "1" : "0");
                    url.searchParams.append("highpriority", (notification.smseaglePriority) ? notification.smseaglePriority : "0");
                } else {
                    url.searchParams.append("duration", duration);
                }
                if (notification.smseagleRecipientType !== "smseagle-ring") {
                    url.searchParams.append("message", msg);
                }

Review comment (suggestion):
No need to clutter, lets just use nullish coalessing.
There are a bunch of cases where you do this

```suggestion
                        duration = notification.smseagleDuration ?? 10;
```

Code after:
                let config = {
                    headers: {
                        "Content-Type": "application/x-www-form-urlencoded",
                    }
                };

                let sendMethod;
                let recipientType;
                let duration;
                let voiceId;

                if (notification.smseagleRecipientType === "smseagle-contact") {
                    recipientType = "contactname";
                    sendMethod = "/send_tocontact";
                } else if (notification.smseagleRecipientType === "smseagle-group") {
                    recipientType = "groupname";
                    sendMethod = "/send_togroup";
                } else if (notification.smseagleRecipientType === "smseagle-to") {
                    recipientType = "to";
                    sendMethod = "/send_sms";
                    if (notification.smseagleMsgType !== "smseagle-sms") {
                        duration = notification.smseagleDuration ?? 10;

                        if (notification.smseagleMsgType === "smseagle-ring") {
                            sendMethod = "/ring_call";
                        } else if (notification.smseagleMsgType === "smseagle-tts") {
                            sendMethod = "/tts_call";
                        } else if (notification.smseagleMsgType === "smseagle-tts-advanced") {
                            sendMethod = "/tts_adv_call";
                            voiceId = notification.smseagleTtsModel ? notification.smseagleTtsModel : 1;
                        }
                    }
                }

                const url = new URL(notification.smseagleUrl + "/http_api" + sendMethod);

                url.searchParams.append("access_token", notification.smseagleToken);
                url.searchParams.append(recipientType, notification.smseagleRecipient);
                if (!notification.smseagleRecipientType || notification.smseagleRecipientType === "smseagle-sms") {
                    url.searchParams.append("unicode", (notification.smseagleEncoding) ? "1" : "0");
                    url.searchParams.append("highpriority", notification.smseaglePriority ?? "0");
                } else {
                    url.searchParams.append("duration", duration);
                }
                if (notification.smseagleRecipientType !== "smseagle-ring") {
                    url.searchParams.append("message", msg);
                }
                if (voiceId) {
                    url.searchParams.append("voice_id", voiceId);
                }