forked from telegramdesktop/tdesktop
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
323 changed files
with
10,867 additions
and
2,094 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+681 Bytes
Telegram/Resources/icons/settings/premium/business/business_intro.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.26 KB
Telegram/Resources/icons/settings/premium/business/business_intro@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.91 KB
Telegram/Resources/icons/settings/premium/business/business_intro@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+733 Bytes
Telegram/Resources/icons/settings/premium/business/business_links.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.32 KB
Telegram/Resources/icons/settings/premium/business/business_links@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.96 KB
Telegram/Resources/icons/settings/premium/business/business_links@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+748 Bytes
Telegram/Resources/icons/settings/premium/promo/business_chatbot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.38 KB
Telegram/Resources/icons/settings/premium/promo/business_chatbot@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.97 KB
Telegram/Resources/icons/settings/premium/promo/business_chatbot@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+873 Bytes
Telegram/Resources/icons/settings/premium/promo/business_chatlink.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.69 KB
Telegram/Resources/icons/settings/premium/promo/business_chatlink@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.39 KB
Telegram/Resources/icons/settings/premium/promo/business_chatlink@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+784 Bytes
Telegram/Resources/icons/settings/premium/promo/business_greeting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.53 KB
Telegram/Resources/icons/settings/premium/promo/business_greeting@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.29 KB
Telegram/Resources/icons/settings/premium/promo/business_greeting@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.13 KB
Telegram/Resources/icons/settings/premium/promo/business_hours@2x.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file added
BIN
+940 Bytes
Telegram/Resources/icons/settings/premium/promo/business_intro@2x.png
Oops, something went wrong.
Binary file added
BIN
+1.35 KB
Telegram/Resources/icons/settings/premium/promo/business_intro@3x.png
Oops, something went wrong.
Binary file added
BIN
+760 Bytes
Telegram/Resources/icons/settings/premium/promo/business_location.png
Oops, something went wrong.
Binary file added
BIN
+1.41 KB
Telegram/Resources/icons/settings/premium/promo/business_location@2x.png
Oops, something went wrong.
Binary file added
BIN
+2.06 KB
Telegram/Resources/icons/settings/premium/promo/business_location@3x.png
Oops, something went wrong.
Binary file added
BIN
+751 Bytes
Telegram/Resources/icons/settings/premium/promo/business_quickreply.png
Oops, something went wrong.
Binary file added
BIN
+1.39 KB
Telegram/Resources/icons/settings/premium/promo/business_quickreply@2x.png
Oops, something went wrong.
Binary file added
BIN
+2.04 KB
Telegram/Resources/icons/settings/premium/promo/business_quickreply@3x.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
/* | ||
This file is part of Telegram Desktop, | ||
the official desktop application for the Telegram messaging service. | ||
For license and copyright information please follow this link: | ||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL | ||
*/ | ||
#include "api/api_chat_links.h" | ||
|
||
#include "api/api_text_entities.h" | ||
#include "apiwrap.h" | ||
#include "data/data_session.h" | ||
#include "main/main_session.h" | ||
|
||
namespace Api { | ||
namespace { | ||
|
||
[[nodiscard]] ChatLink FromMTP( | ||
not_null<Main::Session*> session, | ||
const MTPBusinessChatLink &link) { | ||
const auto &data = link.data(); | ||
return { | ||
.link = qs(data.vlink()), | ||
.title = qs(data.vtitle().value_or_empty()), | ||
.message = { | ||
qs(data.vmessage()), | ||
EntitiesFromMTP( | ||
session, | ||
data.ventities().value_or_empty()) | ||
}, | ||
.clicks = data.vviews().v, | ||
}; | ||
} | ||
|
||
[[nodiscard]] MTPInputBusinessChatLink ToMTP( | ||
not_null<Main::Session*> session, | ||
const QString &title, | ||
const TextWithEntities &message) { | ||
auto entities = EntitiesToMTP( | ||
session, | ||
message.entities, | ||
ConvertOption::SkipLocal); | ||
using Flag = MTPDinputBusinessChatLink::Flag; | ||
const auto flags = (title.isEmpty() ? Flag() : Flag::f_title) | ||
| (entities.v.isEmpty() ? Flag() : Flag::f_entities); | ||
return MTP_inputBusinessChatLink( | ||
MTP_flags(flags), | ||
MTP_string(message.text), | ||
std::move(entities), | ||
MTP_string(title)); | ||
} | ||
|
||
} // namespace | ||
|
||
ChatLinks::ChatLinks(not_null<ApiWrap*> api) : _api(api) { | ||
} | ||
|
||
void ChatLinks::create( | ||
const QString &title, | ||
const TextWithEntities &message, | ||
Fn<void(Link)> done) { | ||
const auto session = &_api->session(); | ||
_api->request(MTPaccount_CreateBusinessChatLink( | ||
ToMTP(session, title, message) | ||
)).done([=](const MTPBusinessChatLink &result) { | ||
const auto link = FromMTP(session, result); | ||
_list.push_back(link); | ||
_updates.fire({ .was = QString(), .now = link }); | ||
if (done) done(link); | ||
}).fail([=](const MTP::Error &error) { | ||
const auto type = error.type(); | ||
if (done) done(Link()); | ||
}).send(); | ||
} | ||
|
||
void ChatLinks::edit( | ||
const QString &link, | ||
const QString &title, | ||
const TextWithEntities &message, | ||
Fn<void(Link)> done) { | ||
const auto session = &_api->session(); | ||
_api->request(MTPaccount_EditBusinessChatLink( | ||
MTP_string(link), | ||
ToMTP(session, title, message) | ||
)).done([=](const MTPBusinessChatLink &result) { | ||
const auto parsed = FromMTP(session, result); | ||
if (parsed.link != link) { | ||
LOG(("API Error: EditBusinessChatLink changed the link.")); | ||
if (done) done(Link()); | ||
return; | ||
} | ||
const auto i = ranges::find(_list, link, &Link::link); | ||
if (i != end(_list)) { | ||
*i = parsed; | ||
_updates.fire({ .was = link, .now = parsed }); | ||
if (done) done(parsed); | ||
} else { | ||
LOG(("API Error: EditBusinessChatLink link not found.")); | ||
if (done) done(Link()); | ||
} | ||
}).fail([=](const MTP::Error &error) { | ||
const auto type = error.type(); | ||
if (done) done(Link()); | ||
}).send(); | ||
} | ||
|
||
void ChatLinks::destroy( | ||
const QString &link, | ||
Fn<void()> done) { | ||
_api->request(MTPaccount_DeleteBusinessChatLink( | ||
MTP_string(link) | ||
)).done([=] { | ||
const auto i = ranges::find(_list, link, &Link::link); | ||
if (i != end(_list)) { | ||
_list.erase(i); | ||
_updates.fire({ .was = link }); | ||
if (done) done(); | ||
} else { | ||
LOG(("API Error: DeleteBusinessChatLink link not found.")); | ||
if (done) done(); | ||
} | ||
}).fail([=](const MTP::Error &error) { | ||
const auto type = error.type(); | ||
if (done) done(); | ||
}).send(); | ||
} | ||
|
||
void ChatLinks::preload() { | ||
if (_loaded || _requestId) { | ||
return; | ||
} | ||
_requestId = _api->request(MTPaccount_GetBusinessChatLinks( | ||
)).done([=](const MTPaccount_BusinessChatLinks &result) { | ||
const auto &data = result.data(); | ||
const auto session = &_api->session(); | ||
const auto owner = &session->data(); | ||
owner->processUsers(data.vusers()); | ||
owner->processChats(data.vchats()); | ||
auto links = std::vector<Link>(); | ||
links.reserve(data.vlinks().v.size()); | ||
for (const auto &link : data.vlinks().v) { | ||
links.push_back(FromMTP(session, link)); | ||
} | ||
_list = std::move(links); | ||
_loaded = true; | ||
_loadedUpdates.fire({}); | ||
}).fail([=] { | ||
_requestId = 0; | ||
_loaded = true; | ||
_loadedUpdates.fire({}); | ||
}).send(); | ||
} | ||
|
||
const std::vector<ChatLink> &ChatLinks::list() const { | ||
return _list; | ||
} | ||
|
||
bool ChatLinks::loaded() const { | ||
return _loaded; | ||
} | ||
|
||
rpl::producer<> ChatLinks::loadedUpdates() const { | ||
return _loadedUpdates.events(); | ||
} | ||
|
||
rpl::producer<ChatLinks::Update> ChatLinks::updates() const { | ||
return _updates.events(); | ||
} | ||
|
||
} // namespace Api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
This file is part of Telegram Desktop, | ||
the official desktop application for the Telegram messaging service. | ||
For license and copyright information please follow this link: | ||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL | ||
*/ | ||
#pragma once | ||
|
||
class ApiWrap; | ||
|
||
namespace Api { | ||
|
||
struct ChatLink { | ||
QString link; | ||
QString title; | ||
TextWithEntities message; | ||
int clicks = 0; | ||
}; | ||
|
||
struct ChatLinkUpdate { | ||
QString was; | ||
std::optional<ChatLink> now; | ||
}; | ||
|
||
class ChatLinks final { | ||
public: | ||
explicit ChatLinks(not_null<ApiWrap*> api); | ||
|
||
using Link = ChatLink; | ||
using Update = ChatLinkUpdate; | ||
|
||
void create( | ||
const QString &title, | ||
const TextWithEntities &message, | ||
Fn<void(Link)> done = nullptr); | ||
void edit( | ||
const QString &link, | ||
const QString &title, | ||
const TextWithEntities &message, | ||
Fn<void(Link)> done = nullptr); | ||
void destroy( | ||
const QString &link, | ||
Fn<void()> done = nullptr); | ||
|
||
void preload(); | ||
[[nodiscard]] const std::vector<ChatLink> &list() const; | ||
[[nodiscard]] bool loaded() const; | ||
[[nodiscard]] rpl::producer<> loadedUpdates() const; | ||
[[nodiscard]] rpl::producer<Update> updates() const; | ||
|
||
private: | ||
const not_null<ApiWrap*> _api; | ||
|
||
std::vector<Link> _list; | ||
rpl::event_stream<> _loadedUpdates; | ||
mtpRequestId _requestId = 0; | ||
bool _loaded = false; | ||
|
||
rpl::event_stream<Update> _updates; | ||
|
||
}; | ||
|
||
} // namespace Api |
Oops, something went wrong.