diff --git a/src/bot/listeners.ts b/src/bot/listeners.ts index 22e2c4e..1f733e2 100644 --- a/src/bot/listeners.ts +++ b/src/bot/listeners.ts @@ -11,7 +11,7 @@ export class UpdateListeners { @On("sticker") async onSticker(@Ctx() ctx: Context) { - await ctx.reply("πŸ‘"); + // await ctx.reply("πŸ‘"); } @Hears("hi") diff --git a/src/db/schemas/session.schema.ts b/src/db/schemas/session.schema.ts index 54d7a5e..9f89495 100644 --- a/src/db/schemas/session.schema.ts +++ b/src/db/schemas/session.schema.ts @@ -1,7 +1,7 @@ import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose"; import { HydratedDocument } from "mongoose"; -@Schema({ expires: "7d" }) +@Schema({ timestamps: true }) // Enables `createdAt` and `updatedAt` fields automatically export class Session { @Prop({ required: true }) type: string; @@ -11,6 +11,10 @@ export class Session { @Prop({ required: true }) option: string; + + @Prop({ default: Date.now, expires: "7d" }) // TTL index with expiration after 7 days + createdAt: Date; // MongoDB uses this field for the TTL } + export type TSession = HydratedDocument; export const SessionSchema = SchemaFactory.createForClass(Session); diff --git a/src/db/task.service.ts b/src/db/task.service.ts index 1e1fa84..b8c8d07 100644 --- a/src/db/task.service.ts +++ b/src/db/task.service.ts @@ -182,7 +182,7 @@ export class TaskService implements ITask { async deleteAllTasksForJob(jobId: string): Promise { await this.taskModel.deleteMany({ - _id: jobId, + _id: jobId, // BUG - there should be jobId in the task scheme status: { $in: [taskStatus.new, taskStatus.snoozed, taskStatus.pending], }, diff --git a/src/notebook.txt b/src/notebook.txt new file mode 100644 index 0000000..de0da2c --- /dev/null +++ b/src/notebook.txt @@ -0,0 +1,154 @@ +{ + "update_id": 396065464, + "my_chat_member": { + "chat": { + "id": -892251879, + "title": "Π”ΠΈΠΊΠ°Ρ€ΠΈ", + "type": "group", + "all_members_are_administrators": true + }, + "from": { + "id": 268482275, + "is_bot": false, + "first_name": "uncle Lyozha", + "username": "Lyozha", + "language_code": "en" + }, + "date": 1719910633, + "old_chat_member": { + "user": { + "id": 7035486003, + "is_bot": true, + "first_name": "test_lyozha_bot", + "username": "testLyozhaBot" + }, + "status": "left" + }, + "new_chat_member": { + "user": { + "id": 7035486003, + "is_bot": true, + "first_name": "test_lyozha_bot", + "username": "testLyozhaBot" + }, + "status": "member" + } + } +}, +{ + "update_id": 396065465, + "message": { + "message_id": 2487, + "from": { + "id": 268482275, + "is_bot": false, + "first_name": "uncle Lyozha", + "username": "Lyozha", + "language_code": "en" + }, + "chat": { + "id": -892251879, + "title": "Π”ΠΈΠΊΠ°Ρ€ΠΈ", + "type": "group", + "all_members_are_administrators": true + }, + "date": 1719910633, + "new_chat_participant": { + "id": 7035486003, + "is_bot": true, + "first_name": "test_lyozha_bot", + "username": "testLyozhaBot" + }, + "new_chat_member": { + "id": 7035486003, + "is_bot": true, + "first_name": "test_lyozha_bot", + "username": "testLyozhaBot" + }, + "new_chat_members": [ + { + "id": 7035486003, + "is_bot": true, + "first_name": "test_lyozha_bot", + "username": "testLyozhaBot" + } + ] + } +} +User with 7035486003 not found in DB. +New user created: + { + userName: 'testLyozhaBot', + tgId: 7035486003, + _id: new ObjectId('6683c0e9362e888122b1eb59'), + __v: 0 +} +{ + "update_id": 396065466, + "my_chat_member": { + "chat": { + "id": -892251879, + "title": "Π”ΠΈΠΊΠ°Ρ€ΠΈ", + "type": "group", + "all_members_are_administrators": true + }, + "from": { + "id": 268482275, + "is_bot": false, + "first_name": "uncle Lyozha", + "username": "Lyozha", + "language_code": "en" + }, + "date": 1719910650, + "old_chat_member": { + "user": { + "id": 7035486003, + "is_bot": true, + "first_name": "test_lyozha_bot", + "username": "testLyozhaBot" + }, + "status": "member" + }, + "new_chat_member": { + "user": { + "id": 7035486003, + "is_bot": true, + "first_name": "test_lyozha_bot", + "username": "testLyozhaBot" + }, + "status": "left" + } + } +} +{ + "update_id": 396065467, + "message": { + "message_id": 2489, + "from": { + "id": 268482275, + "is_bot": false, + "first_name": "uncle Lyozha", + "username": "Lyozha", + "language_code": "en" + }, + "chat": { + "id": -892251879, + "title": "Π”ΠΈΠΊΠ°Ρ€ΠΈ", + "type": "group", + "all_members_are_administrators": true + }, + "date": 1719910650, + "left_chat_participant": { + "id": 7035486003, + "is_bot": true, + "first_name": "test_lyozha_bot", + "username": "testLyozhaBot" + }, + "left_chat_member": { + "id": 7035486003, + "is_bot": true, + "first_name": "test_lyozha_bot", + "username": "testLyozhaBot" + } + } +} \ No newline at end of file diff --git a/src/scenes/assignUser.wizard.ts b/src/scenes/assignUser.wizard.ts index b64f55f..e97a4f2 100644 --- a/src/scenes/assignUser.wizard.ts +++ b/src/scenes/assignUser.wizard.ts @@ -51,7 +51,7 @@ export class AssignUserWizard { await ctx.editMessageText(errMsgGeneral); } const pmMsg = - "New task created: \n" + newTask.jobName + " = " + newTask.userName; + "The user on duty has been changed: \n" + newTask.jobName + " = " + newTask.userName; await ctx.editMessageText(pmMsg); await ctx.scene.leave(); }