aboutsummaryrefslogtreecommitdiffhomepage
path: root/td/telegram/DialogFilter.hpp
blob: 5349bf81cd70a204399a59c701a76f18c16ffdb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2026
//
// 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;
  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();
  bool has_color_id = color_id_ != -1;
  bool has_title_entities = !title_.entities.empty();
  BEGIN_STORE_FLAGS();
  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_);
  STORE_FLAG(has_pinned_dialog_ids);
  STORE_FLAG(has_included_dialog_ids);
  STORE_FLAG(has_excluded_dialog_ids);
  STORE_FLAG(is_shareable_);
  STORE_FLAG(has_my_invites_);
  STORE_FLAG(has_color_id);
  STORE_FLAG(has_title_entities);
  STORE_FLAG(animate_title_);
  END_STORE_FLAGS();
  store(dialog_filter_id_, storer);
  store(title_.text, storer);
  if (has_title_entities) {
    store(title_.entities, storer);
  }
  store(emoji_, storer);
  if (has_pinned_dialog_ids) {
    store(pinned_dialog_ids_, storer);
  }
  if (has_included_dialog_ids) {
    store(included_dialog_ids_, storer);
  }
  if (has_excluded_dialog_ids) {
    store(excluded_dialog_ids_, storer);
  }
  if (has_color_id) {
    store(color_id_, storer);
  }
}

template <class ParserT>
void DialogFilter::parse(ParserT &parser) {
  using td::parse;
  bool has_pinned_dialog_ids;
  bool has_included_dialog_ids;
  bool has_excluded_dialog_ids;
  bool has_color_id;
  bool has_title_entities;
  BEGIN_PARSE_FLAGS();
  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_);
  PARSE_FLAG(has_pinned_dialog_ids);
  PARSE_FLAG(has_included_dialog_ids);
  PARSE_FLAG(has_excluded_dialog_ids);
  PARSE_FLAG(is_shareable_);
  PARSE_FLAG(has_my_invites_);
  PARSE_FLAG(has_color_id);
  PARSE_FLAG(has_title_entities);
  PARSE_FLAG(animate_title_);
  END_PARSE_FLAGS();
  parse(dialog_filter_id_, parser);
  parse(title_.text, parser);
  if (has_title_entities) {
    parse(title_.entities, parser);
    keep_only_custom_emoji(title_);
  }
  parse(emoji_, parser);
  if (has_pinned_dialog_ids) {
    parse(pinned_dialog_ids_, parser);
  }
  if (has_included_dialog_ids) {
    parse(included_dialog_ids_, parser);
  }
  if (has_excluded_dialog_ids) {
    parse(excluded_dialog_ids_, parser);
  }
  if (has_color_id) {
    parse(color_id_, parser);
  } else {
    color_id_ = -1;
  }
}

}  // namespace td