Skip to content

Commit

Permalink
Merge pull request #3 from antonkorotkov/dev
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
antonkorotkov authored Aug 25, 2024
2 parents f34072b + f58886c commit 36947b0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/bot/TelegramBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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);
}
});
Expand Down
4 changes: 4 additions & 0 deletions app/db/schemas/Monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 36947b0

Please sign in to comment.