diff --git a/app/bot/TelegramBot.js b/app/bot/TelegramBot.js index 8606a4d..9ecbedf 100644 --- a/app/bot/TelegramBot.js +++ b/app/bot/TelegramBot.js @@ -4,6 +4,7 @@ const { Bot, GrammyError, HttpError, session } = require("grammy"); const { start, search } = require("./commands"); const User = require("../db/schemas/User"); +const Monitor = require("../db/schemas/Monitor"); const i18n = new I18n({ defaultLocale: "en", @@ -36,6 +37,7 @@ class TelegramBot { this.#bot.on('my_chat_member', async ctx => { if (['kicked', 'left'].includes(ctx.myChatMember.new_chat_member.status)) { await User.deactivate(ctx.myChatMember.chat.id); + await Monitor.deleteByTelegramId(ctx.myChatMember.chat.id); this.#pagination.flushUserCache(ctx.from.id); } }); diff --git a/app/db/schemas/Monitor.js b/app/db/schemas/Monitor.js index b3dbbf2..203a340 100644 --- a/app/db/schemas/Monitor.js +++ b/app/db/schemas/Monitor.js @@ -46,6 +46,10 @@ MonitorSchema.statics.createOrUpdate = function ({ ); }; +MonitorSchema.statics.deleteByTelegramId = function (telegramId) { + return this.deleteMany({ telegramId }); +}; + const Monitor = model('Monitor', MonitorSchema); module.exports = Monitor; \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 8d7d785..b35fd03 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,9 +11,10 @@ services: - app-network healthcheck: test: rabbitmq-diagnostics -q ping - interval: 5s + interval: 30s timeout: 5s retries: 5 + start_period: 10s logging: driver: json-file options: