From 0b2bee0a3df5bbd3f7c29e2bd8f2e27929d94aee80640f50af70aa949d8cc335 Mon Sep 17 00:00:00 2001 From: AidarKC Date: Thu, 29 Jan 2026 18:30:55 +0300 Subject: [PATCH] 29 01 25 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Удалил старые черновики тест весь проходит --- .../ws_protocol/JSON/JsonHandlerRegistry.java | 4 - .../Net_GetSubscribedChannels_Handler.java | 147 ------------------ .../Net_GetSubscribedChannels_Request.java | 23 --- .../Net_GetSubscribedChannels_Response.java | 58 ------- 4 files changed, 232 deletions(-) delete mode 100644 shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/subscriptions/Net_GetSubscribedChannels_Handler.java delete mode 100644 shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/subscriptions/entyties/Net_GetSubscribedChannels_Request.java delete mode 100644 shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/subscriptions/entyties/Net_GetSubscribedChannels_Response.java diff --git a/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/JsonHandlerRegistry.java b/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/JsonHandlerRegistry.java index 86540ba..4ddc45c 100644 --- a/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/JsonHandlerRegistry.java +++ b/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/JsonHandlerRegistry.java @@ -43,8 +43,6 @@ import server.logic.ws_protocol.JSON.handlers.userParams.entyties.Net_ListUserPa import server.logic.ws_protocol.JSON.handlers.userParams.entyties.Net_UpsertUserParam_Request; // --- subscriptions --- -//import server.logic.ws_protocol.JSON.handlers.subscriptions.Net_GetSubscribedChannels_Handler; -import server.logic.ws_protocol.JSON.handlers.subscriptions.entyties.Net_GetSubscribedChannels_Request; // --- NEW: connections friends lists --- import server.logic.ws_protocol.JSON.handlers.connections.Net_GetFriendsLists_Handler; @@ -111,8 +109,6 @@ public final class JsonHandlerRegistry { Map.entry("GetUserParam", Net_GetUserParam_Request.class), Map.entry("ListUserParams", Net_ListUserParams_Request.class), - // --- subscriptions --- - Map.entry("ListSubscribedChannels", Net_GetSubscribedChannels_Request.class), // --- connections --- Map.entry("GetFriendsLists", Net_GetFriendsLists_Request.class) diff --git a/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/subscriptions/Net_GetSubscribedChannels_Handler.java b/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/subscriptions/Net_GetSubscribedChannels_Handler.java deleted file mode 100644 index 2a86e32..0000000 --- a/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/subscriptions/Net_GetSubscribedChannels_Handler.java +++ /dev/null @@ -1,147 +0,0 @@ -//package server.logic.ws_protocol.JSON.handlers.subscriptions; -// -//import blockchain.BchBlockEntry; -//import blockchain.body.TextBody; -//import org.slf4j.Logger; -//import org.slf4j.LoggerFactory; -//import server.logic.ws_protocol.JSON.ConnectionContext; -//import server.logic.ws_protocol.JSON.entyties.Net_Request; -//import server.logic.ws_protocol.JSON.entyties.Net_Response; -//import server.logic.ws_protocol.JSON.handlers.JsonMessageHandler; -//import server.logic.ws_protocol.JSON.handlers.subscriptions.entyties.Net_GetSubscribedChannels_Request; -//import server.logic.ws_protocol.JSON.handlers.subscriptions.entyties.Net_GetSubscribedChannels_Response; -//import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory; -//import server.logic.ws_protocol.WireCodes; -//import shine.db.SqliteDbController; -//import shine.db.dao.SubscriptionsDAO; -// -//import java.sql.Connection; -//import java.sql.SQLException; -//import java.util.ArrayList; -//import java.util.List; -// -///** -// * Handler: GetSubscribedChannels -// * -// * Логика: -// * - DAO возвращает last publication orig bytes (+ edit bytes если есть) -// * - Handler парсит FULL bytes блока: -// * timestamp берём из ОРИГИНАЛА (publication) -// * текст берём из EDIT (если есть) иначе из оригинала -// * - формируем превью первых 50 символов -// */ -//public class Net_GetSubscribedChannels_Handler implements JsonMessageHandler { -// -// private static final Logger log = LoggerFactory.getLogger(Net_GetSubscribedChannels_Handler.class); -// -// @Override -// public Net_Response handle(Net_Request baseRequest, ConnectionContext ctx) { -// Net_GetSubscribedChannels_Request req = (Net_GetSubscribedChannels_Request) baseRequest; -// -// if (req.getLogin() == null || req.getLogin().isBlank()) { -// return NetExceptionResponseFactory.error( -// req, -// WireCodes.Status.BAD_REQUEST, -// "BAD_FIELDS", -// "Некорректное поле: login" -// ); -// } -// -// // Если хочешь жёстче: -// // if (!req.getLogin().matches("^[A-Za-z0-9_]+$")) ... -// -// SubscriptionsDAO dao = SubscriptionsDAO.getInstance(); -// SqliteDbController db = SqliteDbController.getInstance(); -// -// try (Connection c = db.getConnection()) { -// -// List rows = dao.getSubscribedChannels(c, req.getLogin()); -// List out = new ArrayList<>(rows.size()); -// -// for (SubscriptionsDAO.ChannelRow r : rows) { -// Net_GetSubscribedChannels_Response.ChannelInfo dto = -// new Net_GetSubscribedChannels_Response.ChannelInfo(); -// -// dto.setChannelLogin(r.getChannelLogin()); -// dto.setChannelBchName(r.getChannelBchName()); -// dto.setPublicationsCount(r.getPublicationsCount()); -// -// byte[] pubBytes = r.getLastPublicationBlockBytes(); -// byte[] editBytes = r.getLastEditBlockBytes(); -// -// if (pubBytes == null || pubBytes.length == 0) { -// dto.setLastPublicationTimestampSec(null); -// dto.setLastTextPreview(null); -// out.add(dto); -// continue; -// } -// -// // 1) timestamp берём из ОРИГИНАЛЬНОЙ публикации -// BchBlockEntry pubBlock = new BchBlockEntry(pubBytes); -// dto.setLastPublicationTimestampSec(pubBlock.timestamp); -// -// // 2) текст — из EDIT (если есть) иначе из оригинала -// byte[] actualBytes = (editBytes != null && editBytes.length > 0) ? editBytes : pubBytes; -// BchBlockEntry actualBlock = new BchBlockEntry(actualBytes); -// -// if (!(actualBlock.body instanceof TextBody)) { -// // Это уже нарушение данных: last publication должен быть текстовым блоком. -// throw new IllegalStateException("Last publication is not TextBody: type=" -// + (actualBlock.body == null ? "null" : (actualBlock.body.type() & 0xFFFF))); -// } -// -// String msg = ((TextBody) actualBlock.body).message; -// dto.setLastTextPreview(firstNCharsSafe(msg, 50)); -// -// out.add(dto); -// } -// -// Net_GetSubscribedChannels_Response resp = new Net_GetSubscribedChannels_Response(); -// resp.setOp(req.getOp()); -// resp.setRequestId(req.getRequestId()); -// resp.setStatus(WireCodes.Status.OK); -// resp.setChannels(out); -// -// return resp; -// -// } catch (SQLException e) { -// log.error("❌ DB error GetSubscribedChannels", e); -// return NetExceptionResponseFactory.error( -// req, -// WireCodes.Status.SERVER_DATA_ERROR, -// "DB_ERROR", -// "Ошибка БД" -// ); -// } catch (IllegalArgumentException e) { -// // сюда попадёт, например, если BchBlockEntry не смог распарсить block_byte -// log.error("❌ Bad block bytes in DB (cannot parse BchBlockEntry)", e); -// return NetExceptionResponseFactory.error( -// req, -// WireCodes.Status.SERVER_DATA_ERROR, -// "BAD_BLOCK_BYTES", -// "В БД обнаружен повреждённый блок" -// ); -// } catch (Exception e) { -// log.error("❌ Internal error GetSubscribedChannels", e); -// return NetExceptionResponseFactory.error( -// req, -// WireCodes.Status.INTERNAL_ERROR, -// "INTERNAL_ERROR", -// "Внутренняя ошибка сервера" -// ); -// } -// } -// -// /** -// * Берём первые N "символов" безопасно для emoji/суррогатных пар: -// * режем по code points. -// */ -// private static String firstNCharsSafe(String s, int n) { -// if (s == null) return null; -// if (n <= 0) return ""; -// int cp = s.codePointCount(0, s.length()); -// if (cp <= n) return s; -// int end = s.offsetByCodePoints(0, n); -// return s.substring(0, end); -// } -//} \ No newline at end of file diff --git a/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/subscriptions/entyties/Net_GetSubscribedChannels_Request.java b/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/subscriptions/entyties/Net_GetSubscribedChannels_Request.java deleted file mode 100644 index 26031fd..0000000 --- a/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/subscriptions/entyties/Net_GetSubscribedChannels_Request.java +++ /dev/null @@ -1,23 +0,0 @@ -package server.logic.ws_protocol.JSON.handlers.subscriptions.entyties; - -import server.logic.ws_protocol.JSON.entyties.Net_Request; - -/** - * Запрос GetSubscribedChannels. - * - * Клиент отправляет: - * { - * "op": "GetSubscribedChannels", - * "requestId": "....", - * "payload": { - * "login": "anya" - * } - * } - */ -public class Net_GetSubscribedChannels_Request extends Net_Request { - - private String login; - - public String getLogin() { return login; } - public void setLogin(String login) { this.login = login; } -} \ No newline at end of file diff --git a/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/subscriptions/entyties/Net_GetSubscribedChannels_Response.java b/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/subscriptions/entyties/Net_GetSubscribedChannels_Response.java deleted file mode 100644 index cd70c53..0000000 --- a/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/subscriptions/entyties/Net_GetSubscribedChannels_Response.java +++ /dev/null @@ -1,58 +0,0 @@ -package server.logic.ws_protocol.JSON.handlers.subscriptions.entyties; - -import server.logic.ws_protocol.JSON.entyties.Net_Response; - -import java.util.List; - -/** - * Ответ GetSubscribedChannels. - * - * payload: - * { - * "channels": [ - * { - * "channelLogin": "dima", - * "channelBchName": "dima-001", - * "publicationsCount": 123, - * "lastPublicationTimestampSec": 1736371200, - * "lastTextPreview": "...." - * } - * ] - * } - */ -public class Net_GetSubscribedChannels_Response extends Net_Response { - - private List channels; - - public List getChannels() { return channels; } - public void setChannels(List channels) { this.channels = channels; } - - public static class ChannelInfo { - - private String channelLogin; - private String channelBchName; - - private Integer publicationsCount; - - /** Unix seconds времени ПУБЛИКАЦИИ (оригинального TEXT_NEW). Nullable, если публикаций нет. */ - private Long lastPublicationTimestampSec; - - /** Первые 50 символов актуального текста (edit или orig). Nullable, если публикаций нет. */ - private String lastTextPreview; - - public String getChannelLogin() { return channelLogin; } - public void setChannelLogin(String channelLogin) { this.channelLogin = channelLogin; } - - public String getChannelBchName() { return channelBchName; } - public void setChannelBchName(String channelBchName) { this.channelBchName = channelBchName; } - - public Integer getPublicationsCount() { return publicationsCount; } - public void setPublicationsCount(Integer publicationsCount) { this.publicationsCount = publicationsCount; } - - public Long getLastPublicationTimestampSec() { return lastPublicationTimestampSec; } - public void setLastPublicationTimestampSec(Long lastPublicationTimestampSec) { this.lastPublicationTimestampSec = lastPublicationTimestampSec; } - - public String getLastTextPreview() { return lastTextPreview; } - public void setLastTextPreview(String lastTextPreview) { this.lastTextPreview = lastTextPreview; } - } -} \ No newline at end of file