From 8fc7493a737ebc76d83fc0af861f0391fadb3e05 Mon Sep 17 00:00:00 2001 From: Dobrunia Date: Sun, 19 Nov 2023 17:54:01 +0300 Subject: [PATCH] updateUserStatus --- services/sqlwrapper.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/services/sqlwrapper.ts b/services/sqlwrapper.ts index 9b72240..cd7b09b 100644 --- a/services/sqlwrapper.ts +++ b/services/sqlwrapper.ts @@ -318,13 +318,14 @@ export async function returnFriends(userId: string) { } } -export async function updateUserStatus( - user_id: string, -): Promise { +export async function updateUserStatus(user_id: string): Promise { try { + const currentTime = Math.floor(new Date().getTime() / 1000); // Unix-время в секундах + const targetTime = currentTime + (15 * 60); // Добавляем 15 минут к текущему времени в секундах + const results = await conn.query( - 'UPDATE users SET status = NOW() WHERE id = ?', - [user_id], + 'UPDATE users SET status = FROM_UNIXTIME(?) WHERE id = ?', + [targetTime, user_id], ); return results[0]; } catch (ex) {