Skip to content
Open
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
0a136a1
feat
gongfuture Apr 27, 2026
824359c
Merge commit '1cab3ac75c30283f9ca7dbb725e43debd8bf90be' into feat/not…
gongfuture Apr 27, 2026
530c4b3
fix issues
gongfuture Apr 27, 2026
6240ca6
fix backend isues
gongfuture Apr 27, 2026
85a1bc8
add to credit
gongfuture Apr 27, 2026
047bc4c
fallback config == null检查
gongfuture Apr 27, 2026
b21a590
fix
gongfuture Apr 27, 2026
f99b105
fix url encode issue
gongfuture Apr 27, 2026
3681487
fix
gongfuture Apr 27, 2026
48f1d04
这怎么多个分号
gongfuture Apr 27, 2026
bdeaff2
perf
gongfuture Apr 28, 2026
60b1f49
get不显示body_template
gongfuture Apr 28, 2026
83bb4cb
大小写统一
gongfuture Apr 28, 2026
636b6c2
换成灰色
gongfuture May 9, 2026
f126a6d
自定义请求头添加按钮修改
gongfuture May 9, 2026
a6cd80e
多项refactor
gongfuture May 12, 2026
1d86506
格式修复
gongfuture May 12, 2026
7b3a099
feat: 增加level参数支持
gongfuture May 14, 2026
dd94aa0
small fix
gongfuture May 14, 2026
eaaa274
Merge commit 'ee60707af7b8355d3a93c1781be65f93e4437161' into feat/not…
gongfuture Jul 1, 2026
b83e86d
修正header问题
gongfuture Jul 10, 2026
0be65d2
lint
gongfuture Jul 10, 2026
c49fd3c
Merge remote-tracking branch 'upstream/dev' into feat/notification/we…
gongfuture Jul 10, 2026
38e8fe9
调整了一下顺序
gongfuture Jul 10, 2026
2f1bd83
ntfy 图标网址常量化
gongfuture Jul 10, 2026
2cf895a
过长表单的修复一不小心被回退了,重新加回去
gongfuture Jul 10, 2026
2b33c43
lint
gongfuture Jul 11, 2026
5986af1
Merge remote-tracking branch 'upstream/dev' into feat/notification/we…
gongfuture Jul 20, 2026
b888bd7
清理过时翻译字段
gongfuture Aug 3, 2026
19ff85f
修正校验
gongfuture Aug 5, 2026
4c80d82
rfc 8187 编码
gongfuture Aug 5, 2026
f0d66c4
fix
gongfuture Aug 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void publishAlert(boolean push, @NotNull AlertLevel level, @NotNull Strin
alertEntity.setCreateAt(OffsetDateTime.now());
alertDao.saveOrUpdate(alertEntity);
if (push) {
if (!pushManager.pushMessage("[PeerBanHelper/" + level.name() + "] " + tlUI(title), tlUI(content))) {
if (!pushManager.pushMessage("[PeerBanHelper/" + level.name() + "] " + tlUI(title), tlUI(content), level)) {
log.error(tlUI(Lang.UNABLE_TO_PUSH_ALERT_VIA_PROVIDERS));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ghostchu.peerbanhelper.module.impl.webapi;

import com.ghostchu.peerbanhelper.alert.AlertLevel;
import com.ghostchu.peerbanhelper.module.AbstractFeatureModule;
import com.ghostchu.peerbanhelper.module.impl.webapi.dto.PushWrapperDTO;
import com.ghostchu.peerbanhelper.text.Lang;
Expand Down Expand Up @@ -135,7 +136,7 @@ private void handlePushProviderTest(Context ctx) {
return;
}
try {
var testResult = pushProvider.push(tl(locale(ctx), Lang.PUSH_PROVIDER_TEST_TITLE), tl(locale(ctx), Lang.PUSH_PROVIDER_TEST_DESCRIPTION, name, pushProvider.getConfigType()));
var testResult = pushProvider.push(tl(locale(ctx), Lang.PUSH_PROVIDER_TEST_TITLE), tl(locale(ctx), Lang.PUSH_PROVIDER_TEST_DESCRIPTION, name, pushProvider.getConfigType()), AlertLevel.INFO);
if (testResult) {
ctx.json(new StdResp(true, tl(locale(ctx), Lang.PUSH_PROVIDER_API_TEST_OK), null));
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ghostchu.peerbanhelper.util.push;

import com.ghostchu.peerbanhelper.alert.AlertLevel;
import com.google.gson.JsonObject;
import org.bspfsystems.yamlconfiguration.configuration.ConfigurationSection;

Expand All @@ -16,7 +17,7 @@ public interface PushManager {

void savePushProviders() throws IOException;

boolean pushMessage(String title, String description);
boolean pushMessage(String title, String description, AlertLevel level);

java.util.List<PushProvider> getProviderList();
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ghostchu.peerbanhelper.util.push;

import com.ghostchu.peerbanhelper.Main;
import com.ghostchu.peerbanhelper.alert.AlertLevel;
import com.ghostchu.peerbanhelper.text.Lang;
import com.ghostchu.peerbanhelper.util.HTTPUtil;
import com.ghostchu.peerbanhelper.util.push.impl.*;
Expand Down Expand Up @@ -47,6 +48,8 @@ public PushProvider createPushProvider(String name, String type, ConfigurationSe
case "pushdeer" -> provider = PushDeerPushProvider.loadFromYaml(name, section, httpUtil);
case "gotify" -> provider = GotifyPushProvider.loadFromYaml(name, section, httpUtil);
case "ntfy" -> provider = NtfyPushProvider.loadFromYaml(name, section, httpUtil);
case "webhook" -> provider = WebhookPushProvider.loadFromYaml(name, section, httpUtil);
default -> provider = null;
Comment thread
gongfuture marked this conversation as resolved.
}
return provider;
}
Expand All @@ -63,6 +66,8 @@ public PushProvider createPushProvider(String name, String type, JsonObject json
case "pushdeer" -> provider = PushDeerPushProvider.loadFromJson(name, jsonObject, httpUtil);
case "gotify" -> provider = GotifyPushProvider.loadFromJson(name, jsonObject, httpUtil);
case "ntfy" -> provider = NtfyPushProvider.loadFromJson(name, jsonObject, httpUtil);
case "webhook" -> provider = WebhookPushProvider.loadFromJson(name, jsonObject, httpUtil);
default -> provider = null;
}
return provider;
}
Expand Down Expand Up @@ -104,11 +109,11 @@ public void savePushProviders() throws IOException {
}

@Override
public boolean pushMessage(String title, String description) {
public boolean pushMessage(String title, String description, AlertLevel level) {
AtomicBoolean anySuccess = new AtomicBoolean(false);
providerList.forEach(pushProvider -> {
try {
if (pushProvider.push(title, description)) {
if (pushProvider.push(title, description, level)) {
anySuccess.set(true);
}
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ghostchu.peerbanhelper.util.push;

import com.ghostchu.peerbanhelper.alert.AlertLevel;
import com.google.gson.JsonObject;
import org.bspfsystems.yamlconfiguration.configuration.ConfigurationSection;

Expand All @@ -11,7 +12,7 @@ public interface PushProvider {
JsonObject saveJson();

ConfigurationSection saveYaml();

boolean push(String title, String content);
boolean push(String title, String content, AlertLevel level);

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ghostchu.peerbanhelper.util.push.impl;

import com.ghostchu.peerbanhelper.alert.AlertLevel;
import com.ghostchu.peerbanhelper.util.HTTPUtil;
import com.ghostchu.peerbanhelper.util.json.JsonUtil;
import com.ghostchu.peerbanhelper.util.push.AbstractPushProvider;
Expand Down Expand Up @@ -67,7 +68,7 @@ public static BarkPushProvider loadFromYaml(String name, ConfigurationSection se
}

@Override
public boolean push(String title, String content) {
public boolean push(String title, String content, AlertLevel level) {
Map<String, Object> map = new HashMap<>();
map.put("title", title);
map.put("body", content);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ghostchu.peerbanhelper.util.push.impl;

import com.ghostchu.peerbanhelper.alert.AlertLevel;
import com.ghostchu.peerbanhelper.util.HTTPUtil;
import com.ghostchu.peerbanhelper.util.json.JsonUtil;
import com.ghostchu.peerbanhelper.util.push.AbstractPushProvider;
Expand Down Expand Up @@ -64,7 +65,7 @@ public static GotifyPushProvider loadFromYaml(String name, ConfigurationSection
}

@Override
public boolean push(String title, String content) {
public boolean push(String title, String content, AlertLevel level) {
Map<String, Object> map = new HashMap<>();
map.put("title", title);
map.put("message", content);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ghostchu.peerbanhelper.util.push.impl;

import com.ghostchu.peerbanhelper.alert.AlertLevel;
import com.ghostchu.peerbanhelper.util.HTTPUtil;
import com.ghostchu.peerbanhelper.util.json.JsonUtil;
import com.ghostchu.peerbanhelper.util.push.AbstractPushProvider;
Expand All @@ -22,6 +23,7 @@ public final class NtfyPushProvider extends AbstractPushProvider {
private final Config config;
private final String name;
private final HTTPUtil httpUtil;
private static final String ICON_URL ="https://raw.githubusercontent.com/PBH-BTN/PeerBanHelper/refs/heads/master/src/main/resources/assets/icon.png";

public NtfyPushProvider(String name, Config config, HTTPUtil httpUtil) {
this.name = name;
Expand Down Expand Up @@ -71,7 +73,7 @@ public static NtfyPushProvider loadFromYaml(String name, ConfigurationSection se
}

@Override
public boolean push(String title, String content) {
public boolean push(String title, String content, AlertLevel level) {

RequestBody requestBody = RequestBody.create(
content,
Expand All @@ -85,7 +87,7 @@ public boolean push(String title, String content) {
.post(requestBody)
.header("Title", encodedTitle)
.header("Priority", String.valueOf(config.getPriority()))
.header("Icon", "https://raw.githubusercontent.com/PBH-BTN/PeerBanHelper/refs/heads/master/src/main/resources/assets/icon.png");
.header("Icon", ICON_URL);

if (config.getToken() != null && !config.getToken().isBlank()) {
builder.header("Authorization", "Bearer " + config.getToken());
Expand All @@ -105,6 +107,16 @@ public boolean push(String title, String content) {
return true;
}

private int mapLevelToPriority(AlertLevel level) {
return switch (level) {
case TIP -> 1;
case INFO -> 2;
case WARN -> 3;
case ERROR -> 4;
case FATAL -> 5;
};
}

@AllArgsConstructor
@Data
public static class Config {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ghostchu.peerbanhelper.util.push.impl;

import com.ghostchu.peerbanhelper.alert.AlertLevel;
import com.ghostchu.peerbanhelper.util.HTTPUtil;
import com.ghostchu.peerbanhelper.util.json.JsonUtil;
import com.ghostchu.peerbanhelper.util.push.AbstractPushProvider;
Expand Down Expand Up @@ -65,7 +66,7 @@ public static PushDeerPushProvider loadFromYaml(String name, ConfigurationSectio
}

@Override
public boolean push(String title, String content) {
public boolean push(String title, String content, AlertLevel level) {
Map<String, Object> map = new HashMap<>();
map.put("pushkey", config.getPushKey());
map.put("text", title);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ghostchu.peerbanhelper.util.push.impl;

import com.ghostchu.peerbanhelper.alert.AlertLevel;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.ghostchu.peerbanhelper.util.HTTPUtil;
import com.ghostchu.peerbanhelper.util.json.JsonUtil;
Expand Down Expand Up @@ -76,7 +77,7 @@ public String getConfigType() {
}

@Override
public boolean push(String title, String content) {
public boolean push(String title, String content, AlertLevel level) {
Map<String, Object> args = new HashMap<>() {{
put("token", config.getToken());
if (config.getTopic() != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ghostchu.peerbanhelper.util.push.impl;

import com.ghostchu.peerbanhelper.alert.AlertLevel;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.ghostchu.peerbanhelper.util.HTTPUtil;
import com.ghostchu.peerbanhelper.util.json.JsonUtil;
Expand Down Expand Up @@ -74,7 +75,7 @@ public static ServerChanPushProvider loadFromYaml(String name, ConfigurationSect
}

@Override
public boolean push(String title, String content) {
public boolean push(String title, String content, AlertLevel level) {
Map<String, Object> map = new HashMap<>();
map.put("title", title);
map.put("desp", content);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ghostchu.peerbanhelper.util.push.impl;

import com.ghostchu.peerbanhelper.alert.AlertLevel;
import com.ghostchu.peerbanhelper.util.json.JsonUtil;
import com.ghostchu.peerbanhelper.util.push.AbstractPushProvider;
import com.google.gson.JsonObject;
Expand Down Expand Up @@ -142,7 +143,7 @@ public String getConfigType() {
}

@Override
public boolean push(String title, String content) {
public boolean push(String title, String content, AlertLevel level) {
try {
sendMail(config.getReceivers(), title, content);
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ghostchu.peerbanhelper.util.push.impl;

import com.ghostchu.peerbanhelper.alert.AlertLevel;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.ghostchu.peerbanhelper.util.HTTPUtil;
import com.ghostchu.peerbanhelper.util.json.JsonUtil;
Expand Down Expand Up @@ -66,7 +67,7 @@ public ConfigurationSection saveYaml() {
}

@Override
public boolean push(String title, String content) {
public boolean push(String title, String content, AlertLevel level) {
String markdown = "*" + title + "*\n" + content;
Map<String, Object> map = new HashMap<>();
map.put("chat_id", config.getChatId());
Expand Down
Loading
Loading