Add td_api::chatFilterInviteLink.

This commit is contained in:
levlam 2023-03-24 17:06:09 +03:00
parent debf8f5f68
commit 9a85e4df1c
4 changed files with 103 additions and 0 deletions

View File

@ -321,6 +321,7 @@ set(TDLIB_SOURCE
td/telegram/DialogDb.cpp
td/telegram/DialogEventLog.cpp
td/telegram/DialogFilter.cpp
td/telegram/DialogFilterInviteLink.cpp
td/telegram/DialogId.cpp
td/telegram/DialogInviteLink.cpp
td/telegram/DialogLocation.cpp
@ -559,6 +560,7 @@ set(TDLIB_SOURCE
td/telegram/DialogEventLog.h
td/telegram/DialogFilter.h
td/telegram/DialogFilterId.h
td/telegram/DialogFilterInviteLink.h
td/telegram/DialogId.h
td/telegram/DialogInviteLink.h
td/telegram/DialogListId.h

View File

@ -1314,6 +1314,12 @@ chatFilter title:string icon_name:string pinned_chat_ids:vector<int53> included_
//-"Favorite", "Flower", "Game", "Home", "Love", "Mask", "Party", "Sport", "Study", "Trade", "Travel", "Work", "Airplane", "Book", "Light", "Like", "Money", "Note", "Palette"
chatFilterInfo id:int32 title:string icon_name:string = ChatFilterInfo;
//@description Contains a chat filter invite link
//@invite_link The chat filter invite link
//@name Name of the link
//@chat_ids Identifiers of chats, included in the link
chatFilterInviteLink invite_link:string name:string chat_ids:vector<int53> = ChatFilterInviteLink;
//@description Describes a recommended chat filter @filter The chat filter @param_description Chat filter description
recommendedChatFilter filter:chatFilter description:string = RecommendedChatFilter;

View File

@ -0,0 +1,46 @@
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// 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/DialogFilterInviteLink.h"
#include "td/telegram/MessagesManager.h"
#include "td/telegram/Td.h"
namespace td {
DialogFilterInviteLink::DialogFilterInviteLink(
Td *td, telegram_api::object_ptr<telegram_api::exportedChatlistInvite> exported_invite) {
CHECK(exported_invite != nullptr);
invite_link_ = std::move(exported_invite->url_);
title_ = std::move(exported_invite->title_);
for (const auto &peer : exported_invite->peers_) {
DialogId dialog_id(peer);
if (dialog_id.is_valid()) {
td->messages_manager_->force_create_dialog(dialog_id, "DialogFilterInviteLink");
dialog_ids_.push_back(dialog_id);
}
}
}
td_api::object_ptr<td_api::chatFilterInviteLink> DialogFilterInviteLink::get_chat_filter_invite_link_object() const {
return td_api::make_object<td_api::chatFilterInviteLink>(
invite_link_, title_, transform(dialog_ids_, [](DialogId dialog_id) { return dialog_id.get(); }));
}
bool operator==(const DialogFilterInviteLink &lhs, const DialogFilterInviteLink &rhs) {
return lhs.invite_link_ == rhs.invite_link_ && lhs.title_ == rhs.title_ && lhs.dialog_ids_ == rhs.dialog_ids_;
}
bool operator!=(const DialogFilterInviteLink &lhs, const DialogFilterInviteLink &rhs) {
return !(lhs == rhs);
}
StringBuilder &operator<<(StringBuilder &string_builder, const DialogFilterInviteLink &invite_link) {
return string_builder << "FolderInviteLink[" << invite_link.invite_link_ << '(' << invite_link.title_ << ')'
<< invite_link.dialog_ids_ << ']';
}
} // namespace td

View File

@ -0,0 +1,49 @@
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// 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/DialogId.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/utils/algorithm.h"
#include "td/utils/common.h"
#include "td/utils/Slice.h"
#include "td/utils/StringBuilder.h"
namespace td {
class Td;
class DialogFilterInviteLink {
string invite_link_;
string title_;
vector<DialogId> dialog_ids_;
friend bool operator==(const DialogFilterInviteLink &lhs, const DialogFilterInviteLink &rhs);
friend StringBuilder &operator<<(StringBuilder &string_builder, const DialogFilterInviteLink &invite_link);
public:
DialogFilterInviteLink() = default;
DialogFilterInviteLink(Td *td, telegram_api::object_ptr<telegram_api::exportedChatlistInvite> exported_invite);
td_api::object_ptr<td_api::chatFilterInviteLink> get_chat_filter_invite_link_object() const;
bool is_valid() const {
return !invite_link_.empty();
}
};
bool operator==(const DialogFilterInviteLink &lhs, const DialogFilterInviteLink &rhs);
bool operator!=(const DialogFilterInviteLink &lhs, const DialogFilterInviteLink &rhs);
StringBuilder &operator<<(StringBuilder &string_builder, const DialogFilterInviteLink &invite_link);
} // namespace td