aboutsummaryrefslogtreecommitdiffhomepage
path: root/td/telegram/NotificationGroupType.cpp
blob: 8508ebeaa4de82eab023d0ac06f4a50574b05b94 (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
//
// 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)
//
#include "td/telegram/NotificationGroupType.h"

namespace td {

bool is_database_notification_group_type(NotificationGroupType type) {
  switch (type) {
    case NotificationGroupType::Messages:
    case NotificationGroupType::Mentions:
    case NotificationGroupType::SecretChat:
      return true;
    case NotificationGroupType::Calls:
      return false;
    default:
      UNREACHABLE();
      return false;
  }
}

bool is_partial_notification_group_type(NotificationGroupType type) {
  switch (type) {
    case NotificationGroupType::Messages:
    case NotificationGroupType::Mentions:
      return true;
    case NotificationGroupType::SecretChat:
    case NotificationGroupType::Calls:
      return false;
    default:
      UNREACHABLE();
      return false;
  }
}

td_api::object_ptr<td_api::NotificationGroupType> get_notification_group_type_object(NotificationGroupType type) {
  switch (type) {
    case NotificationGroupType::Messages:
      return td_api::make_object<td_api::notificationGroupTypeMessages>();
    case NotificationGroupType::Mentions:
      return td_api::make_object<td_api::notificationGroupTypeMentions>();
    case NotificationGroupType::SecretChat:
      return td_api::make_object<td_api::notificationGroupTypeSecretChat>();
    case NotificationGroupType::Calls:
      return td_api::make_object<td_api::notificationGroupTypeCalls>();
    default:
      UNREACHABLE();
      return nullptr;
  }
}

NotificationGroupType get_notification_group_type(const td_api::object_ptr<td_api::NotificationGroupType> &type) {
  CHECK(type != nullptr);
  switch (type->get_id()) {
    case td_api::notificationGroupTypeMessages::ID:
      return NotificationGroupType::Messages;
    case td_api::notificationGroupTypeMentions::ID:
      return NotificationGroupType::Mentions;
    case td_api::notificationGroupTypeSecretChat::ID:
      return NotificationGroupType::SecretChat;
    case td_api::notificationGroupTypeCalls::ID:
      return NotificationGroupType::Calls;
    default:
      UNREACHABLE();
      return NotificationGroupType::Calls;
  }
}

StringBuilder &operator<<(StringBuilder &string_builder, const NotificationGroupType &type) {
  switch (type) {
    case NotificationGroupType::Messages:
      return string_builder << "Messages";
    case NotificationGroupType::Mentions:
      return string_builder << "Mentions";
    case NotificationGroupType::SecretChat:
      return string_builder << "SecretChat";
    case NotificationGroupType::Calls:
      return string_builder << "Calls";
    default:
      UNREACHABLE();
      return string_builder;
  }
}

}  // namespace td