From d5a2d315dbccbc64b522cf58188cec93e9363ceb Mon Sep 17 00:00:00 2001 From: John Gibbon Date: Mon, 16 Nov 2020 10:28:16 +0100 Subject: [PATCH 1/8] forwarding/new message/attachment permissions enhances #159 PR, hopefully fixes #164 issue --- qml/js/functions.js | 25 +++++++++++++++++ qml/pages/ChatPage.qml | 31 ++++++++++++-------- qml/pages/ChatSelectionPage.qml | 50 +++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 11 deletions(-) diff --git a/qml/js/functions.js b/qml/js/functions.js index e7fa25e..a0954ac 100644 --- a/qml/js/functions.js +++ b/qml/js/functions.js @@ -406,3 +406,28 @@ function handleErrorMessage(code, message) { appNotification.show(message); } } + +function getMessagesNeededForwardPermissions(messages) { + var neededPermissions = ["can_send_messages"]; + + var mediaMessageTypes = ["messageAudio", "messageDocument", "messagePhoto", "messageVideo", "messageVideoNote", "messageVoiceNote"]; + var otherMessageTypes = ["messageAnimation", "messageGame", "messageSticker"] + for(var i = 0; i < messages.length; i += 1) { + var type = messages[i]["content"]["@type"]; + var permission = ""; + if(type === "messageText") { + continue; + } else if(type === "messagePoll") { + permission = "can_send_polls"; + } else if(mediaMessageTypes.indexOf(type) > -1) { + permission = "can_send_media_messages"; + } else if(otherMessageTypes.indexOf(type) > -1) { + permission = "can_send_other_messages"; + } + + if(permission !== "" && neededPermissions.indexOf(permission) === -1) { + neededPermissions.push(permission); + } + } + return neededPermissions; +} diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index b5d89d1..bd97589 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -266,6 +266,17 @@ Page { forwardMessagesTimer.messageIds = messageIds; forwardMessagesTimer.start(); } + function hasSendPrivilege(privilege) { + return chatPage.isPrivateChat || + chatGroupInformation && + ( + (chatGroupInformation.status["@type"] === "chatMemberStatusMember" && chatGroupInformation.status.permissions[privilege]) + || chatGroupInformation.status["@type"] === "chatMemberStatusAdministrator" + || chatGroupInformation.status["@type"] === "chatMemberStatusCreator" + || (chatGroupInformation.status["@type"] === "chatMemberStatusRestricted" && chatInformation.permissions[privilege]) + ) + } + Timer { id: forwardMessagesTimer interval: 200 @@ -822,7 +833,7 @@ Page { topPadding: Theme.paddingSmall width: parent.width - ( 2 * Theme.horizontalPageMargin ) anchors.horizontalCenter: parent.horizontalCenter - visible: !chatPage.isChannel + visible: chatPage.hasSendPrivilege("can_send_messages") height: visible ? implicitHeight : 0 Behavior on opacity { FadeAnimation {} } @@ -859,7 +870,7 @@ Page { layoutDirection: Qt.RightToLeft spacing: Theme.paddingMedium IconButton { - id: imageAttachmentButton + visible: chatPage.hasSendPrivilege("can_send_media_messages") icon.source: "image://theme/icon-m-image" onClicked: { var picker = pageStack.push("Sailfish.Pickers.ImagePickerPage"); @@ -874,7 +885,7 @@ Page { } } IconButton { - id: videoAttachmentButton + visible: chatPage.hasSendPrivilege("can_send_media_messages") icon.source: "image://theme/icon-m-video" onClicked: { var picker = pageStack.push("Sailfish.Pickers.VideoPickerPage"); @@ -889,7 +900,7 @@ Page { } } IconButton { - id: documentAttachmentButton + visible: chatPage.hasSendPrivilege("can_send_media_messages") icon.source: "image://theme/icon-m-document" onClicked: { var picker = pageStack.push("Sailfish.Pickers.DocumentPickerPage"); @@ -905,6 +916,8 @@ Page { } IconButton { + + visible: chatPage.hasSendPrivilege("can_send_other_messages") icon.source: "../../images/icon-m-sticker.svg" icon.sourceSize { width: Theme.iconSizeMedium @@ -917,10 +930,7 @@ Page { } } IconButton { - visible: !chatPage.isPrivateChat && chatGroupInformation && - (chatGroupInformation.status["@type"] === "chatMemberStatusCreator" - || chatGroupInformation.status["@type"] === "chatMemberStatusAdministrator" - || (chatGroupInformation.status["@type"] === "chatMemberStatusMember" && chatInformation.permissions.can_send_polls)) + visible: !chatPage.isPrivateChat && chatPage.hasSendPrivilege("can_send_polls") icon.source: "image://theme/icon-m-question" onClicked: { pageStack.push(Qt.resolvedUrl("../pages/PollCreationPage.qml"), { "chatId" : chatInformation.id, groupName: chatInformation.title}); @@ -1205,12 +1215,11 @@ Page { icon.source: "image://theme/icon-m-forward" onClicked: { var ids = Functions.getMessagesArrayIds(chatPage.selectedMessages); - + var neededPermissions = Functions.getMessagesNeededForwardPermissions(chatPage.selectedMessages); var chatId = chatInformation.id; - pageStack.push(Qt.resolvedUrl("../pages/ChatSelectionPage.qml"), { headerDescription: qsTr("Forward %n messages", "dialog header", ids.length).arg(ids.length), - payload: {fromChatId: chatId, messageIds:ids}, + payload: {fromChatId: chatId, messageIds:ids, neededPermissions: neededPermissions}, state: "forwardMessages" }); } diff --git a/qml/pages/ChatSelectionPage.qml b/qml/pages/ChatSelectionPage.qml index 4dec379..9609401 100644 --- a/qml/pages/ChatSelectionPage.qml +++ b/qml/pages/ChatSelectionPage.qml @@ -31,6 +31,10 @@ Dialog { acceptDestinationReplaceTarget: pageStack.find( function(page){ return(page._depth === 0)} ) property alias headerTitle: pageHeader.title property alias headerDescription: pageHeader.description + /* + payload dependent on chatSelectionPage.state + - forwardMessages: {fromChatId, messageIds, neededPermissions} + */ property var payload: ({}) onAccepted: { @@ -38,6 +42,7 @@ Dialog { case "forwardMessages": acceptDestinationInstance.forwardMessages(payload.fromChatId, payload.messageIds) break; + // future uses of chat selection can be processed here } } @@ -62,7 +67,52 @@ Dialog { model: chatListModel delegate: ChatListViewItem { ownUserId: overviewPage.ownUserId + Loader { // checking permissions takes a while, so we defer those calculations + id: visibleLoader + asynchronous: true + sourceComponent: Component { + QtObject { + property var chatGroupInformation: ({}) + property bool visible: false + Component.onCompleted: { + if(chatSelectionPage.state === "forwardMessages") { + var chatType = display.type['@type']; + if(chatType === "chatTypePrivate" || chatType === "chatTypeSecret") { + visible = true + return; + } + else if (chatType === "chatTypeBasicGroup" ) { + chatGroupInformation = tdLibWrapper.getBasicGroup(display.type.basic_group_id); + } + else if (chatType === "chatTypeSupergroup" ) { + chatGroupInformation = tdLibWrapper.getSuperGroup(display.type.supergroup_id); + } + visible = (chatGroupInformation.status["@type"] === "chatMemberStatusCreator" + || chatGroupInformation.status["@type"] === "chatMemberStatusAdministrator" + || (chatGroupInformation.status["@type"] === "chatMemberStatusMember" + && chatSelectionPage.payload.neededPermissions.every(function(neededPermission){ + return display.permissions[neededPermission]; + }) + ) + ); + } else { // future uses of chat selection can be processed here + visible = true; + } + } + } + } + } + + property bool valid: visibleLoader && visibleLoader.item && visibleLoader.item.visible + opacity: valid ? 1.0 : 0.5 + + Behavior on opacity { FadeAnimation {}} + Behavior on height { NumberAnimation {}} + + // normal height while calculating, otherwise all elements get displayed at once + height: !visibleLoader.item || visible ? contentHeight : 0 + enabled: valid onClicked: { var chat = tdLibWrapper.getChat(display.id); switch(chatSelectionPage.state) { From ac10e600bf6d293f982b53998e1722be3c8a4414 Mon Sep 17 00:00:00 2001 From: John Gibbon Date: Mon, 16 Nov 2020 10:58:33 +0100 Subject: [PATCH 2/8] fix restricted member permission copy/paste issue --- qml/pages/ChatPage.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index bd97589..740f2c3 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -273,7 +273,7 @@ Page { (chatGroupInformation.status["@type"] === "chatMemberStatusMember" && chatGroupInformation.status.permissions[privilege]) || chatGroupInformation.status["@type"] === "chatMemberStatusAdministrator" || chatGroupInformation.status["@type"] === "chatMemberStatusCreator" - || (chatGroupInformation.status["@type"] === "chatMemberStatusRestricted" && chatInformation.permissions[privilege]) + || (chatGroupInformation.status["@type"] === "chatMemberStatusRestricted" && chatGroupInformation.status.permissions[privilege]) ) } From c4947260f73c587aea80ddb93c88fe25ac5f098f Mon Sep 17 00:00:00 2001 From: John Gibbon Date: Mon, 16 Nov 2020 12:25:47 +0100 Subject: [PATCH 3/8] forwarding permissions: possibly prevent some unneccessary loops --- qml/js/functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qml/js/functions.js b/qml/js/functions.js index a0954ac..4abc5c4 100644 --- a/qml/js/functions.js +++ b/qml/js/functions.js @@ -412,7 +412,7 @@ function getMessagesNeededForwardPermissions(messages) { var mediaMessageTypes = ["messageAudio", "messageDocument", "messagePhoto", "messageVideo", "messageVideoNote", "messageVoiceNote"]; var otherMessageTypes = ["messageAnimation", "messageGame", "messageSticker"] - for(var i = 0; i < messages.length; i += 1) { + for(var i = 0; i < messages.length && neededPermissions.length < 3; i += 1) { var type = messages[i]["content"]["@type"]; var permission = ""; if(type === "messageText") { From c76d079e03f2e10af60012ee58cc1d30991f095c Mon Sep 17 00:00:00 2001 From: John Gibbon Date: Mon, 16 Nov 2020 22:31:37 +0100 Subject: [PATCH 4/8] permissions: replace leftover debug changes; fix another copy/paste --- qml/pages/ChatPage.qml | 3 ++- qml/pages/ChatSelectionPage.qml | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index 740f2c3..18690ce 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -1208,7 +1208,7 @@ Page { leftMargin: visible ? Theme.paddingSmall : 0 verticalCenter: parent.verticalCenter } - visible: chatPage.chatInformation.can_be_forwarded && selectedMessages.every(function(message){ + visible: selectedMessages.every(function(message){ return message.can_be_forwarded }) width: visible ? Theme.itemSizeMedium : 0 @@ -1218,6 +1218,7 @@ Page { var neededPermissions = Functions.getMessagesNeededForwardPermissions(chatPage.selectedMessages); var chatId = chatInformation.id; pageStack.push(Qt.resolvedUrl("../pages/ChatSelectionPage.qml"), { + myUserId: chatPage.myUserId, headerDescription: qsTr("Forward %n messages", "dialog header", ids.length).arg(ids.length), payload: {fromChatId: chatId, messageIds:ids, neededPermissions: neededPermissions}, state: "forwardMessages" diff --git a/qml/pages/ChatSelectionPage.qml b/qml/pages/ChatSelectionPage.qml index 9609401..e975331 100644 --- a/qml/pages/ChatSelectionPage.qml +++ b/qml/pages/ChatSelectionPage.qml @@ -29,6 +29,7 @@ Dialog { canAccept: false acceptDestinationAction: PageStackAction.Replace acceptDestinationReplaceTarget: pageStack.find( function(page){ return(page._depth === 0)} ) + property int myUserId: tdLibWrapper.getUserInformation().id; property alias headerTitle: pageHeader.title property alias headerDescription: pageHeader.description /* @@ -66,7 +67,7 @@ Dialog { model: chatListModel delegate: ChatListViewItem { - ownUserId: overviewPage.ownUserId + ownUserId: chatSelectionPage.myUserId Loader { // checking permissions takes a while, so we defer those calculations id: visibleLoader asynchronous: true @@ -105,13 +106,13 @@ Dialog { } property bool valid: visibleLoader && visibleLoader.item && visibleLoader.item.visible - opacity: valid ? 1.0 : 0.5 + opacity: valid ? 1.0 : 0 Behavior on opacity { FadeAnimation {}} Behavior on height { NumberAnimation {}} // normal height while calculating, otherwise all elements get displayed at once - height: !visibleLoader.item || visible ? contentHeight : 0 + height: !visibleLoader.item || valid ? contentHeight : 0 enabled: valid onClicked: { var chat = tdLibWrapper.getChat(display.id); From 3cce631aa7bf1b270ff20820b2d1b0c0e303af03 Mon Sep 17 00:00:00 2001 From: John Gibbon Date: Tue, 17 Nov 2020 11:14:36 +0100 Subject: [PATCH 5/8] optimize permission lookups --- qml/pages/ChatPage.qml | 17 +++++++++-------- qml/pages/ChatSelectionPage.qml | 20 ++++++++++++++------ 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index 18690ce..c4c96e2 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -267,14 +267,15 @@ Page { forwardMessagesTimer.start(); } function hasSendPrivilege(privilege) { - return chatPage.isPrivateChat || - chatGroupInformation && - ( - (chatGroupInformation.status["@type"] === "chatMemberStatusMember" && chatGroupInformation.status.permissions[privilege]) - || chatGroupInformation.status["@type"] === "chatMemberStatusAdministrator" - || chatGroupInformation.status["@type"] === "chatMemberStatusCreator" - || (chatGroupInformation.status["@type"] === "chatMemberStatusRestricted" && chatGroupInformation.status.permissions[privilege]) - ) + var groupStatus = chatGroupInformation ? chatGroupInformation.status : null; + var groupStatusType = grouptStatus ? groupStatus["@type"] : null; + return chatPage.isPrivateChat + || (groupStatusType === "chatMemberStatusMember" && chatInformation.permissions[privilege]) + || groupStatusType === "chatMemberStatusAdministrator" + || groupStatusType === "chatMemberStatusCreator" + || (groupStatusType === "chatMemberStatusRestricted" && groupStatus.permissions[privilege]) + + } Timer { diff --git a/qml/pages/ChatSelectionPage.qml b/qml/pages/ChatSelectionPage.qml index e975331..b6924e8 100644 --- a/qml/pages/ChatSelectionPage.qml +++ b/qml/pages/ChatSelectionPage.qml @@ -73,11 +73,11 @@ Dialog { asynchronous: true sourceComponent: Component { QtObject { - property var chatGroupInformation: ({}) property bool visible: false Component.onCompleted: { if(chatSelectionPage.state === "forwardMessages") { var chatType = display.type['@type']; + var chatGroupInformation; if(chatType === "chatTypePrivate" || chatType === "chatTypeSecret") { visible = true return; @@ -88,14 +88,22 @@ Dialog { else if (chatType === "chatTypeSupergroup" ) { chatGroupInformation = tdLibWrapper.getSuperGroup(display.type.supergroup_id); } - - visible = (chatGroupInformation.status["@type"] === "chatMemberStatusCreator" - || chatGroupInformation.status["@type"] === "chatMemberStatusAdministrator" - || (chatGroupInformation.status["@type"] === "chatMemberStatusMember" + var groupStatus = chatGroupInformation.status; + var groupStatusType = groupStatus["@type"]; + var groupStatusPermissions = groupStatus.permissions; + var groupPermissions = display.permissions; + visible = (groupStatusType === "chatMemberStatusCreator" + || groupStatusType === "chatMemberStatusAdministrator" + || (groupStatusType === "chatMemberStatusMember" && chatSelectionPage.payload.neededPermissions.every(function(neededPermission){ - return display.permissions[neededPermission]; + return groupPermissions[neededPermission]; }) ) + || (groupStatusType === "chatMemberStatusRestricted" + && chatSelectionPage.payload.neededPermissions.every(function(neededPermission){ + return groupStatusPermissions[neededPermission]; + }) + ) ); } else { // future uses of chat selection can be processed here visible = true; From 59304527d2a68e1341f5a6787ccccd66d92eadb0 Mon Sep 17 00:00:00 2001 From: John Gibbon Date: Tue, 17 Nov 2020 16:21:20 +0100 Subject: [PATCH 6/8] fix typo; don't update group status while selecting --- qml/pages/ChatPage.qml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index c4c96e2..135c369 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -108,6 +108,9 @@ Page { } function updateGroupStatusText() { + if(chatPage.state === "selectMessages") { + return + } if (chatOnlineMemberCount > 0) { chatStatusText.text = qsTr("%1 members, %2 online").arg(Functions.getShortenedCount(chatGroupInformation.member_count)).arg(Functions.getShortenedCount(chatOnlineMemberCount)); } else { @@ -268,14 +271,12 @@ Page { } function hasSendPrivilege(privilege) { var groupStatus = chatGroupInformation ? chatGroupInformation.status : null; - var groupStatusType = grouptStatus ? groupStatus["@type"] : null; + var groupStatusType = groupStatus ? groupStatus["@type"] : null; return chatPage.isPrivateChat || (groupStatusType === "chatMemberStatusMember" && chatInformation.permissions[privilege]) || groupStatusType === "chatMemberStatusAdministrator" || groupStatusType === "chatMemberStatusCreator" || (groupStatusType === "chatMemberStatusRestricted" && groupStatus.permissions[privilege]) - - } Timer { From 1486e49f1c74d5f3b49d87d4b2c04437cc3a7f2b Mon Sep 17 00:00:00 2001 From: John Gibbon Date: Tue, 17 Nov 2020 16:45:54 +0100 Subject: [PATCH 7/8] add FernschreiberUtils to qml context (unused for now) --- src/harbour-fernschreiber.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/harbour-fernschreiber.cpp b/src/harbour-fernschreiber.cpp index 5491f65..631f28b 100644 --- a/src/harbour-fernschreiber.cpp +++ b/src/harbour-fernschreiber.cpp @@ -39,6 +39,7 @@ #include "processlauncher.h" #include "stickermanager.h" #include "tgsplugin.h" +#include "fernschreiberutils.h" Q_IMPORT_PLUGIN(TgsIOPlugin) @@ -60,6 +61,9 @@ int main(int argc, char *argv[]) context->setContextProperty("tdLibWrapper", tdLibWrapper); qmlRegisterUncreatableType(uri, 1, 0, "TelegramAPI", QString()); + FernschreiberUtils *fernschreiberUtils = new FernschreiberUtils(view.data()); + context->setContextProperty("fernschreiberUtils", fernschreiberUtils); + DBusAdaptor *dBusAdaptor = tdLibWrapper->getDBusAdaptor(); context->setContextProperty("dBusAdaptor", dBusAdaptor); From 816ba6eca7f73ae4aa8a37886e5c40327e47ff39 Mon Sep 17 00:00:00 2001 From: John Gibbon Date: Wed, 18 Nov 2020 11:13:05 +0100 Subject: [PATCH 8/8] remove some semicolons; --- qml/js/functions.js | 20 ++++++++++---------- qml/pages/ChatPage.qml | 12 ++++++------ qml/pages/ChatSelectionPage.qml | 26 +++++++++++++------------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/qml/js/functions.js b/qml/js/functions.js index 4abc5c4..67f7838 100644 --- a/qml/js/functions.js +++ b/qml/js/functions.js @@ -408,26 +408,26 @@ function handleErrorMessage(code, message) { } function getMessagesNeededForwardPermissions(messages) { - var neededPermissions = ["can_send_messages"]; + var neededPermissions = ["can_send_messages"] - var mediaMessageTypes = ["messageAudio", "messageDocument", "messagePhoto", "messageVideo", "messageVideoNote", "messageVoiceNote"]; + var mediaMessageTypes = ["messageAudio", "messageDocument", "messagePhoto", "messageVideo", "messageVideoNote", "messageVoiceNote"] var otherMessageTypes = ["messageAnimation", "messageGame", "messageSticker"] for(var i = 0; i < messages.length && neededPermissions.length < 3; i += 1) { - var type = messages[i]["content"]["@type"]; - var permission = ""; + var type = messages[i]["content"]["@type"] + var permission = "" if(type === "messageText") { - continue; + continue } else if(type === "messagePoll") { - permission = "can_send_polls"; + permission = "can_send_polls" } else if(mediaMessageTypes.indexOf(type) > -1) { - permission = "can_send_media_messages"; + permission = "can_send_media_messages" } else if(otherMessageTypes.indexOf(type) > -1) { - permission = "can_send_other_messages"; + permission = "can_send_other_messages" } if(permission !== "" && neededPermissions.indexOf(permission) === -1) { - neededPermissions.push(permission); + neededPermissions.push(permission) } } - return neededPermissions; + return neededPermissions } diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index 135c369..809f495 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -270,8 +270,8 @@ Page { forwardMessagesTimer.start(); } function hasSendPrivilege(privilege) { - var groupStatus = chatGroupInformation ? chatGroupInformation.status : null; - var groupStatusType = groupStatus ? groupStatus["@type"] : null; + var groupStatus = chatGroupInformation ? chatGroupInformation.status : null + var groupStatusType = groupStatus ? groupStatus["@type"] : null return chatPage.isPrivateChat || (groupStatusType === "chatMemberStatusMember" && chatInformation.permissions[privilege]) || groupStatusType === "chatMemberStatusAdministrator" @@ -1216,15 +1216,15 @@ Page { width: visible ? Theme.itemSizeMedium : 0 icon.source: "image://theme/icon-m-forward" onClicked: { - var ids = Functions.getMessagesArrayIds(chatPage.selectedMessages); - var neededPermissions = Functions.getMessagesNeededForwardPermissions(chatPage.selectedMessages); - var chatId = chatInformation.id; + var ids = Functions.getMessagesArrayIds(chatPage.selectedMessages) + var neededPermissions = Functions.getMessagesNeededForwardPermissions(chatPage.selectedMessages) + var chatId = chatInformation.id pageStack.push(Qt.resolvedUrl("../pages/ChatSelectionPage.qml"), { myUserId: chatPage.myUserId, headerDescription: qsTr("Forward %n messages", "dialog header", ids.length).arg(ids.length), payload: {fromChatId: chatId, messageIds:ids, neededPermissions: neededPermissions}, state: "forwardMessages" - }); + }) } } diff --git a/qml/pages/ChatSelectionPage.qml b/qml/pages/ChatSelectionPage.qml index b6924e8..f75ab64 100644 --- a/qml/pages/ChatSelectionPage.qml +++ b/qml/pages/ChatSelectionPage.qml @@ -29,7 +29,7 @@ Dialog { canAccept: false acceptDestinationAction: PageStackAction.Replace acceptDestinationReplaceTarget: pageStack.find( function(page){ return(page._depth === 0)} ) - property int myUserId: tdLibWrapper.getUserInformation().id; + property int myUserId: tdLibWrapper.getUserInformation().id property alias headerTitle: pageHeader.title property alias headerDescription: pageHeader.description /* @@ -76,37 +76,37 @@ Dialog { property bool visible: false Component.onCompleted: { if(chatSelectionPage.state === "forwardMessages") { - var chatType = display.type['@type']; - var chatGroupInformation; + var chatType = display.type['@type'] + var chatGroupInformation if(chatType === "chatTypePrivate" || chatType === "chatTypeSecret") { visible = true return; } else if (chatType === "chatTypeBasicGroup" ) { - chatGroupInformation = tdLibWrapper.getBasicGroup(display.type.basic_group_id); + chatGroupInformation = tdLibWrapper.getBasicGroup(display.type.basic_group_id) } else if (chatType === "chatTypeSupergroup" ) { - chatGroupInformation = tdLibWrapper.getSuperGroup(display.type.supergroup_id); + chatGroupInformation = tdLibWrapper.getSuperGroup(display.type.supergroup_id) } - var groupStatus = chatGroupInformation.status; - var groupStatusType = groupStatus["@type"]; - var groupStatusPermissions = groupStatus.permissions; - var groupPermissions = display.permissions; + var groupStatus = chatGroupInformation.status + var groupStatusType = groupStatus["@type"] + var groupStatusPermissions = groupStatus.permissions + var groupPermissions = display.permissions visible = (groupStatusType === "chatMemberStatusCreator" || groupStatusType === "chatMemberStatusAdministrator" || (groupStatusType === "chatMemberStatusMember" && chatSelectionPage.payload.neededPermissions.every(function(neededPermission){ - return groupPermissions[neededPermission]; + return groupPermissions[neededPermission] }) ) || (groupStatusType === "chatMemberStatusRestricted" && chatSelectionPage.payload.neededPermissions.every(function(neededPermission){ - return groupStatusPermissions[neededPermission]; + return groupStatusPermissions[neededPermission] }) ) - ); + ) } else { // future uses of chat selection can be processed here - visible = true; + visible = true } } }