This commit is contained in:
miesiu 2025-07-18 11:22:40 +00:00 committed by GitHub
commit 1057fc5599
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 42 additions and 9 deletions

View file

@ -17,14 +17,24 @@ class SerwerSMS extends NotificationProvider {
"Content-Type": "application/json",
}
};
let data = {
"username": notification.serwersmsUsername,
"password": notification.serwersmsPassword,
"phone": notification.serwersmsPhoneNumber,
"text": msg.replace(/[^\x00-\x7F]/g, ""),
"text": msg.replace(/[^\x00-\x7F]/g, ""), // SerwerSMS may not support special characters without UTF-8 encoding
"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);
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}`;
this.throwGeneralAxiosError(error);
} else {
let error = "SerwerSMS.pl API returned an unexpected response";
this.throwGeneralAxiosError(error);
this.throwGeneralAxiosError("SerwerSMS.pl API returned an unexpected response");
}
}

View file

@ -3,14 +3,34 @@
<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>
</div>
<div class="mb-3">
<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>
</div>
<div class="mb-3">
<label for="serwersms-phone-number" class="form-label">{{ $t("serwersmsPhoneNumber") }}</label>
<input id="serwersms-phone-number" v-model="$parent.notification.serwersmsPhoneNumber" type="text" class="form-control" required>
<label class="form-label">{{ $t("serwersmsDestinationType") }}</label><br>
<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 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">
<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">

View file

@ -756,10 +756,14 @@
"alertaApiKey": "API Key",
"alertaAlertState": "Alert State",
"alertaRecoverState": "Recover State",
"serwersmsAPIUser": "API Username (incl. webapi_ prefix)",
"serwersmsAPIPassword": "API Password",
"serwersmsAPIUser": "API username (including the webapi_ prefix)",
"serwersmsAPIPassword": "API password",
"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)",
"smseagleGroup": "Phonebook group name(s)",
"smseagleContact": "Phonebook contact name(s)",