2023-07-03 15:03:28 +02:00
|
|
|
//
|
2024-01-01 01:07:21 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
2023-07-03 15:03:28 +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/StoryInteractionInfo.h"
|
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
|
|
|
#include "td/utils/tl_helpers.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
|
|
|
template <class StorerT>
|
|
|
|
void StoryInteractionInfo::store(StorerT &storer) const {
|
|
|
|
using td::store;
|
|
|
|
bool has_recent_viewer_user_ids = !recent_viewer_user_ids_.empty();
|
2023-08-04 14:32:24 +02:00
|
|
|
bool has_reaction_count = reaction_count_ > 0;
|
2023-08-13 23:29:57 +02:00
|
|
|
bool know_has_viewers = true;
|
2023-09-18 21:00:38 +02:00
|
|
|
bool has_forward_count = forward_count_ > 0;
|
2023-09-19 12:09:59 +02:00
|
|
|
bool has_reaction_counts = !reaction_counts_.empty();
|
2023-07-03 15:03:28 +02:00
|
|
|
BEGIN_STORE_FLAGS();
|
|
|
|
STORE_FLAG(has_recent_viewer_user_ids);
|
2023-08-04 14:32:24 +02:00
|
|
|
STORE_FLAG(has_reaction_count);
|
2023-08-13 23:29:57 +02:00
|
|
|
STORE_FLAG(know_has_viewers);
|
|
|
|
STORE_FLAG(has_viewers_);
|
2023-09-18 21:00:38 +02:00
|
|
|
STORE_FLAG(has_forward_count);
|
2023-09-19 12:09:59 +02:00
|
|
|
STORE_FLAG(has_reaction_counts);
|
2023-07-03 15:03:28 +02:00
|
|
|
END_STORE_FLAGS();
|
|
|
|
store(view_count_, storer);
|
|
|
|
if (has_recent_viewer_user_ids) {
|
|
|
|
store(recent_viewer_user_ids_, storer);
|
|
|
|
}
|
2023-08-04 14:32:24 +02:00
|
|
|
if (has_reaction_count) {
|
|
|
|
store(reaction_count_, storer);
|
|
|
|
}
|
2023-09-18 21:00:38 +02:00
|
|
|
if (has_forward_count) {
|
|
|
|
store(forward_count_, storer);
|
|
|
|
}
|
2023-09-19 12:09:59 +02:00
|
|
|
if (has_reaction_counts) {
|
|
|
|
store(reaction_counts_, storer);
|
|
|
|
}
|
2023-07-03 15:03:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void StoryInteractionInfo::parse(ParserT &parser) {
|
|
|
|
using td::parse;
|
|
|
|
bool has_recent_viewer_user_ids;
|
2023-08-04 14:32:24 +02:00
|
|
|
bool has_reaction_count;
|
2023-08-13 23:29:57 +02:00
|
|
|
bool know_has_viewers;
|
2023-09-18 21:00:38 +02:00
|
|
|
bool has_forward_count;
|
2023-09-19 12:09:59 +02:00
|
|
|
bool has_reaction_counts;
|
2023-07-03 15:03:28 +02:00
|
|
|
BEGIN_PARSE_FLAGS();
|
|
|
|
PARSE_FLAG(has_recent_viewer_user_ids);
|
2023-08-04 14:32:24 +02:00
|
|
|
PARSE_FLAG(has_reaction_count);
|
2023-08-13 23:29:57 +02:00
|
|
|
PARSE_FLAG(know_has_viewers);
|
|
|
|
PARSE_FLAG(has_viewers_);
|
2023-09-18 21:00:38 +02:00
|
|
|
PARSE_FLAG(has_forward_count);
|
2023-09-19 12:09:59 +02:00
|
|
|
PARSE_FLAG(has_reaction_counts);
|
2023-07-03 15:03:28 +02:00
|
|
|
END_PARSE_FLAGS();
|
|
|
|
parse(view_count_, parser);
|
|
|
|
if (has_recent_viewer_user_ids) {
|
|
|
|
parse(recent_viewer_user_ids_, parser);
|
|
|
|
}
|
2023-08-04 14:32:24 +02:00
|
|
|
if (has_reaction_count) {
|
|
|
|
parse(reaction_count_, parser);
|
|
|
|
}
|
2023-09-18 21:00:38 +02:00
|
|
|
if (has_forward_count) {
|
|
|
|
parse(forward_count_, parser);
|
|
|
|
}
|
2023-09-19 12:09:59 +02:00
|
|
|
if (has_reaction_counts) {
|
|
|
|
parse(reaction_counts_, parser);
|
|
|
|
}
|
2023-09-18 21:00:38 +02:00
|
|
|
|
2023-08-13 23:29:57 +02:00
|
|
|
if (!know_has_viewers) {
|
|
|
|
has_viewers_ = (view_count_ > 0 && !has_recent_viewer_user_ids) || reaction_count_ > 0;
|
|
|
|
}
|
2023-07-03 15:03:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace td
|