From a191f6d73ba57fe5c3b28fa80c390716f7a73f31 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 10 Jan 2025 02:26:28 +0000 Subject: [PATCH 01/20] Update dependency org.apache.james:apache-mime4j-storage to v0.8.12 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0be51f904..a8b398a47 100644 --- a/pom.xml +++ b/pom.xml @@ -425,7 +425,7 @@ org.apache.james apache-mime4j-storage - 0.8.11 + 0.8.12 commons-io From d5002657727ebb80f134ddad4946b300eb7d46f9 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 9 Jan 2025 22:46:01 +0000 Subject: [PATCH 02/20] Update dependency org.apache.james:apache-mime4j-dom to v0.8.12 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a8b398a47..44603216e 100644 --- a/pom.xml +++ b/pom.xml @@ -403,7 +403,7 @@ org.apache.james apache-mime4j-dom - 0.8.11 + 0.8.12 commons-io From 0c77cf222a65e1dd44d94f52786c2fd032630e87 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 9 Jan 2025 22:45:58 +0000 Subject: [PATCH 03/20] Update dependency org.apache.james:apache-mime4j-core to v0.8.12 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 44603216e..782104321 100644 --- a/pom.xml +++ b/pom.xml @@ -414,7 +414,7 @@ org.apache.james apache-mime4j-core - 0.8.11 + 0.8.12 commons-io From 90eefc1160d2c78b4ac08c986ce633151e2bdf9f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 10 Jan 2025 03:20:35 +0000 Subject: [PATCH 04/20] Update docker/build-push-action action to v6.11.0 --- .github/workflows/jvm-ci.yml | 4 ++-- .github/workflows/jvm-release.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/jvm-ci.yml b/.github/workflows/jvm-ci.yml index 466e193e6..93fd34bd4 100644 --- a/.github/workflows/jvm-ci.yml +++ b/.github/workflows/jvm-ci.yml @@ -63,7 +63,7 @@ jobs: type=raw,ci type=sha - name: Build and push Docker image - uses: docker/build-push-action@v6.10.0 + uses: docker/build-push-action@v6.11.0 with: context: . file: ./Dockerfile @@ -98,7 +98,7 @@ jobs: type=raw,ci type=sha - name: Build and push Docker image - uses: docker/build-push-action@v6.10.0 + uses: docker/build-push-action@v6.11.0 with: context: . file: ./Dockerfile diff --git a/.github/workflows/jvm-release.yml b/.github/workflows/jvm-release.yml index d7c4bb334..9277ff935 100644 --- a/.github/workflows/jvm-release.yml +++ b/.github/workflows/jvm-release.yml @@ -159,7 +159,7 @@ jobs: type=raw,latest type=sha - name: Build and push Docker image - uses: docker/build-push-action@v6.10.0 + uses: docker/build-push-action@v6.11.0 with: context: . file: ./Dockerfile @@ -195,7 +195,7 @@ jobs: type=raw,latest type=sha - name: Build and push Aliyun ACR - uses: docker/build-push-action@v6.10.0 + uses: docker/build-push-action@v6.11.0 with: context: . file: ./Dockerfile-Release From a7fc22727f47e6d95f8b587412bdccec52828f3d Mon Sep 17 00:00:00 2001 From: Gaojianli Date: Mon, 13 Jan 2025 17:12:21 +0800 Subject: [PATCH 05/20] =?UTF-8?q?=E5=A4=84=E7=90=86=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E5=90=8E=E5=8F=AF=E8=83=BD=E7=9A=84=E7=99=BB=E9=99=86=E6=80=81?= =?UTF-8?q?=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webui/src/stores/endpoint.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/webui/src/stores/endpoint.ts b/webui/src/stores/endpoint.ts index e2993f210..85c642a15 100644 --- a/webui/src/stores/endpoint.ts +++ b/webui/src/stores/endpoint.ts @@ -210,6 +210,8 @@ export const useEndpointStore = defineStore('endpoint', () => { throw new IncorrectTokenError() } else if (res.status === 303) { throw new NeedInitError() + } else if (res.status === 401) { + throw new IncorrectTokenError() } }, getGlobalConfig, From 3f0710a56e0ec51f2c7a528ff1ae97d52955035b Mon Sep 17 00:00:00 2001 From: Ghost_chu <30802565+Ghost-chu@users.noreply.github.com> Date: Mon, 13 Jan 2025 19:06:30 +0800 Subject: [PATCH 06/20] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 66171cba5..88a9dc8e3 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,4 @@ dependency-reduced-pom.xml PeerBanHelper.jar *.pkg install4j/output +install4j/project.install4j~ From 216da92de9b2ee73de5fdb8a5bf354b60b53419c Mon Sep 17 00:00:00 2001 From: Ghost_chu Date: Mon, 13 Jan 2025 19:59:56 +0800 Subject: [PATCH 07/20] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=A0=87=E5=87=86?= =?UTF-8?q?=E5=8C=96=E5=AD=97=E7=AC=A6=E4=B8=B2=E6=89=A7=E8=A1=8C=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=93=8D=E4=BD=9C=20#849?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../peerbanhelper/module/impl/webapi/PBHPeerController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHPeerController.java b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHPeerController.java index c4b764969..89e9f4371 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHPeerController.java +++ b/src/main/java/com/ghostchu/peerbanhelper/module/impl/webapi/PBHPeerController.java @@ -153,7 +153,7 @@ private void handleInfo(Context ctx) throws SQLException { private void handleBanHistory(Context ctx) throws SQLException { - String ip = IPAddressUtil.getIPAddress(ctx.pathParam("ip")).toString(); + String ip = IPAddressUtil.getIPAddress(ctx.pathParam("ip")).toNormalizedString(); Pageable pageable = new Pageable(ctx); var builder = historyDao.queryBuilder() .orderBy("banAt", false); @@ -168,7 +168,7 @@ private void handleBanHistory(Context ctx) throws SQLException { private void handleAccessHistory(Context ctx) throws SQLException { activeMonitoringModule.flush(); - String ip = IPAddressUtil.getIPAddress(ctx.pathParam("ip")).toString(); + String ip = IPAddressUtil.getIPAddress(ctx.pathParam("ip")).toNormalizedString(); Pageable pageable = new Pageable(ctx); var builder = peerRecordDao.queryBuilder() .orderBy("lastTimeSeen", false); From cfc51695204c887ae92d148fb97c7d85ccbf9a00 Mon Sep 17 00:00:00 2001 From: Ghost_chu Date: Mon, 13 Jan 2025 20:46:04 +0800 Subject: [PATCH 08/20] =?UTF-8?q?=E9=9D=99=E9=BB=98=E5=A4=84=E7=90=86?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../downloader/impl/qbittorrent/AbstractQbittorrent.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/ghostchu/peerbanhelper/downloader/impl/qbittorrent/AbstractQbittorrent.java b/src/main/java/com/ghostchu/peerbanhelper/downloader/impl/qbittorrent/AbstractQbittorrent.java index 9e62b65a0..7cf95818f 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/downloader/impl/qbittorrent/AbstractQbittorrent.java +++ b/src/main/java/com/ghostchu/peerbanhelper/downloader/impl/qbittorrent/AbstractQbittorrent.java @@ -162,7 +162,6 @@ public boolean isLoggedIn() { } return !info.getQt().isBlank(); } catch (Exception e) { - log.error("Failed to check login status", e); return false; } } From b7ac4238817d85d090d18988b06415d363cb12e0 Mon Sep 17 00:00:00 2001 From: Ghost_chu Date: Mon, 13 Jan 2025 21:05:23 +0800 Subject: [PATCH 09/20] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20hash=20=E6=B0=94?= =?UTF-8?q?=E6=B3=A1=E8=A2=AB=E8=A6=86=E7=9B=96=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webui/src/views/banlist/components/banListItem.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webui/src/views/banlist/components/banListItem.vue b/webui/src/views/banlist/components/banListItem.vue index b503b644f..c5ce36ece 100644 --- a/webui/src/views/banlist/components/banListItem.vue +++ b/webui/src/views/banlist/components/banListItem.vue @@ -136,7 +136,7 @@ - + {{ item.banMetadata.torrent.name }} From 206d5ad405cec0cd241b2950781e7d863513364d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 13:49:01 +0000 Subject: [PATCH 10/20] Bump org.apache.james:apache-mime4j-storage from 0.8.11 to 0.8.12 Bumps org.apache.james:apache-mime4j-storage from 0.8.11 to 0.8.12. --- updated-dependencies: - dependency-name: org.apache.james:apache-mime4j-storage dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4a5e4ba0e..db58832c1 100644 --- a/pom.xml +++ b/pom.xml @@ -420,7 +420,7 @@ org.apache.james apache-mime4j-storage - 0.8.11 + 0.8.12 commons-io From 2f368c9ca9bd3f0d4390228f808da363731ed409 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 13:49:41 +0000 Subject: [PATCH 11/20] Bump org.apache.james:apache-mime4j-dom from 0.8.11 to 0.8.12 Bumps org.apache.james:apache-mime4j-dom from 0.8.11 to 0.8.12. --- updated-dependencies: - dependency-name: org.apache.james:apache-mime4j-dom dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4a5e4ba0e..c110ef8af 100644 --- a/pom.xml +++ b/pom.xml @@ -398,7 +398,7 @@ org.apache.james apache-mime4j-dom - 0.8.11 + 0.8.12 commons-io From d638abe4cdbac53f3b20c6fd6174ea932c31db34 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 13:50:01 +0000 Subject: [PATCH 12/20] Bump org.apache.james:apache-mime4j-core from 0.8.11 to 0.8.12 Bumps org.apache.james:apache-mime4j-core from 0.8.11 to 0.8.12. --- updated-dependencies: - dependency-name: org.apache.james:apache-mime4j-core dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4a5e4ba0e..935ebfc72 100644 --- a/pom.xml +++ b/pom.xml @@ -409,7 +409,7 @@ org.apache.james apache-mime4j-core - 0.8.11 + 0.8.12 commons-io From 9d57cfc7c08c860dfa0fe89f2062037c3e53929a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 13:50:12 +0000 Subject: [PATCH 13/20] Bump org.bspfsystems:yamlconfiguration from 3.0.1 to 3.0.2 Bumps [org.bspfsystems:yamlconfiguration](https://github.com/bspfsystems/YamlConfiguration) from 3.0.1 to 3.0.2. - [Release notes](https://github.com/bspfsystems/YamlConfiguration/releases) - [Commits](https://github.com/bspfsystems/YamlConfiguration/compare/v3.0.1...v3.0.2) --- updated-dependencies: - dependency-name: org.bspfsystems:yamlconfiguration dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4a5e4ba0e..7f3f6f571 100644 --- a/pom.xml +++ b/pom.xml @@ -258,7 +258,7 @@ org.bspfsystems yamlconfiguration - 3.0.1 + 3.0.2 compile From 6de2cac56e1cb21c01c404c089196399b9eb9219 Mon Sep 17 00:00:00 2001 From: Ghost_chu Date: Mon, 13 Jan 2025 22:14:58 +0800 Subject: [PATCH 14/20] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A4=8D=E6=9D=82=20Tr?= =?UTF-8?q?anslationComponent=20=E7=BB=84=E4=BB=B6=E5=BA=8F=E5=88=97?= =?UTF-8?q?=E5=8C=96=E3=80=81=E5=8F=8D=E5=BA=8F=E5=88=97=E5=8C=96=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../database/table/AlertEntity.java | 6 +- .../peerbanhelper/util/json/JsonUtil.java | 2 + .../json/TranslationComponentTypeAdapter.java | 72 ++++++++++++++++--- 3 files changed, 67 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/ghostchu/peerbanhelper/database/table/AlertEntity.java b/src/main/java/com/ghostchu/peerbanhelper/database/table/AlertEntity.java index 872f1dcab..ffb43214b 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/database/table/AlertEntity.java +++ b/src/main/java/com/ghostchu/peerbanhelper/database/table/AlertEntity.java @@ -1,8 +1,8 @@ package com.ghostchu.peerbanhelper.database.table; import com.ghostchu.peerbanhelper.alert.AlertLevel; +import com.ghostchu.peerbanhelper.database.TranslationComponentPersistener; import com.ghostchu.peerbanhelper.text.TranslationComponent; -import com.j256.ormlite.field.DataType; import com.j256.ormlite.field.DatabaseField; import com.j256.ormlite.table.DatabaseTable; import lombok.AllArgsConstructor; @@ -26,8 +26,8 @@ public final class AlertEntity { private AlertLevel level; @DatabaseField(canBeNull = false, index = true) private String identifier; - @DatabaseField(canBeNull = false, dataType = DataType.SERIALIZABLE) + @DatabaseField(canBeNull = false, persisterClass = TranslationComponentPersistener.class) private TranslationComponent title; - @DatabaseField(canBeNull = false, dataType = DataType.SERIALIZABLE) + @DatabaseField(canBeNull = false, persisterClass = TranslationComponentPersistener.class) private TranslationComponent content; } \ No newline at end of file diff --git a/src/main/java/com/ghostchu/peerbanhelper/util/json/JsonUtil.java b/src/main/java/com/ghostchu/peerbanhelper/util/json/JsonUtil.java index e9e936962..88dbd3c4a 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/util/json/JsonUtil.java +++ b/src/main/java/com/ghostchu/peerbanhelper/util/json/JsonUtil.java @@ -1,5 +1,6 @@ package com.ghostchu.peerbanhelper.util.json; +import com.ghostchu.peerbanhelper.text.TranslationComponent; import com.google.gson.*; import org.jetbrains.annotations.NotNull; @@ -13,6 +14,7 @@ public class JsonUtil { .setExclusionStrategies(new HiddenAnnotationExclusionStrategy()) .serializeNulls() .registerTypeAdapter(Timestamp.class, TimestampTypeAdapter.INSTANCE) + .registerTypeAdapter(TranslationComponent.class, TranslationComponentTypeAdapter.INSTANCE) .disableHtmlEscaping() .create(); diff --git a/src/main/java/com/ghostchu/peerbanhelper/util/json/TranslationComponentTypeAdapter.java b/src/main/java/com/ghostchu/peerbanhelper/util/json/TranslationComponentTypeAdapter.java index 5a4521deb..3b9b2b13e 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/util/json/TranslationComponentTypeAdapter.java +++ b/src/main/java/com/ghostchu/peerbanhelper/util/json/TranslationComponentTypeAdapter.java @@ -1,20 +1,72 @@ package com.ghostchu.peerbanhelper.util.json; import com.ghostchu.peerbanhelper.text.TranslationComponent; -import com.google.gson.JsonElement; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonToken; +import com.google.gson.stream.JsonWriter; -import java.lang.reflect.Type; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; -import static com.ghostchu.peerbanhelper.text.TextManager.tlUI; - -public class TranslationComponentTypeAdapter implements JsonSerializer { +public class TranslationComponentTypeAdapter extends TypeAdapter { public static final TranslationComponentTypeAdapter INSTANCE = new TranslationComponentTypeAdapter(); @Override - public JsonElement serialize(TranslationComponent ts, Type t, JsonSerializationContext jsc) { - return new JsonPrimitive(tlUI(ts)); + public void write(JsonWriter out, TranslationComponent value) throws IOException { + out.beginObject(); + out.name("key").value(value.getKey()); + out.name("params"); + out.beginArray(); // 开始 JSON 数组 + // 遍历 params 数组并写入元素 + for (Object param : value.getParams()) { + if (param instanceof String) { + out.value((String) param); // 如果是 String,直接写入 + } else if (param instanceof TranslationComponent) { + // 如果是 TranslationComponent,递归调用 write 方法 + TranslationComponentTypeAdapter.INSTANCE.write(out, (TranslationComponent) param); + } else { + out.nullValue(); // 如果是其他类型,写入 null(可以根据需求调整) + } + } + out.endArray(); // 结束 JSON 数组 + out.endObject(); // 结束 JSON 对象 + } + + @Override + public TranslationComponent read(JsonReader in) throws IOException { + String key = null; + List params = new ArrayList<>(); + + in.beginObject(); // 开始读取 JSON 对象 + + while (in.hasNext()) { // 循环读取每个字段 + String name = in.nextName(); + if ("key".equals(name)) { + key = in.nextString(); // 读取 key 字段 + } else if ("params".equals(name)) { + in.beginArray(); // 开始读取 JSON 数组 + while (in.hasNext()) { + // 判断当前元素是字符串还是 TranslationComponent + if (in.peek() == JsonToken.STRING) { + params.add(in.nextString()); // 如果是字符串,直接添加到 params 列表 + } else if (in.peek() == JsonToken.BEGIN_OBJECT) { + // 如果是对象,则递归读取 TranslationComponent + params.add(TranslationComponentTypeAdapter.INSTANCE.read(in)); + } else { + in.skipValue(); // 跳过不需要的值 + } + } + in.endArray(); // 结束数组读取 + } else { + in.skipValue(); // 跳过不需要的字段 + } + } + + in.endObject(); // 结束 JSON 对象的读取 + + // 构造并返回 TranslationComponent 对象 + return new TranslationComponent(key, params.toArray(new Object[0])); } } \ No newline at end of file From f567779247266d07dd42335c46ec7269239739e4 Mon Sep 17 00:00:00 2001 From: Ghost_chu Date: Mon, 13 Jan 2025 22:25:36 +0800 Subject: [PATCH 15/20] =?UTF-8?q?=E7=9B=B4=E6=8E=A5=20toString?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../util/json/TranslationComponentTypeAdapter.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/ghostchu/peerbanhelper/util/json/TranslationComponentTypeAdapter.java b/src/main/java/com/ghostchu/peerbanhelper/util/json/TranslationComponentTypeAdapter.java index 3b9b2b13e..f5d4c0862 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/util/json/TranslationComponentTypeAdapter.java +++ b/src/main/java/com/ghostchu/peerbanhelper/util/json/TranslationComponentTypeAdapter.java @@ -27,11 +27,13 @@ public void write(JsonWriter out, TranslationComponent value) throws IOException // 如果是 TranslationComponent,递归调用 write 方法 TranslationComponentTypeAdapter.INSTANCE.write(out, (TranslationComponent) param); } else { - out.nullValue(); // 如果是其他类型,写入 null(可以根据需求调整) + out.value(value.toString()); } } out.endArray(); // 结束 JSON 数组 out.endObject(); // 结束 JSON 对象 + + // 特别注意嵌套里面不允许出现除了 TranslationComponent 以外的 JsonObject,否则必翻车 } @Override From ca86e75879565954bf55fbe9f66a34a804e24d1f Mon Sep 17 00:00:00 2001 From: Ghost_chu Date: Mon, 13 Jan 2025 22:26:00 +0800 Subject: [PATCH 16/20] apply changes --- .../util/json/TranslationComponentTypeAdapter.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/com/ghostchu/peerbanhelper/util/json/TranslationComponentTypeAdapter.java b/src/main/java/com/ghostchu/peerbanhelper/util/json/TranslationComponentTypeAdapter.java index f5d4c0862..25161a86f 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/util/json/TranslationComponentTypeAdapter.java +++ b/src/main/java/com/ghostchu/peerbanhelper/util/json/TranslationComponentTypeAdapter.java @@ -21,9 +21,7 @@ public void write(JsonWriter out, TranslationComponent value) throws IOException out.beginArray(); // 开始 JSON 数组 // 遍历 params 数组并写入元素 for (Object param : value.getParams()) { - if (param instanceof String) { - out.value((String) param); // 如果是 String,直接写入 - } else if (param instanceof TranslationComponent) { + if (param instanceof TranslationComponent) { // 如果是 TranslationComponent,递归调用 write 方法 TranslationComponentTypeAdapter.INSTANCE.write(out, (TranslationComponent) param); } else { From 820ff50ab40cd530dab18e97798c002e87cc0da0 Mon Sep 17 00:00:00 2001 From: Ghost_chu Date: Mon, 13 Jan 2025 22:27:55 +0800 Subject: [PATCH 17/20] update 7.3.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7d59ebbdf..ef916f4ec 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.ghostchu.peerbanhelper peerbanhelper - 7.3.1 + 7.3.2 jar PeerBanHelper From c457fadce8d9a10d8039bd6efe37e361835b3f9c Mon Sep 17 00:00:00 2001 From: Ghost_chu Date: Mon, 13 Jan 2025 22:35:13 +0800 Subject: [PATCH 18/20] =?UTF-8?q?=E6=B8=85=E7=A9=BA=20Alert=20=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ghostchu/peerbanhelper/database/DatabaseHelper.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/ghostchu/peerbanhelper/database/DatabaseHelper.java b/src/main/java/com/ghostchu/peerbanhelper/database/DatabaseHelper.java index e3387de43..cb506f6b2 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/database/DatabaseHelper.java +++ b/src/main/java/com/ghostchu/peerbanhelper/database/DatabaseHelper.java @@ -75,6 +75,11 @@ private void performUpgrade() throws SQLException { TableUtils.createTableIfNotExists(database.getDataSource(), AlertEntity.class); v = 7; } + if (v == 7) { + TableUtils.dropTable(getDataSource(), AlertEntity.class, true); + TableUtils.createTableIfNotExists(database.getDataSource(), AlertEntity.class); + v = 8; + } version.setValue(String.valueOf(v)); metadata.update(version); } From 4d9347fe4c0971732bc6b2d38bc082f553e796d2 Mon Sep 17 00:00:00 2001 From: Ghost_chu Date: Mon, 13 Jan 2025 22:42:15 +0800 Subject: [PATCH 19/20] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20param.toString()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../util/json/TranslationComponentTypeAdapter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/ghostchu/peerbanhelper/util/json/TranslationComponentTypeAdapter.java b/src/main/java/com/ghostchu/peerbanhelper/util/json/TranslationComponentTypeAdapter.java index 25161a86f..f109186ea 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/util/json/TranslationComponentTypeAdapter.java +++ b/src/main/java/com/ghostchu/peerbanhelper/util/json/TranslationComponentTypeAdapter.java @@ -25,7 +25,7 @@ public void write(JsonWriter out, TranslationComponent value) throws IOException // 如果是 TranslationComponent,递归调用 write 方法 TranslationComponentTypeAdapter.INSTANCE.write(out, (TranslationComponent) param); } else { - out.value(value.toString()); + out.value(param.toString()); } } out.endArray(); // 结束 JSON 数组 From 251296356544962d8a89ed2375e8356ac6f9708f Mon Sep 17 00:00:00 2001 From: Ghost_chu Date: Mon, 13 Jan 2025 23:31:43 +0800 Subject: [PATCH 20/20] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20IP=20=E6=8E=92?= =?UTF-8?q?=E8=A1=8C=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ghostchu/peerbanhelper/PeerBanHelperServer.java | 4 ++++ .../peerbanhelper/database/dao/impl/HistoryDao.java | 13 +++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/ghostchu/peerbanhelper/PeerBanHelperServer.java b/src/main/java/com/ghostchu/peerbanhelper/PeerBanHelperServer.java index 592acb608..01e216725 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/PeerBanHelperServer.java +++ b/src/main/java/com/ghostchu/peerbanhelper/PeerBanHelperServer.java @@ -201,6 +201,10 @@ private void runTestCode() { return; } // run some junky test code here +// ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory +// .getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME); +// root.setLevel(ch.qos.logback.classic.Level.TRACE); + } diff --git a/src/main/java/com/ghostchu/peerbanhelper/database/dao/impl/HistoryDao.java b/src/main/java/com/ghostchu/peerbanhelper/database/dao/impl/HistoryDao.java index 709e8f1d5..47909e6cd 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/database/dao/impl/HistoryDao.java +++ b/src/main/java/com/ghostchu/peerbanhelper/database/dao/impl/HistoryDao.java @@ -44,15 +44,16 @@ public Page getBannedIps(Pageable pageable, String filter) throws .selectRaw("ip, COUNT(*) AS count") .groupBy("ip") .orderByRaw("count DESC"); + String[] args = new String[0]; if (filter != null) { - builder.setWhere(builder.where().like("ip", new SelectArg(filter + "%"))); + builder.setWhere(builder.where().like("ip", new SelectArg())); + args = new String[]{filter + "%"}; } - List mapped; - try (GenericRawResults banLogs = builder + var queryBuilder = builder .limit(pageable.getSize()) - .offset(pageable.getZeroBasedPage() * pageable.getSize()) - // .where().ge("banAt", twoWeeksAgo) - .queryRaw()) { + .offset(pageable.getZeroBasedPage() * pageable.getSize()); + List mapped; + try (GenericRawResults banLogs = queryRaw(queryBuilder.prepareStatementString(), args)) { var results = banLogs.getResults(); mapped = results.stream().map(arr -> new PeerBanCount(arr[0], Long.parseLong(arr[1]))).toList(); }