Send updateUser when premium status expires.
This commit is contained in:
parent
df53830161
commit
085ac48a9f
@ -3416,6 +3416,9 @@ ContactsManager::ContactsManager(Td *td, ActorShared<> parent) : td_(td), parent
|
|||||||
user_online_timeout_.set_callback(on_user_online_timeout_callback);
|
user_online_timeout_.set_callback(on_user_online_timeout_callback);
|
||||||
user_online_timeout_.set_callback_data(static_cast<void *>(this));
|
user_online_timeout_.set_callback_data(static_cast<void *>(this));
|
||||||
|
|
||||||
|
user_emoji_status_timeout_.set_callback(on_user_emoji_status_timeout_callback);
|
||||||
|
user_emoji_status_timeout_.set_callback_data(static_cast<void *>(this));
|
||||||
|
|
||||||
channel_unban_timeout_.set_callback(on_channel_unban_timeout_callback);
|
channel_unban_timeout_.set_callback(on_channel_unban_timeout_callback);
|
||||||
channel_unban_timeout_.set_callback_data(static_cast<void *>(this));
|
channel_unban_timeout_.set_callback_data(static_cast<void *>(this));
|
||||||
|
|
||||||
@ -3505,6 +3508,28 @@ void ContactsManager::on_user_online_timeout(UserId user_id) {
|
|||||||
update_user_online_member_count(u);
|
update_user_online_member_count(u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContactsManager::on_user_emoji_status_timeout_callback(void *contacts_manager_ptr, int64 user_id_long) {
|
||||||
|
if (G()->close_flag()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto contacts_manager = static_cast<ContactsManager *>(contacts_manager_ptr);
|
||||||
|
send_closure_later(contacts_manager->actor_id(contacts_manager), &ContactsManager::on_user_emoji_status_timeout,
|
||||||
|
UserId(user_id_long));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContactsManager::on_user_emoji_status_timeout(UserId user_id) {
|
||||||
|
if (G()->close_flag()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto u = get_user(user_id);
|
||||||
|
CHECK(u != nullptr);
|
||||||
|
CHECK(u->is_update_user_sent);
|
||||||
|
|
||||||
|
update_user(u, user_id);
|
||||||
|
}
|
||||||
|
|
||||||
void ContactsManager::on_channel_unban_timeout_callback(void *contacts_manager_ptr, int64 channel_id_long) {
|
void ContactsManager::on_channel_unban_timeout_callback(void *contacts_manager_ptr, int64 channel_id_long) {
|
||||||
if (G()->close_flag()) {
|
if (G()->close_flag()) {
|
||||||
return;
|
return;
|
||||||
@ -10353,11 +10378,20 @@ void ContactsManager::update_user(User *u, UserId user_id, bool from_binlog, boo
|
|||||||
auto unix_time = G()->unix_time();
|
auto unix_time = G()->unix_time();
|
||||||
auto effective_custom_emoji_id = u->emoji_status.get_effective_custom_emoji_id(u->is_premium, unix_time);
|
auto effective_custom_emoji_id = u->emoji_status.get_effective_custom_emoji_id(u->is_premium, unix_time);
|
||||||
if (effective_custom_emoji_id != u->last_sent_emoji_status) {
|
if (effective_custom_emoji_id != u->last_sent_emoji_status) {
|
||||||
|
user_emoji_status_timeout_.cancel_timeout(user_id.get());
|
||||||
u->last_sent_emoji_status = effective_custom_emoji_id;
|
u->last_sent_emoji_status = effective_custom_emoji_id;
|
||||||
u->is_changed = true;
|
u->is_changed = true;
|
||||||
} else {
|
} else {
|
||||||
u->need_save_to_database = true;
|
u->need_save_to_database = true;
|
||||||
}
|
}
|
||||||
|
if (u->last_sent_emoji_status != 0) {
|
||||||
|
auto until_date = u->emoji_status.get_until_date();
|
||||||
|
auto left_time = until_date - unix_time;
|
||||||
|
if (left_time >= 0 && left_time < 30 * 86400) {
|
||||||
|
LOG(DEBUG) << "Set premium status timeout for " << user_id << " in " << left_time;
|
||||||
|
user_emoji_status_timeout_.set_timeout_in(user_id.get(), left_time);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (u->is_deleted) {
|
if (u->is_deleted) {
|
||||||
td_->inline_queries_manager_->remove_recent_inline_bot(user_id, Promise<>());
|
td_->inline_queries_manager_->remove_recent_inline_bot(user_id, Promise<>());
|
||||||
|
@ -1676,6 +1676,8 @@ class ContactsManager final : public Actor {
|
|||||||
|
|
||||||
static void on_user_online_timeout_callback(void *contacts_manager_ptr, int64 user_id_long);
|
static void on_user_online_timeout_callback(void *contacts_manager_ptr, int64 user_id_long);
|
||||||
|
|
||||||
|
static void on_user_emoji_status_timeout_callback(void *contacts_manager_ptr, int64 user_id_long);
|
||||||
|
|
||||||
static void on_channel_unban_timeout_callback(void *contacts_manager_ptr, int64 channel_id_long);
|
static void on_channel_unban_timeout_callback(void *contacts_manager_ptr, int64 channel_id_long);
|
||||||
|
|
||||||
static void on_user_nearby_timeout_callback(void *contacts_manager_ptr, int64 user_id_long);
|
static void on_user_nearby_timeout_callback(void *contacts_manager_ptr, int64 user_id_long);
|
||||||
@ -1688,6 +1690,8 @@ class ContactsManager final : public Actor {
|
|||||||
|
|
||||||
void on_user_online_timeout(UserId user_id);
|
void on_user_online_timeout(UserId user_id);
|
||||||
|
|
||||||
|
void on_user_emoji_status_timeout(UserId user_id);
|
||||||
|
|
||||||
void on_channel_unban_timeout(ChannelId channel_id);
|
void on_channel_unban_timeout(ChannelId channel_id);
|
||||||
|
|
||||||
void on_user_nearby_timeout(UserId user_id);
|
void on_user_nearby_timeout(UserId user_id);
|
||||||
@ -1861,6 +1865,7 @@ class ContactsManager final : public Actor {
|
|||||||
vector<int32> unimported_contact_invites_; // result of change_imported_contacts
|
vector<int32> unimported_contact_invites_; // result of change_imported_contacts
|
||||||
|
|
||||||
MultiTimeout user_online_timeout_{"UserOnlineTimeout"};
|
MultiTimeout user_online_timeout_{"UserOnlineTimeout"};
|
||||||
|
MultiTimeout user_emoji_status_timeout_{"UserEmojiStatusTimeout"};
|
||||||
MultiTimeout channel_unban_timeout_{"ChannelUnbanTimeout"};
|
MultiTimeout channel_unban_timeout_{"ChannelUnbanTimeout"};
|
||||||
MultiTimeout user_nearby_timeout_{"UserNearbyTimeout"};
|
MultiTimeout user_nearby_timeout_{"UserNearbyTimeout"};
|
||||||
MultiTimeout slow_mode_delay_timeout_{"SlowModeDelayTimeout"};
|
MultiTimeout slow_mode_delay_timeout_{"SlowModeDelayTimeout"};
|
||||||
|
@ -43,6 +43,10 @@ class EmojiStatus {
|
|||||||
return custom_emoji_id_ == 0;
|
return custom_emoji_id_ == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32 get_until_date() const {
|
||||||
|
return until_date_;
|
||||||
|
}
|
||||||
|
|
||||||
template <class StorerT>
|
template <class StorerT>
|
||||||
void store(StorerT &storer) const {
|
void store(StorerT &storer) const {
|
||||||
bool has_until_date = until_date_ != 0;
|
bool has_until_date = until_date_ != 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user