From e7e5432aba9ae4cdba8a546969de0618968f8b57 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 12 Jan 2023 13:57:40 +0300 Subject: Telegram: handle "chat not found" errors --- src/main/java/com/juick/TelegramBotManager.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/com/juick/TelegramBotManager.java b/src/main/java/com/juick/TelegramBotManager.java index 3ca0f217..9dfea1a3 100644 --- a/src/main/java/com/juick/TelegramBotManager.java +++ b/src/main/java/com/juick/TelegramBotManager.java @@ -369,6 +369,19 @@ public class TelegramBotManager implements NotificationListener { boolean status = telegramService.deleteTelegramUser(user.getUid()); logger.info("deleting telegram id of @{} : {}", user.getName(), status); } + } else if (response.errorCode() == 400) { + if (response.description().equals("Bad Request: chat not found")) { + if (user.isAnonymous()) { + boolean status = telegramService.deleteAnonymous(chatId); + logger.info("deleting chat id {}: {}", chatId, status); + } else { + boolean status = telegramService.deleteTelegramUser(user.getUid()); + logger.info("deleting telegram id of @{} : {}", user.getName(), status); + } + } else { + logger.warn("error response, isOk: {}, errorCode: {}, description: {}", + response.isOk(), response.errorCode(), response.description()); + } } else { logger.warn("error response, isOk: {}, errorCode: {}, description: {}", response.isOk(), response.errorCode(), response.description()); -- cgit v1.2.3