Skip to content

Commit

Permalink
updateUserStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobrunia committed Nov 19, 2023
1 parent 7e1af96 commit 8fc7493
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions services/sqlwrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,14 @@ export async function returnFriends(userId: string) {
}
}

export async function updateUserStatus(
user_id: string,
): Promise<mysql.RowDataPacket[]> {
export async function updateUserStatus(user_id: string): Promise<mysql.RowDataPacket[]> {
try {
const currentTime = Math.floor(new Date().getTime() / 1000); // Unix-время в секундах
const targetTime = currentTime + (15 * 60); // Добавляем 15 минут к текущему времени в секундах

const results = await conn.query<RowDataPacket[]>(
'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) {
Expand Down

0 comments on commit 8fc7493

Please sign in to comment.