bringing back forgotten awaits

This commit is contained in:
Dmitry Anderson 2024-10-28 18:00:10 +01:00
parent ade154b169
commit 0084abc4b8
2 changed files with 5 additions and 5 deletions

View File

@ -129,16 +129,16 @@ export const checkUserOnNewChatMember = async (
const { expect_user_tg_id } = inviteLinksData[0]
out.isExpectedUserJoined = expect_user_tg_id === ctx.chatMember.from.id
out.expectedUserTgId = expect_user_tg_id
db.deleteFrom('invite_links').where('link', '=', invite_link).execute()
ctx.revokeChatInviteLink(invite_link)
await db.deleteFrom('invite_links').where('link', '=', invite_link).execute()
await ctx.revokeChatInviteLink(invite_link)
}
if (!out.isExpectedUserJoined) {
db.updateTable('users').where(eb => eb.or([
await db.updateTable('users').where(eb => eb.or([
eb('tg_id', '=', out.expectedUserTgId),
eb('tg_id', '=', ctx.chatMember.from.id),
])).execute()
ctx.banChatMember(ctx.chatMember.from.id).catch()
await ctx.banChatMember(ctx.chatMember.from.id).catch()
}
return out

View File

@ -35,7 +35,7 @@ export const getActiveInviteLink = async (
const now = new Date()
const link = invite_links[0]
if (link.valid_until && link.valid_until < now) {
db.deleteFrom('invite_links')
await db.deleteFrom('invite_links')
.where('link', '=', link.link).execute()
return
}