mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-13 08:17:03 +00:00
feat: Templating and plaintext for Google Workspace Notification Provider (#6048)
Some checks failed
Auto Test / armv7-simple-test (18, ARMv7) (push) Has been cancelled
Auto Test / armv7-simple-test (20, ARMv7) (push) Has been cancelled
Auto Test / check-linters (push) Has been cancelled
Auto Test / e2e-test (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
Merge Conflict Labeler / Labeling (push) Has been cancelled
validate / json-yaml-validate (push) Has been cancelled
validate / validate (push) Has been cancelled
Auto Test / auto-test (18, ARM64) (push) Has been cancelled
Auto Test / auto-test (18, macos-latest) (push) Has been cancelled
Auto Test / auto-test (18, ubuntu-latest) (push) Has been cancelled
Auto Test / auto-test (18, windows-latest) (push) Has been cancelled
Auto Test / auto-test (20, ARM64) (push) Has been cancelled
Auto Test / auto-test (20, macos-latest) (push) Has been cancelled
Auto Test / auto-test (20, ubuntu-latest) (push) Has been cancelled
Auto Test / auto-test (20, windows-latest) (push) Has been cancelled
Some checks failed
Auto Test / armv7-simple-test (18, ARMv7) (push) Has been cancelled
Auto Test / armv7-simple-test (20, ARMv7) (push) Has been cancelled
Auto Test / check-linters (push) Has been cancelled
Auto Test / e2e-test (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
Merge Conflict Labeler / Labeling (push) Has been cancelled
validate / json-yaml-validate (push) Has been cancelled
validate / validate (push) Has been cancelled
Auto Test / auto-test (18, ARM64) (push) Has been cancelled
Auto Test / auto-test (18, macos-latest) (push) Has been cancelled
Auto Test / auto-test (18, ubuntu-latest) (push) Has been cancelled
Auto Test / auto-test (18, windows-latest) (push) Has been cancelled
Auto Test / auto-test (20, ARM64) (push) Has been cancelled
Auto Test / auto-test (20, macos-latest) (push) Has been cancelled
Auto Test / auto-test (20, ubuntu-latest) (push) Has been cancelled
Auto Test / auto-test (20, windows-latest) (push) Has been cancelled
Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
parent
f027ce309e
commit
4f944cd869
3 changed files with 50 additions and 1 deletions
|
@ -14,6 +14,18 @@ class GoogleChat extends NotificationProvider {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Google Chat message formatting: https://developers.google.com/chat/api/guides/message-formats/basic
|
// Google Chat message formatting: https://developers.google.com/chat/api/guides/message-formats/basic
|
||||||
|
if (notification.googleChatUseTemplate && notification.googleChatTemplate) {
|
||||||
|
// Send message using template
|
||||||
|
const renderedText = await this.renderTemplate(
|
||||||
|
notification.googleChatTemplate,
|
||||||
|
msg,
|
||||||
|
monitorJSON,
|
||||||
|
heartbeatJSON
|
||||||
|
);
|
||||||
|
const data = { "text": renderedText };
|
||||||
|
await axios.post(notification.googleChatWebhookURL, data);
|
||||||
|
return okMsg;
|
||||||
|
}
|
||||||
|
|
||||||
let chatHeader = {
|
let chatHeader = {
|
||||||
title: "Uptime Kuma Alert",
|
title: "Uptime Kuma Alert",
|
||||||
|
@ -88,7 +100,6 @@ class GoogleChat extends NotificationProvider {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.throwGeneralAxiosError(error);
|
this.throwGeneralAxiosError(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,4 +10,40 @@
|
||||||
</i18n-t>
|
</i18n-t>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<div class="form-check form-switch">
|
||||||
|
<input id="google-chat-use-template" v-model="$parent.notification.googleChatUseTemplate" type="checkbox" class="form-check-input">
|
||||||
|
<label for="google-chat-use-template" class="form-check-label"> {{ $t("Template plain text instead of using cards") }} </label>
|
||||||
|
<i18n-t tag="p" class="form-text" keypath="issueWithGoogleChatOnAndroidHelptext">
|
||||||
|
<template #issuetackerURL>
|
||||||
|
<a href="https://issuetracker.google.com/issues/283746283" target="_blank">issuetracker.google.com/issues/283746283</a>
|
||||||
</template>
|
</template>
|
||||||
|
</i18n-t>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template v-if="$parent.notification.googleChatUseTemplate">
|
||||||
|
<div class="mb-3">
|
||||||
|
<TemplatedTextarea id="google-chat-template" v-model="$parent.notification.googleChatTemplate" :required="true" :placeholder="googleChatTemplatePlaceholder" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import TemplatedTextarea from "../TemplatedTextarea.vue";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "GoogleChat",
|
||||||
|
components: {
|
||||||
|
TemplatedTextarea,
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
googleChatTemplatePlaceholder() {
|
||||||
|
return this.$t("Example:", [
|
||||||
|
"{{ name }} - {{ msg }}{% if hostnameOrURL %} ({{ hostnameOrURL }}){% endif %}"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
|
@ -645,6 +645,8 @@
|
||||||
"pushyToken": "Device token",
|
"pushyToken": "Device token",
|
||||||
"apprise": "Apprise (Support 50+ Notification services)",
|
"apprise": "Apprise (Support 50+ Notification services)",
|
||||||
"GoogleChat": "Google Chat (Google Workspace only)",
|
"GoogleChat": "Google Chat (Google Workspace only)",
|
||||||
|
"Template plain text instead of using cards": "Template plain text instead of using cards",
|
||||||
|
"issueWithGoogleChatOnAndroidHelptext": "This also allows to get around bugs upstream like {issuetackerURL}",
|
||||||
"wayToGetKookBotToken": "Create application and get your bot token at {0}",
|
"wayToGetKookBotToken": "Create application and get your bot token at {0}",
|
||||||
"wayToGetKookGuildID": "Switch on 'Developer Mode' in Kook setting, and right click the guild to get its ID",
|
"wayToGetKookGuildID": "Switch on 'Developer Mode' in Kook setting, and right click the guild to get its ID",
|
||||||
"Guild ID": "Guild ID",
|
"Guild ID": "Guild ID",
|
||||||
|
|
Loading…
Add table
Reference in a new issue