2020-06-02 12:58:53 +02:00
|
|
|
//
|
2024-01-01 01:07:21 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
2020-06-02 12:58:53 +02:00
|
|
|
//
|
|
|
|
// 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/DialogFilter.h"
|
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
|
|
|
#include "td/utils/tl_helpers.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
|
|
|
template <class StorerT>
|
|
|
|
void DialogFilter::store(StorerT &storer) const {
|
|
|
|
using td::store;
|
2023-03-23 15:26:24 +01:00
|
|
|
bool has_pinned_dialog_ids = !pinned_dialog_ids_.empty();
|
|
|
|
bool has_included_dialog_ids = !included_dialog_ids_.empty();
|
|
|
|
bool has_excluded_dialog_ids = !excluded_dialog_ids_.empty();
|
2024-03-01 13:57:30 +01:00
|
|
|
bool has_color_id = color_id_ != -1;
|
2020-06-02 12:58:53 +02:00
|
|
|
BEGIN_STORE_FLAGS();
|
2023-03-23 15:26:24 +01:00
|
|
|
STORE_FLAG(exclude_muted_);
|
|
|
|
STORE_FLAG(exclude_read_);
|
|
|
|
STORE_FLAG(exclude_archived_);
|
|
|
|
STORE_FLAG(include_contacts_);
|
|
|
|
STORE_FLAG(include_non_contacts_);
|
|
|
|
STORE_FLAG(include_bots_);
|
|
|
|
STORE_FLAG(include_groups_);
|
|
|
|
STORE_FLAG(include_channels_);
|
2020-06-02 12:58:53 +02:00
|
|
|
STORE_FLAG(has_pinned_dialog_ids);
|
|
|
|
STORE_FLAG(has_included_dialog_ids);
|
|
|
|
STORE_FLAG(has_excluded_dialog_ids);
|
2023-03-24 13:32:47 +01:00
|
|
|
STORE_FLAG(is_shareable_);
|
2023-04-03 14:06:37 +02:00
|
|
|
STORE_FLAG(has_my_invites_);
|
2024-03-01 13:57:30 +01:00
|
|
|
STORE_FLAG(has_color_id);
|
2020-06-02 12:58:53 +02:00
|
|
|
END_STORE_FLAGS();
|
2023-03-23 15:26:24 +01:00
|
|
|
store(dialog_filter_id_, storer);
|
|
|
|
store(title_, storer);
|
|
|
|
store(emoji_, storer);
|
2020-06-02 12:58:53 +02:00
|
|
|
if (has_pinned_dialog_ids) {
|
2023-03-23 15:26:24 +01:00
|
|
|
store(pinned_dialog_ids_, storer);
|
2020-06-02 12:58:53 +02:00
|
|
|
}
|
|
|
|
if (has_included_dialog_ids) {
|
2023-03-23 15:26:24 +01:00
|
|
|
store(included_dialog_ids_, storer);
|
2020-06-02 12:58:53 +02:00
|
|
|
}
|
|
|
|
if (has_excluded_dialog_ids) {
|
2023-03-23 15:26:24 +01:00
|
|
|
store(excluded_dialog_ids_, storer);
|
2020-06-02 12:58:53 +02:00
|
|
|
}
|
2024-03-01 13:57:30 +01:00
|
|
|
if (has_color_id) {
|
|
|
|
store(color_id_, storer);
|
|
|
|
}
|
2020-06-02 12:58:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void DialogFilter::parse(ParserT &parser) {
|
|
|
|
using td::parse;
|
2022-04-24 21:43:43 +02:00
|
|
|
bool has_pinned_dialog_ids;
|
|
|
|
bool has_included_dialog_ids;
|
|
|
|
bool has_excluded_dialog_ids;
|
2024-03-01 13:57:30 +01:00
|
|
|
bool has_color_id;
|
2020-06-02 12:58:53 +02:00
|
|
|
BEGIN_PARSE_FLAGS();
|
2023-03-23 15:26:24 +01:00
|
|
|
PARSE_FLAG(exclude_muted_);
|
|
|
|
PARSE_FLAG(exclude_read_);
|
|
|
|
PARSE_FLAG(exclude_archived_);
|
|
|
|
PARSE_FLAG(include_contacts_);
|
|
|
|
PARSE_FLAG(include_non_contacts_);
|
|
|
|
PARSE_FLAG(include_bots_);
|
|
|
|
PARSE_FLAG(include_groups_);
|
|
|
|
PARSE_FLAG(include_channels_);
|
2020-06-02 12:58:53 +02:00
|
|
|
PARSE_FLAG(has_pinned_dialog_ids);
|
|
|
|
PARSE_FLAG(has_included_dialog_ids);
|
|
|
|
PARSE_FLAG(has_excluded_dialog_ids);
|
2023-03-24 13:32:47 +01:00
|
|
|
PARSE_FLAG(is_shareable_);
|
2023-04-03 14:06:37 +02:00
|
|
|
PARSE_FLAG(has_my_invites_);
|
2024-03-01 13:57:30 +01:00
|
|
|
PARSE_FLAG(has_color_id);
|
2020-06-02 12:58:53 +02:00
|
|
|
END_PARSE_FLAGS();
|
2023-03-23 15:26:24 +01:00
|
|
|
parse(dialog_filter_id_, parser);
|
|
|
|
parse(title_, parser);
|
|
|
|
parse(emoji_, parser);
|
2020-06-02 12:58:53 +02:00
|
|
|
if (has_pinned_dialog_ids) {
|
2023-03-23 15:26:24 +01:00
|
|
|
parse(pinned_dialog_ids_, parser);
|
2020-06-02 12:58:53 +02:00
|
|
|
}
|
|
|
|
if (has_included_dialog_ids) {
|
2023-03-23 15:26:24 +01:00
|
|
|
parse(included_dialog_ids_, parser);
|
2020-06-02 12:58:53 +02:00
|
|
|
}
|
|
|
|
if (has_excluded_dialog_ids) {
|
2023-03-23 15:26:24 +01:00
|
|
|
parse(excluded_dialog_ids_, parser);
|
2020-06-02 12:58:53 +02:00
|
|
|
}
|
2024-03-01 13:57:30 +01:00
|
|
|
if (has_color_id) {
|
|
|
|
parse(color_id_, parser);
|
|
|
|
} else {
|
|
|
|
color_id_ = -1;
|
|
|
|
}
|
2020-06-02 12:58:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace td
|