Prepare to join/see chats by link
This commit is contained in:
parent
8e46661d78
commit
84bfb003b0
3 changed files with 44 additions and 1 deletions
|
@ -282,7 +282,24 @@ function handleLink(link) {
|
|||
} else if (link.indexOf("userId://") === 0) {
|
||||
tdLibWrapper.createPrivateChat(link.substring(9));
|
||||
} else {
|
||||
Qt.openUrlExternally(link);
|
||||
var tMePrefix = tdLibWrapper.getOptionString("t_me_url");
|
||||
if (link.indexOf(tMePrefix) === 0) {
|
||||
if (link.indexOf("joinchat") !== -1) {
|
||||
console.log("Joining Chatto: " + link);
|
||||
tdLibWrapper.joinChatByInviteLink(link);
|
||||
// Do the necessary stuff to open the chat if successful
|
||||
// Fail with nice error message if it doesn't work
|
||||
} else {
|
||||
console.log("SUCH! " + link.substring(tMePrefix.length));
|
||||
tdLibWrapper.searchPublicChat(link.substring(tMePrefix.length));
|
||||
// Check responses for updateBasicGroup or updateSupergroup
|
||||
// Fire createBasicGroupChat or createSupergroupChat
|
||||
// Do the necessary stuff to open the chat
|
||||
// Fail with nice error message if chat can't be found
|
||||
}
|
||||
} else {
|
||||
Qt.openUrlExternally(link);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -687,6 +687,24 @@ void TDLibWrapper::getPollVoters(const QString &chatId, const qlonglong &message
|
|||
this->sendRequest(requestObject);
|
||||
}
|
||||
|
||||
void TDLibWrapper::searchPublicChat(const QString &userName)
|
||||
{
|
||||
LOG("Search public chat" << userName);
|
||||
QVariantMap requestObject;
|
||||
requestObject.insert(_TYPE, "searchPublicChat");
|
||||
requestObject.insert("username", userName);
|
||||
this->sendRequest(requestObject);
|
||||
}
|
||||
|
||||
void TDLibWrapper::joinChatByInviteLink(const QString &inviteLink)
|
||||
{
|
||||
LOG("Join chat by invite link" << inviteLink);
|
||||
QVariantMap requestObject;
|
||||
requestObject.insert(_TYPE, "joinChatByInviteLink");
|
||||
requestObject.insert("invite_link", inviteLink);
|
||||
this->sendRequest(requestObject);
|
||||
}
|
||||
|
||||
void TDLibWrapper::searchEmoji(const QString &queryString)
|
||||
{
|
||||
LOG("Searching emoji" << queryString);
|
||||
|
@ -753,6 +771,11 @@ QVariantMap TDLibWrapper::getChat(const QString &chatId)
|
|||
return this->chats.value(chatId).toMap();
|
||||
}
|
||||
|
||||
QString TDLibWrapper::getOptionString(const QString &optionName)
|
||||
{
|
||||
return this->options.value(optionName).toString();
|
||||
}
|
||||
|
||||
void TDLibWrapper::copyFileToDownloads(const QString &filePath)
|
||||
{
|
||||
LOG("Copy file to downloads" << filePath);
|
||||
|
|
|
@ -98,6 +98,7 @@ public:
|
|||
Q_INVOKABLE QVariantMap getBasicGroup(qlonglong groupId) const;
|
||||
Q_INVOKABLE QVariantMap getSuperGroup(qlonglong groupId) const;
|
||||
Q_INVOKABLE QVariantMap getChat(const QString &chatId);
|
||||
Q_INVOKABLE QString getOptionString(const QString &optionName);
|
||||
Q_INVOKABLE void copyFileToDownloads(const QString &filePath);
|
||||
Q_INVOKABLE void openFileOnDevice(const QString &filePath);
|
||||
Q_INVOKABLE void controlScreenSaver(bool enabled);
|
||||
|
@ -147,6 +148,8 @@ public:
|
|||
Q_INVOKABLE void setPollAnswer(const QString &chatId, const qlonglong &messageId, QVariantList optionIds);
|
||||
Q_INVOKABLE void stopPoll(const QString &chatId, const qlonglong &messageId);
|
||||
Q_INVOKABLE void getPollVoters(const QString &chatId, const qlonglong &messageId, const int &optionId, const int &limit, const int &offset, const QString &extra);
|
||||
Q_INVOKABLE void searchPublicChat(const QString &userName);
|
||||
Q_INVOKABLE void joinChatByInviteLink(const QString &inviteLink);
|
||||
|
||||
// Others (candidates for extraction ;))
|
||||
Q_INVOKABLE void searchEmoji(const QString &queryString);
|
||||
|
|
Loading…
Reference in a new issue