Move class NotificationGroupInfo to a separate header.
This commit is contained in:
parent
08ead89f31
commit
d2cf780a1f
|
@ -426,6 +426,7 @@ set(TDLIB_SOURCE
|
||||||
td/telegram/net/SessionProxy.cpp
|
td/telegram/net/SessionProxy.cpp
|
||||||
td/telegram/net/SessionMultiProxy.cpp
|
td/telegram/net/SessionMultiProxy.cpp
|
||||||
td/telegram/NewPasswordState.cpp
|
td/telegram/NewPasswordState.cpp
|
||||||
|
td/telegram/NotificationGroupInfo.cpp
|
||||||
td/telegram/NotificationManager.cpp
|
td/telegram/NotificationManager.cpp
|
||||||
td/telegram/NotificationSettingsScope.cpp
|
td/telegram/NotificationSettingsScope.cpp
|
||||||
td/telegram/NotificationSettingsManager.cpp
|
td/telegram/NotificationSettingsManager.cpp
|
||||||
|
@ -715,6 +716,7 @@ set(TDLIB_SOURCE
|
||||||
td/telegram/NewPasswordState.h
|
td/telegram/NewPasswordState.h
|
||||||
td/telegram/Notification.h
|
td/telegram/Notification.h
|
||||||
td/telegram/NotificationGroupId.h
|
td/telegram/NotificationGroupId.h
|
||||||
|
td/telegram/NotificationGroupInfo.h
|
||||||
td/telegram/NotificationGroupKey.h
|
td/telegram/NotificationGroupKey.h
|
||||||
td/telegram/NotificationGroupType.h
|
td/telegram/NotificationGroupType.h
|
||||||
td/telegram/NotificationId.h
|
td/telegram/NotificationId.h
|
||||||
|
@ -847,6 +849,7 @@ set(TDLIB_SOURCE
|
||||||
td/telegram/MessageReaction.hpp
|
td/telegram/MessageReaction.hpp
|
||||||
td/telegram/MessageReplyInfo.hpp
|
td/telegram/MessageReplyInfo.hpp
|
||||||
td/telegram/MinChannel.hpp
|
td/telegram/MinChannel.hpp
|
||||||
|
td/telegram/NotificationGroupInfo.hpp
|
||||||
td/telegram/OrderInfo.hpp
|
td/telegram/OrderInfo.hpp
|
||||||
td/telegram/Photo.hpp
|
td/telegram/Photo.hpp
|
||||||
td/telegram/PhotoSize.hpp
|
td/telegram/PhotoSize.hpp
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
#include "td/telegram/misc.h"
|
#include "td/telegram/misc.h"
|
||||||
#include "td/telegram/net/DcId.h"
|
#include "td/telegram/net/DcId.h"
|
||||||
#include "td/telegram/net/NetQuery.h"
|
#include "td/telegram/net/NetQuery.h"
|
||||||
|
#include "td/telegram/NotificationGroupInfo.hpp"
|
||||||
#include "td/telegram/NotificationGroupType.h"
|
#include "td/telegram/NotificationGroupType.h"
|
||||||
#include "td/telegram/NotificationManager.h"
|
#include "td/telegram/NotificationManager.h"
|
||||||
#include "td/telegram/NotificationSettingsManager.h"
|
#include "td/telegram/NotificationSettingsManager.h"
|
||||||
|
@ -5197,28 +5198,6 @@ void MessagesManager::Message::parse(ParserT &parser) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class StorerT>
|
|
||||||
void MessagesManager::NotificationGroupInfo::store(StorerT &storer) const {
|
|
||||||
using td::store;
|
|
||||||
store(group_id, storer);
|
|
||||||
store(last_notification_date, storer);
|
|
||||||
store(last_notification_id, storer);
|
|
||||||
store(max_removed_notification_id, storer);
|
|
||||||
store(max_removed_message_id, storer);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class ParserT>
|
|
||||||
void MessagesManager::NotificationGroupInfo::parse(ParserT &parser) {
|
|
||||||
using td::parse;
|
|
||||||
parse(group_id, parser);
|
|
||||||
parse(last_notification_date, parser);
|
|
||||||
parse(last_notification_id, parser);
|
|
||||||
parse(max_removed_notification_id, parser);
|
|
||||||
if (parser.version() >= static_cast<int32>(Version::AddNotificationGroupInfoMaxRemovedMessageId)) {
|
|
||||||
parse(max_removed_message_id, parser);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class StorerT>
|
template <class StorerT>
|
||||||
void MessagesManager::Dialog::store(StorerT &storer) const {
|
void MessagesManager::Dialog::store(StorerT &storer) const {
|
||||||
using td::store;
|
using td::store;
|
||||||
|
@ -28912,14 +28891,14 @@ void MessagesManager::send_update_new_message(const Dialog *d, const Message *m)
|
||||||
td_api::make_object<td_api::updateNewMessage>(get_message_object(d->dialog_id, m, "send_update_new_message")));
|
td_api::make_object<td_api::updateNewMessage>(get_message_object(d->dialog_id, m, "send_update_new_message")));
|
||||||
}
|
}
|
||||||
|
|
||||||
MessagesManager::NotificationGroupInfo &MessagesManager::get_notification_group_info(Dialog *d, bool from_mentions) {
|
NotificationGroupInfo &MessagesManager::get_notification_group_info(Dialog *d, bool from_mentions) {
|
||||||
CHECK(d != nullptr);
|
CHECK(d != nullptr);
|
||||||
auto notification_info = add_dialog_notification_info(d);
|
auto notification_info = add_dialog_notification_info(d);
|
||||||
return from_mentions ? notification_info->mention_notification_group_
|
return from_mentions ? notification_info->mention_notification_group_
|
||||||
: notification_info->message_notification_group_;
|
: notification_info->message_notification_group_;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessagesManager::NotificationGroupInfo &MessagesManager::get_notification_group_info(Dialog *d, const Message *m) {
|
NotificationGroupInfo &MessagesManager::get_notification_group_info(Dialog *d, const Message *m) {
|
||||||
return get_notification_group_info(d, is_from_mention_notification_group(m));
|
return get_notification_group_info(d, is_from_mention_notification_group(m));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37020,20 +36999,10 @@ void MessagesManager::fix_new_dialog(Dialog *d, unique_ptr<Message> &&last_datab
|
||||||
<< d->first_database_message_id << ", last database " << d->last_database_message_id << ", last "
|
<< d->first_database_message_id << ", last database " << d->last_database_message_id << ", last "
|
||||||
<< d->last_message_id << " with order " << d->order;
|
<< d->last_message_id << " with order " << d->order;
|
||||||
if (d->notification_info != nullptr) {
|
if (d->notification_info != nullptr) {
|
||||||
VLOG(notifications) << "Have " << dialog_id << " with message "
|
VLOG(notifications) << "Have " << dialog_id << " with message " << d->notification_info->message_notification_group_
|
||||||
<< d->notification_info->message_notification_group_.group_id << " with last "
|
|
||||||
<< d->notification_info->message_notification_group_.last_notification_id << " sent at "
|
|
||||||
<< d->notification_info->message_notification_group_.last_notification_date << ", max removed "
|
|
||||||
<< d->notification_info->message_notification_group_.max_removed_notification_id << "/"
|
|
||||||
<< d->notification_info->message_notification_group_.max_removed_message_id
|
|
||||||
<< " and new secret chat " << d->notification_info->new_secret_chat_notification_id_;
|
<< " and new secret chat " << d->notification_info->new_secret_chat_notification_id_;
|
||||||
VLOG(notifications) << "Have " << dialog_id << " with mention "
|
VLOG(notifications) << "Have " << dialog_id << " with mention " << d->notification_info->mention_notification_group_
|
||||||
<< d->notification_info->mention_notification_group_.group_id << " with last "
|
<< " and pinned " << d->notification_info->pinned_message_notification_message_id_;
|
||||||
<< d->notification_info->mention_notification_group_.last_notification_id << " sent at "
|
|
||||||
<< d->notification_info->mention_notification_group_.last_notification_date << ", max removed "
|
|
||||||
<< d->notification_info->mention_notification_group_.max_removed_notification_id << "/"
|
|
||||||
<< d->notification_info->mention_notification_group_.max_removed_message_id << " and pinned "
|
|
||||||
<< d->notification_info->pinned_message_notification_message_id_;
|
|
||||||
VLOG(notifications) << "In " << dialog_id << " have last_read_inbox_message_id = " << d->last_read_inbox_message_id
|
VLOG(notifications) << "In " << dialog_id << " have last_read_inbox_message_id = " << d->last_read_inbox_message_id
|
||||||
<< ", last_new_message_id = " << d->last_new_message_id
|
<< ", last_new_message_id = " << d->last_new_message_id
|
||||||
<< ", max_notification_message_id = " << d->notification_info->max_notification_message_id_;
|
<< ", max_notification_message_id = " << d->notification_info->max_notification_message_id_;
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#include "td/telegram/net/NetQuery.h"
|
#include "td/telegram/net/NetQuery.h"
|
||||||
#include "td/telegram/Notification.h"
|
#include "td/telegram/Notification.h"
|
||||||
#include "td/telegram/NotificationGroupId.h"
|
#include "td/telegram/NotificationGroupId.h"
|
||||||
|
#include "td/telegram/NotificationGroupInfo.h"
|
||||||
#include "td/telegram/NotificationGroupKey.h"
|
#include "td/telegram/NotificationGroupKey.h"
|
||||||
#include "td/telegram/NotificationGroupType.h"
|
#include "td/telegram/NotificationGroupType.h"
|
||||||
#include "td/telegram/NotificationId.h"
|
#include "td/telegram/NotificationId.h"
|
||||||
|
@ -1286,22 +1287,6 @@ class MessagesManager final : public Actor {
|
||||||
~Message() = default;
|
~Message() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NotificationGroupInfo {
|
|
||||||
NotificationGroupId group_id;
|
|
||||||
int32 last_notification_date = 0; // date of last notification in the group
|
|
||||||
NotificationId last_notification_id; // identifier of last notification in the group
|
|
||||||
NotificationId max_removed_notification_id; // notification identifier, up to which all notifications are removed
|
|
||||||
MessageId max_removed_message_id; // message identifier, up to which all notifications are removed
|
|
||||||
bool is_changed = false; // true, if the group needs to be saved to database
|
|
||||||
bool try_reuse = false; // true, if the group needs to be deleted from database and tried to be reused
|
|
||||||
|
|
||||||
template <class StorerT>
|
|
||||||
void store(StorerT &storer) const;
|
|
||||||
|
|
||||||
template <class ParserT>
|
|
||||||
void parse(ParserT &parser);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DialogScheduledMessages {
|
struct DialogScheduledMessages {
|
||||||
FlatHashMap<ScheduledServerMessageId, int32, ScheduledServerMessageIdHash> scheduled_message_date_;
|
FlatHashMap<ScheduledServerMessageId, int32, ScheduledServerMessageIdHash> scheduled_message_date_;
|
||||||
|
|
||||||
|
|
17
td/telegram/NotificationGroupInfo.cpp
Normal file
17
td/telegram/NotificationGroupInfo.cpp
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
//
|
||||||
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
#include "td/telegram/NotificationGroupInfo.h"
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
|
||||||
|
StringBuilder &operator<<(StringBuilder &string_builder, const NotificationGroupInfo &group_info) {
|
||||||
|
return string_builder << group_info.group_id << " with last " << group_info.last_notification_id << " sent at "
|
||||||
|
<< group_info.last_notification_date << ", max removed "
|
||||||
|
<< group_info.max_removed_notification_id << '/' << group_info.max_removed_message_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace td
|
33
td/telegram/NotificationGroupInfo.h
Normal file
33
td/telegram/NotificationGroupInfo.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
//
|
||||||
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "td/telegram/MessageId.h"
|
||||||
|
#include "td/telegram/NotificationGroupId.h"
|
||||||
|
#include "td/telegram/NotificationId.h"
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
|
||||||
|
struct NotificationGroupInfo {
|
||||||
|
NotificationGroupId group_id;
|
||||||
|
int32 last_notification_date = 0; // date of last notification in the group
|
||||||
|
NotificationId last_notification_id; // identifier of last notification in the group
|
||||||
|
NotificationId max_removed_notification_id; // notification identifier, up to which all notifications are removed
|
||||||
|
MessageId max_removed_message_id; // message identifier, up to which all notifications are removed
|
||||||
|
bool is_changed = false; // true, if the group needs to be saved to database
|
||||||
|
bool try_reuse = false; // true, if the group needs to be deleted from database and tried to be reused
|
||||||
|
|
||||||
|
template <class StorerT>
|
||||||
|
void store(StorerT &storer) const;
|
||||||
|
|
||||||
|
template <class ParserT>
|
||||||
|
void parse(ParserT &parser);
|
||||||
|
};
|
||||||
|
|
||||||
|
StringBuilder &operator<<(StringBuilder &string_builder, const NotificationGroupInfo &group_info);
|
||||||
|
|
||||||
|
} // namespace td
|
38
td/telegram/NotificationGroupInfo.hpp
Normal file
38
td/telegram/NotificationGroupInfo.hpp
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
//
|
||||||
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "td/telegram/NotificationGroupInfo.h"
|
||||||
|
|
||||||
|
#include "td/utils/common.h"
|
||||||
|
#include "td/utils/tl_helpers.h"
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
|
||||||
|
template <class StorerT>
|
||||||
|
void NotificationGroupInfo::store(StorerT &storer) const {
|
||||||
|
using td::store;
|
||||||
|
store(group_id, storer);
|
||||||
|
store(last_notification_date, storer);
|
||||||
|
store(last_notification_id, storer);
|
||||||
|
store(max_removed_notification_id, storer);
|
||||||
|
store(max_removed_message_id, storer);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class ParserT>
|
||||||
|
void NotificationGroupInfo::parse(ParserT &parser) {
|
||||||
|
using td::parse;
|
||||||
|
parse(group_id, parser);
|
||||||
|
parse(last_notification_date, parser);
|
||||||
|
parse(last_notification_id, parser);
|
||||||
|
parse(max_removed_notification_id, parser);
|
||||||
|
if (parser.version() >= static_cast<int32>(Version::AddNotificationGroupInfoMaxRemovedMessageId)) {
|
||||||
|
parse(max_removed_message_id, parser);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace td
|
Loading…
Reference in New Issue
Block a user