Add ContactsManager::get_user_was_online.

This commit is contained in:
levlam 2024-03-03 01:39:00 +03:00
parent 854b054ed6
commit 958f6ddffd
2 changed files with 9 additions and 0 deletions

View File

@ -15162,6 +15162,13 @@ bool ContactsManager::is_user_online(UserId user_id, int32 tolerance, int32 unix
return was_online > unix_time - tolerance; return was_online > unix_time - tolerance;
} }
int32 ContactsManager::get_user_was_online(UserId user_id, int32 unix_time) const {
if (unix_time <= 0) {
unix_time = G()->unix_time();
}
return get_user_was_online(get_user(user_id), user_id, unix_time);
}
bool ContactsManager::is_user_status_exact(UserId user_id) const { bool ContactsManager::is_user_status_exact(UserId user_id) const {
auto u = get_user(user_id); auto u = get_user(user_id);
return u != nullptr && !u->is_deleted && !u->is_bot && u->was_online > 0; return u != nullptr && !u->is_deleted && !u->is_bot && u->was_online > 0;

View File

@ -572,6 +572,8 @@ class ContactsManager final : public Actor {
bool is_user_online(UserId user_id, int32 tolerance = 0, int32 unix_time = 0) const; bool is_user_online(UserId user_id, int32 tolerance = 0, int32 unix_time = 0) const;
int32 get_user_was_online(UserId user_id, int32 unix_time = 0) const;
bool is_user_status_exact(UserId user_id) const; bool is_user_status_exact(UserId user_id) const;
bool can_report_user(UserId user_id) const; bool can_report_user(UserId user_id) const;