Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Better WeCom notification #3491

Closed
wants to merge 8 commits into from
Closed

feat: Better WeCom notification #3491

wants to merge 8 commits into from

Conversation

KeJunMao
Copy link

⚠️⚠️⚠️ Since we do not accept all types of pull requests and do not want to waste your time. Please be sure that you have read pull request rules:
https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md#can-i-create-a-pull-request-for-uptime-kuma

Tick the checkbox if you understand [x]:

  • I have read and understand the pull request rules.

Description

Fixes #3145

Type of change

Please delete any options that are not relevant.

  • New feature (non-breaking change which adds functionality)

Checklist

  • My code follows the style guidelines of this project
  • I ran ESLint and other linters for modified files
  • I have performed a self-review of my own code and tested it
  • I have commented my code, particularly in hard-to-understand areas
    (including JSDoc for methods)
  • My changes generate no new warnings
  • My code needed automated testing. I have added them (this is optional task)

Screenshots (if any)

Please do not use any external image service. Instead, just paste in or drag and drop the image here, and it will be uploaded automatically.

see #3145

server/notification-providers/wecom.js Outdated Show resolved Hide resolved
server/notification-providers/wecom.js Outdated Show resolved Hide resolved
server/notification-providers/wecom.js Outdated Show resolved Hide resolved
Comment on lines +58 to +59
// fallback address
if (!clientUrl) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use if-else insead

}
break;
default:
address = monitorJSON["url"];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"url" is not a guaranteed parameter.
=> Please handle cases where no monitor exist like the docker monitor.
See #3327 for a bug report resulting from this handling

server/notification-providers/wecom.js Outdated Show resolved Hide resolved
let clientUrl = "";

//#region computed address and clientUrl
switch (monitorJSON["type"]) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please extract this switch to another method for readability

server/notification-providers/wecom.js Outdated Show resolved Hide resolved
await axios.post(
WeComUrl,
{
msgtype: "text",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing it like this means that for testing, users will receive a message which is very differently formatted from what they will receive when they get an actual alert
=> Not sure if this is intentional

card_type: "text_notice",
main_title: {
title: monitorJSON["name"],
desc: monitorJSON["type"] === "push" ? "Heartbeat" : address,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What?
In case of a push-monitor, this is set as "Heartbeat"?

KeJunMao and others added 7 commits July 27, 2023 22:37
Co-authored-by: Frank Elsinga <frank@elsinga.de>
Co-authored-by: Frank Elsinga <frank@elsinga.de>
Co-authored-by: Frank Elsinga <frank@elsinga.de>
Co-authored-by: Frank Elsinga <frank@elsinga.de>
Co-authored-by: Frank Elsinga <frank@elsinga.de>
Co-authored-by: Frank Elsinga <frank@elsinga.de>
Co-authored-by: Frank Elsinga <frank@elsinga.de>
@KeJunMao KeJunMao closed this Jul 27, 2023
@KeJunMao
Copy link
Author

Sorry, I will organize the code and open a new PR

@CommanderStorm
Copy link
Collaborator

CommanderStorm commented Jul 27, 2023

No need to open a new PR, you can just mark this PR as a draft and comment once done ^^
The changes I requested were not bad ones (just edge cases that were missed and some code-quality things) ⇒ no structural defects requiring a new attempt…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better Enterprise WeCom Notifications 更好的企业微信通知
2 participants