mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-07-18 23:34:04 +02:00
Merge 5f19620595
into 2fd4e1cc72
This commit is contained in:
commit
1057fc5599
3 changed files with 42 additions and 9 deletions
|
@ -17,14 +17,24 @@ class SerwerSMS extends NotificationProvider {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let data = {
|
let data = {
|
||||||
"username": notification.serwersmsUsername,
|
"username": notification.serwersmsUsername,
|
||||||
"password": notification.serwersmsPassword,
|
"password": notification.serwersmsPassword,
|
||||||
"phone": notification.serwersmsPhoneNumber,
|
"text": msg.replace(/[^\x00-\x7F]/g, ""), // SerwerSMS may not support special characters without UTF-8 encoding
|
||||||
"text": msg.replace(/[^\x00-\x7F]/g, ""),
|
|
||||||
"sender": notification.serwersmsSenderName,
|
"sender": notification.serwersmsSenderName,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// **CHANGED:** Now uses notification.destinationType and notification.destinationValue directly
|
||||||
|
if (notification.destinationType === "group") {
|
||||||
|
data.group_id = notification.destinationValue;
|
||||||
|
} else if (notification.destinationType === "phone") {
|
||||||
|
data.phone = notification.destinationValue;
|
||||||
|
} else {
|
||||||
|
// Throws an error if recipient type is not defined or invalid
|
||||||
|
throw new Error("SerwerSMS: Recipient type (phone number or group ID) must be defined.");
|
||||||
|
}
|
||||||
|
|
||||||
let resp = await axios.post(url, data, config);
|
let resp = await axios.post(url, data, config);
|
||||||
|
|
||||||
if (!resp.data.success) {
|
if (!resp.data.success) {
|
||||||
|
@ -32,8 +42,7 @@ class SerwerSMS extends NotificationProvider {
|
||||||
let error = `SerwerSMS.pl API returned error code ${resp.data.error.code} (${resp.data.error.type}) with error message: ${resp.data.error.message}`;
|
let error = `SerwerSMS.pl API returned error code ${resp.data.error.code} (${resp.data.error.type}) with error message: ${resp.data.error.message}`;
|
||||||
this.throwGeneralAxiosError(error);
|
this.throwGeneralAxiosError(error);
|
||||||
} else {
|
} else {
|
||||||
let error = "SerwerSMS.pl API returned an unexpected response";
|
this.throwGeneralAxiosError("SerwerSMS.pl API returned an unexpected response");
|
||||||
this.throwGeneralAxiosError(error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,14 +3,34 @@
|
||||||
<label for="serwersms-username" class="form-label">{{ $t('serwersmsAPIUser') }}</label>
|
<label for="serwersms-username" class="form-label">{{ $t('serwersmsAPIUser') }}</label>
|
||||||
<input id="serwersms-username" v-model="$parent.notification.serwersmsUsername" type="text" class="form-control" required>
|
<input id="serwersms-username" v-model="$parent.notification.serwersmsUsername" type="text" class="form-control" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="serwersms-key" class="form-label">{{ $t('serwersmsAPIPassword') }}</label>
|
<label for="serwersms-key" class="form-label">{{ $t('serwersmsAPIPassword') }}</label>
|
||||||
<HiddenInput id="serwersms-key" v-model="$parent.notification.serwersmsPassword" :required="true" autocomplete="new-password"></HiddenInput>
|
<HiddenInput id="serwersms-key" v-model="$parent.notification.serwersmsPassword" :required="true" autocomplete="new-password"></HiddenInput>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="serwersms-phone-number" class="form-label">{{ $t("serwersmsPhoneNumber") }}</label>
|
<label class="form-label">{{ $t("serwersmsDestinationType") }}</label><br>
|
||||||
<input id="serwersms-phone-number" v-model="$parent.notification.serwersmsPhoneNumber" type="text" class="form-control" required>
|
<div class="form-check form-check-inline">
|
||||||
|
<input id="dest-phone" v-model="$parent.notification.destinationType" type="radio" class="form-check-input" value="phone" required>
|
||||||
|
<label class="form-check-label" for="dest-phone">{{ $t("serwersmsPhoneNumber") }}</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-check form-check-inline">
|
||||||
|
<input id="dest-group" v-model="$parent.notification.destinationType" type="radio" class="form-check-input" value="group">
|
||||||
|
<label class="form-check-label" for="dest-group">{{ $t("serwersmsGroupId") }}</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="serwersms-destination-value" class="form-label">
|
||||||
|
{{ $t($parent.notification.destinationType === 'group' ? 'serwersmsGroupId' : 'serwersmsPhoneNumber') }}
|
||||||
|
</label>
|
||||||
|
<input id="serwersms-destination-value" v-model="$parent.notification.destinationValue" type="text" class="form-control" required>
|
||||||
|
<div v-if="$parent.notification.destinationType === 'group'" class="form-text">{{ $t("serwersmsGroupIdHelp") }}</div>
|
||||||
|
<div v-else class="form-text">{{ $t("serwersmsPhoneHelp") }}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="serwersms-sender-name" class="form-label">{{ $t("serwersmsSenderName") }}</label>
|
<label for="serwersms-sender-name" class="form-label">{{ $t("serwersmsSenderName") }}</label>
|
||||||
<input id="serwersms-sender-name" v-model="$parent.notification.serwersmsSenderName" type="text" minlength="3" maxlength="11" class="form-control">
|
<input id="serwersms-sender-name" v-model="$parent.notification.serwersmsSenderName" type="text" minlength="3" maxlength="11" class="form-control">
|
||||||
|
|
|
@ -756,10 +756,14 @@
|
||||||
"alertaApiKey": "API Key",
|
"alertaApiKey": "API Key",
|
||||||
"alertaAlertState": "Alert State",
|
"alertaAlertState": "Alert State",
|
||||||
"alertaRecoverState": "Recover State",
|
"alertaRecoverState": "Recover State",
|
||||||
"serwersmsAPIUser": "API Username (incl. webapi_ prefix)",
|
"serwersmsAPIUser": "API username (including the webapi_ prefix)",
|
||||||
"serwersmsAPIPassword": "API Password",
|
"serwersmsAPIPassword": "API password",
|
||||||
"serwersmsPhoneNumber": "Phone number",
|
"serwersmsPhoneNumber": "Phone number",
|
||||||
"serwersmsSenderName": "SMS Sender Name (registered via customer portal)",
|
"serwersmsSenderName": "SMS sender name (registered via the client portal)",
|
||||||
|
"serwersmsGroupId": "Group ID",
|
||||||
|
"serwersmsGroupIdHelp": "Enter the GROUP ID (group_id from the SerwerSMS panel)",
|
||||||
|
"serwersmsDestinationType": "Recipient type",
|
||||||
|
"serwersmsPhoneHelp": "Enter the phone number, e.g., +48123456789.",
|
||||||
"smseagleTo": "Phone number(s)",
|
"smseagleTo": "Phone number(s)",
|
||||||
"smseagleGroup": "Phonebook group name(s)",
|
"smseagleGroup": "Phonebook group name(s)",
|
||||||
"smseagleContact": "Phonebook contact name(s)",
|
"smseagleContact": "Phonebook contact name(s)",
|
||||||
|
|
Loading…
Add table
Reference in a new issue