https://dev.kronoz.win/r/marzneshin.git
1import { UserType } from "@marzneshin/features/users";
2
3/**
4 * Checks whether the user has been online recently.
5 *
6 * This function compares the provided user's last online time with the current time
7 * to determine if the user has been online within a certain threshold.
8 *
9 * @param user - The user entity containing information about the user.
10 * @returns A boolean value indicating whether the user has been online recently.
11 */
12export const isUserOnline = (user: UserType): boolean => {
13 const utcUserOnlineTime = new Date(user.online_at + 'Z');
14 const currentTime = new Date();
15 const timeDifference = Math.abs(currentTime.getTime() - utcUserOnlineTime.getTime());
16 return timeDifference < 30000;
17};