Skip to content

Commit

Permalink
fix: 修复微信无法推送问题
Browse files Browse the repository at this point in the history
  • Loading branch information
monyuan committed Jan 4, 2024
1 parent ec37d4a commit 994f34d
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 7 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

当有新评论、新文章、等待审核的评论、等待审核的文章时将消息推送到微信、企业微信、飞书、钉钉等12个应用

目前还没上架Halo商店,可以在 [Releases](https://github.com/monyuan/notify-me/releases) 页面直接下载

- 使用了AnPush推送服务,有免费额度,个人博客够用
- 不够用可以多注册几个账号薅羊毛,但是不建议,多支持下开发者

Expand All @@ -15,6 +13,10 @@
- API密钥 [在这里获取](https://anpush.com/ApPush)
- 通道ID [在这里获取](https://anpush.com/ApChannel)

**注意**
如果你用的是微信公众号通道,请一定要勾选这个选项,其他通道不要勾选!
![](https://s2.loli.net/2024/01/04/lDP8N7ejEkv2zfs.png)

没用过AnPush建议看看官网帮助,通过ID和API密钥不要填错了


Expand All @@ -28,4 +30,4 @@

![](https://s2.loli.net/2024/01/03/cV34nAKt8oxUTEh.png)

然后保存就行了
然后保存就行了
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=1.0.1
version=1.0.2
#org.gradle.java.home=/Users/mon/Library/Java/JavaVirtualMachines/corretto-17.0.9/Contents/Home
3 changes: 3 additions & 0 deletions src/main/java/org/xiqi/notifyme/domain/NotifyMe.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public class NotifyMe extends AbstractExtension {
@Schema(defaultValue = "false")
private Boolean status; // 通知总开关

@Schema(defaultValue = "false")
private Boolean wechatStatus; // 微信标记

@Schema(defaultValue = "true")
private Boolean commentStatus; // 评论通知开关

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ public void process(NotifyBaseEvent event, NotifyMe setting) {
}

private void publish(Post post, NotifyMe setting, Comment.CommentSpec commentSpec) { // 评论发布通知
String title = String.format("《%s》上有新评论发布", post.getSpec().getTitle());
if (setting.getCommentStatus()) {
String title = String.format("《%s》上有新评论", post.getSpec().getTitle());
if (setting.getWechatStatus()) {
title = "你有新评论"; // 微信模板消息anpush做了限制,不能太长
}
String content = String.format("%s说: %s \n\n[查看评论](%s)",
commentSpec.getOwner().getDisplayName(),
commentSpec.getContent(),
Expand All @@ -51,6 +54,9 @@ private void publish(Post post, NotifyMe setting, Comment.CommentSpec commentSpe
private void audits(Post post, NotifyMe setting, Comment.CommentSpec commentSpec) { // 评论审核通知
if (setting.getCommentAuditsStatus()) {
String title = String.format("《%s》上有新评论等待审核", post.getSpec().getTitle());
if (setting.getWechatStatus()) {
title = "新评论待审核"; // 微信模板消息anpush做了限制,不能太长
}
String content = String.format("%s说: %s \n\n[现在去审核](%s)",
commentSpec.getOwner().getDisplayName(),
commentSpec.getContent(),
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/xiqi/notifyme/strategy/PostStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private void publish(Post post, NotifyMe setting) { // 文章发布通知

private void audits(Post post, NotifyMe setting) { // 文章审核通知
if (setting.getPostAuditsStatus()) {
String title = "有新文章等待审核: " + post.getSpec().getTitle();
String title = "有新文章待审核: " + post.getSpec().getTitle();
String content = "您的站点有新文文章等待审核,\n\n " + String.format("[立刻审核](%s)",
setting.getSiteUrl() + "/console/posts");
push(title, content, setting);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ spec:
logo: /notify.png
homepage: https://github.com/monyuan/notify-me
displayName: "通知我"
description: "当有评论时推送通知到微信、企业微信、飞书、钉钉、微信测试号、Slack等12个应用,使用了AnPush服务。"
description: "当有评论时、新闻章时推送通知到微信、企业微信、飞书、钉钉、微信测试号、Slack等12个应用,使用了AnPush服务。"
license:
- name: "GPL-3.0"
url: "https://raw.githubusercontent.com/monyuan/notify-me/main/LICENSE"
23 changes: 23 additions & 0 deletions ui/src/views/HomeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default {
status: false,
commentStatus: false,
postStatus: false,
wechatStatus: false,
commentAuditsStatus: false,
postAuditsStatus: false,
apiVersion: "org.xiqi.notifyme/v1alpha1",
Expand Down Expand Up @@ -221,6 +222,28 @@ export default {
type="text" v-model="data.channel" placeholder="有多个就用英文逗号隔开"/>
</div>
</div>
<div
class="nm-title-container formkit-outer formkit-disabled:opacity-50 py-4 first:pt-0 last:pb-0 transition-all">
<div class="nm-checkbox-title">
<svg style="display: inline" viewBox="0 0 24 24" width="20px" height="20px">
<path fill="currentColor"
d="M12 2c5.52 0 10 4.48 10 10s-4.48 10-10 10S2 17.52 2 12S6.48 2 12 2Zm0 18c4.42 0 8-3.58 8-8s-3.58-8-8-8s-8 3.58-8 8s3.58 8 8 8Zm1-8v4h-2v-4H8l4-4l4 4h-3Z">
</path>
</svg>
<span class="icon-title">通道是否是微信公众号</span>
<div style="font-size: 13px;font-weight: normal;color: #8077a4;padding: 5px">
❗️ 如果你用的通道是微信公众号一定要勾选[其他的不要勾选],因为微信公众号的模板消息标题长度固定,超出长度无法发送!
</div>
</div>
<div style="padding: 10px"
class="formkit-inner inline-flex items-center w-full relative box-border border border-gray-300 formkit-invalid:border-red-500 h-9 rounded-base overflow-hidden focus-within:border-primary focus-within:shadow-sm sm:max-w-lg transition-all">
<input class="toggle-all" type="checkbox" :checked="data.wechatStatus"
v-model="data.wechatStatus"/>
<label for="toggle-all"><span class="nm-checkbox-text"
style="font-size: 14px;color: red;vertical-align: 1px">
是</span></label>
</div>
</div>
<div
class="nm-title-container formkit-outer formkit-disabled:opacity-50 py-4 first:pt-0 last:pb-0 transition-all">
<div class="nm-checkbox-title">
Expand Down

0 comments on commit 994f34d

Please sign in to comment.