Skip to content

Commit

Permalink
Add td_api::chatFilterInviteLink.
Browse files Browse the repository at this point in the history
  • Loading branch information
levlam committed Mar 24, 2023
1 parent debf8f5 commit 9a85e4d
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions td/generate/scheme/td_api.tl
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
46 changes: 46 additions & 0 deletions td/telegram/DialogFilterInviteLink.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// Copyright Aliaksei Levin ([email protected]), Arseny Smirnov ([email protected]) 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
49 changes: 49 additions & 0 deletions td/telegram/DialogFilterInviteLink.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// Copyright Aliaksei Levin ([email protected]), Arseny Smirnov ([email protected]) 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

0 comments on commit 9a85e4d

Please sign in to comment.