Compare commits

...

6 commits

Author SHA1 Message Date
Pargorn.Ru
19d19cab98 fix ESLint issues in OneChat.vue 2025-01-25 16:33:02 +07:00
Pargorn.Ru
401d74cacc Use HiddenInput for secret values and clarify Access Token 2025-01-25 16:28:34 +07:00
Pargorn Ruasijan
46e3daef26
Update server/notification-providers/onechat.js
Co-authored-by: Frank Elsinga <frank@elsinga.de>
2025-01-25 15:58:40 +07:00
Pargorn Ruasijan
e3aaceef3f
Update server/notification-providers/onechat.js
Co-authored-by: Frank Elsinga <frank@elsinga.de>
2025-01-25 15:58:30 +07:00
Pargorn Ruasijan
89a2ae8e91
Update server/notification-providers/onechat.js
Co-authored-by: Frank Elsinga <frank@elsinga.de>
2025-01-25 15:50:57 +07:00
Pargorn.Ru
28f4fb233f remove comments 2025-01-25 15:39:32 +07:00
2 changed files with 26 additions and 32 deletions

View file

@ -19,7 +19,6 @@ class OneChat extends NotificationProvider {
Authorization: "Bearer " + notification.accessToken,
},
};
// Send a test message if the monitor is null
if (heartbeatJSON == null) {
const testMessage = {
to: notification.recieverId,
@ -34,17 +33,11 @@ class OneChat extends NotificationProvider {
bot_id: notification.botId,
type: "text",
message:
"UptimeKuma Alert:\n" +
"[🔴 Down]\n" +
"Name: " +
monitorJSON["name"] +
"\n" +
heartbeatJSON["msg"] +
"\n" +
"Time (" +
heartbeatJSON["timezone"] +
"): " +
heartbeatJSON["localDateTime"],
`UptimeKuma Alert:
[🔴 Down]
Name: ${monitorJSON["name"]}
${heartbeatJSON["msg"]}
Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`,
};
await axios.post(url, downMessage, config);
} else if (heartbeatJSON["status"] === UP) {
@ -53,17 +46,11 @@ class OneChat extends NotificationProvider {
bot_id: notification.botId,
type: "text",
message:
"UptimeKuma Alert:\n" +
"[🟢 Up]\n" +
"Name: " +
monitorJSON["name"] +
"\n" +
heartbeatJSON["msg"] +
"\n" +
"Time (" +
heartbeatJSON["timezone"] +
"): " +
heartbeatJSON["localDateTime"],
`UptimeKuma Alert:
[🟢 Up]
Name: ${monitorJSON["name"]}
${heartbeatJSON["msg"]}
Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`,
};
await axios.post(url, upMessage, config);
}
@ -77,9 +64,7 @@ class OneChat extends NotificationProvider {
"Unknown API error occurred.";
throw new Error(`OneChat API Error: ${errorMessage}`);
} else {
throw new Error(
`Network or unexpected error: ${error.message}`
);
this.throwGeneralAxiosError(error);
}
}
}

View file

@ -3,15 +3,14 @@
<!-- Access Token Input -->
<div class="mb-3">
<label for="onechat-access-token" class="form-label">
Access Token<span style="color: red;"><sup>*</sup></span>
OneChat Access Token<span style="color: red;"><sup>*</sup></span>
</label>
<input
<HiddenInput
id="onechat-access-token"
v-model="$parent.notification.accessToken"
type="text"
class="form-control"
required
/>
:required="true"
>
</HiddenInput>
<div class="form-text">
<p>{{ $t("OneChatAccessToken") }}</p>
</div>
@ -53,3 +52,13 @@
</div>
</div>
</template>
<script>
import HiddenInput from "../HiddenInput.vue";
export default {
components: {
HiddenInput,
},
};
</script>