2024-02-26 18:27:17 +01:00
|
|
|
//
|
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
|
|
|
//
|
|
|
|
// 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/BusinessAwayMessage.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
2024-02-27 00:07:21 +01:00
|
|
|
BusinessAwayMessage::BusinessAwayMessage(telegram_api::object_ptr<telegram_api::businessAwayMessage> away_message) {
|
|
|
|
if (away_message == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
shortcut_id_ = QuickReplyShortcutId(away_message->shortcut_id_);
|
|
|
|
recipients_ = BusinessRecipients(std::move(away_message->recipients_));
|
|
|
|
schedule_ = BusinessAwayMessageSchedule(std::move(away_message->schedule_));
|
2024-03-01 12:44:42 +01:00
|
|
|
offline_only_ = away_message->offline_only_;
|
2024-02-26 18:27:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
BusinessAwayMessage::BusinessAwayMessage(td_api::object_ptr<td_api::businessAwayMessageSettings> away_message) {
|
|
|
|
if (away_message == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
shortcut_id_ = QuickReplyShortcutId(away_message->shortcut_id_);
|
|
|
|
recipients_ = BusinessRecipients(std::move(away_message->recipients_));
|
|
|
|
schedule_ = BusinessAwayMessageSchedule(std::move(away_message->schedule_));
|
2024-03-01 12:44:42 +01:00
|
|
|
offline_only_ = away_message->offline_only_;
|
2024-02-26 18:27:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
td_api::object_ptr<td_api::businessAwayMessageSettings> BusinessAwayMessage::get_business_away_message_settings_object(
|
|
|
|
Td *td) const {
|
2024-02-27 00:07:21 +01:00
|
|
|
if (is_empty()) {
|
2024-02-26 18:27:17 +01:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return td_api::make_object<td_api::businessAwayMessageSettings>(
|
|
|
|
shortcut_id_.get(), recipients_.get_business_recipients_object(td),
|
2024-03-01 12:44:42 +01:00
|
|
|
schedule_.get_business_away_message_schedule_object(), offline_only_);
|
2024-02-26 18:27:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
telegram_api::object_ptr<telegram_api::inputBusinessAwayMessage> BusinessAwayMessage::get_input_business_away_message(
|
|
|
|
Td *td) const {
|
|
|
|
int32 flags = 0;
|
2024-03-01 12:44:42 +01:00
|
|
|
if (offline_only_) {
|
|
|
|
flags |= telegram_api::inputBusinessAwayMessage::OFFLINE_ONLY_MASK;
|
|
|
|
}
|
2024-02-26 18:27:17 +01:00
|
|
|
return telegram_api::make_object<telegram_api::inputBusinessAwayMessage>(
|
|
|
|
flags, false /*ignored*/, shortcut_id_.get(), schedule_.get_input_business_away_message_schedule(),
|
|
|
|
recipients_.get_input_business_recipients(td));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const BusinessAwayMessage &lhs, const BusinessAwayMessage &rhs) {
|
2024-03-01 12:44:42 +01:00
|
|
|
return lhs.shortcut_id_ == rhs.shortcut_id_ && lhs.recipients_ == rhs.recipients_ && lhs.schedule_ == rhs.schedule_ &&
|
|
|
|
lhs.offline_only_ == rhs.offline_only_;
|
2024-02-26 18:27:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, const BusinessAwayMessage &away_message) {
|
|
|
|
return string_builder << "away message " << away_message.shortcut_id_ << ' ' << away_message.recipients_ << ' '
|
2024-03-01 12:44:42 +01:00
|
|
|
<< away_message.schedule_ << (away_message.offline_only_ ? " only offline" : "");
|
2024-02-26 18:27:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace td
|