From 7d0a77ef0d65413e4e997f093f3aaa6f276859a2 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Tue, 23 May 2023 16:01:39 -0400 Subject: [PATCH] chore(links): update to use the new external link format Fixes #10777 --- src/app/core/custom_urls/urls_manager.nim | 8 +++++--- src/app_service/service/community/service.nim | 5 ++--- src/app_service/service/message/async_tasks.nim | 9 ++++++--- ui/StatusQ/sandbox/demoapp/DemoCommunityDetailModal.qml | 2 +- ui/app/AppLayouts/Chat/stores/RootStore.qml | 2 +- ui/app/mainui/AppMain.qml | 6 +++--- ui/imports/utils/Constants.qml | 7 ++++--- ui/imports/utils/Utils.qml | 2 +- 8 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/app/core/custom_urls/urls_manager.nim b/src/app/core/custom_urls/urls_manager.nim index 09c3c95dea..03a6fc5878 100644 --- a/src/app/core/custom_urls/urls_manager.nim +++ b/src/app/core/custom_urls/urls_manager.nim @@ -8,10 +8,12 @@ import ../../../app_service/service/accounts/utils logScope: topics = "urls-manager" -const StatusInternalLink = "status-app" -const StatusExternalLink = "join.status.im" +const StatusInternalLink* = "status-app" +const StatusExternalLink* = "status.app" -const UriFormatUserProfile = StatusInternalLink & "://u/" +const profileLinkPrefix* = "/u/" + +const UriFormatUserProfile = StatusInternalLink & ":/" & profileLinkPrefix const UriFormatCommunity = StatusInternalLink & "://c/" diff --git a/src/app_service/service/community/service.nim b/src/app_service/service/community/service.nim index ecad93ceed..ddb9784ff5 100644 --- a/src/app_service/service/community/service.nim +++ b/src/app_service/service/community/service.nim @@ -1325,9 +1325,8 @@ QtObject: proc asyncCommunityInfoLoaded*(self: Service, communityIdAndRpcResponse: string) {.slot.} = let rpcResponseObj = communityIdAndRpcResponse.parseJson - if (rpcResponseObj{"response"}{"error"}.kind != JNull): - let error = Json.decode($rpcResponseObj["response"]["error"], RpcError) - error "Error requesting community info", msg = error.message + if (rpcResponseObj{"error"}.kind != JNull): + error "Error requesting community info", msg = rpcResponseObj{"error"} return var community = rpcResponseObj{"response"}{"result"}.toCommunityDto() diff --git a/src/app_service/service/message/async_tasks.nim b/src/app_service/service/message/async_tasks.nim index a12fe93ffa..6474c9ff7a 100644 --- a/src/app_service/service/message/async_tasks.nim +++ b/src/app_service/service/message/async_tasks.nim @@ -4,6 +4,8 @@ include ../../../app/core/tasks/common import ../../../backend/chat as status_go_chat +import ../../../app/core/custom_urls/urls_manager + ################################################# # Async load messages @@ -197,8 +199,9 @@ const asyncGetLinkPreviewDataTask: Task = proc(argEncoded: string) {.gcsafe, nim let path = uri.path let domain = uri.hostname.toLower() let isSupportedImage = any(parsedWhiteListImgExtensions, proc (extenstion: string): bool = path.endsWith(extenstion)) - let isWhitelistedUrl = parsedWhiteListUrls.hasKey(domain) - let processUrl = isWhitelistedUrl or isSupportedImage + let isListed = parsedWhiteListUrls.hasKey(domain) + let isProfileLink = path.startsWith(profileLinkPrefix) + let processUrl = not isProfileLink and (isListed or isSupportedImage) if domain == "" or processUrl == false: continue @@ -229,7 +232,7 @@ const asyncGetLinkPreviewDataTask: Task = proc(argEncoded: string) {.gcsafe, nim #2. Process whitelisted url #status deep links are handled internally - if domain == "status-app" or domain == "join.status.im": + if domain == StatusInternalLink or domain == StatusExternalLink: responseJson["success"] = %true responseJson["isStatusDeepLink"] = %true responseJson["result"] = %*{ diff --git a/ui/StatusQ/sandbox/demoapp/DemoCommunityDetailModal.qml b/ui/StatusQ/sandbox/demoapp/DemoCommunityDetailModal.qml index 869857e9dd..6aaec89782 100644 --- a/ui/StatusQ/sandbox/demoapp/DemoCommunityDetailModal.qml +++ b/ui/StatusQ/sandbox/demoapp/DemoCommunityDetailModal.qml @@ -42,7 +42,7 @@ StatusModal { StatusDescriptionListItem { title: "Share community" - subTitle: "https://join.status.im/u/0x04...45f19" + subTitle: "https://status.app/u/0x04...45f19" tooltip.text: "Copy to clipboard" asset.name: "copy" iconButton.onClicked: tooltip.visible = !tooltip.visible diff --git a/ui/app/AppLayouts/Chat/stores/RootStore.qml b/ui/app/AppLayouts/Chat/stores/RootStore.qml index 4db7e909e0..b387282ed6 100644 --- a/ui/app/AppLayouts/Chat/stores/RootStore.qml +++ b/ui/app/AppLayouts/Chat/stores/RootStore.qml @@ -488,7 +488,7 @@ QtObject { const result = getLinkTitleAndCb(link) return { - site: "https://join.status.im", + site: Constants.externalStatusLinkWithHttps, title: result.title, communityId: result.communityId, fetching: result.fetching, diff --git a/ui/app/mainui/AppMain.qml b/ui/app/mainui/AppMain.qml index 55d9e8246b..c92a90729c 100644 --- a/ui/app/mainui/AppMain.qml +++ b/ui/app/mainui/AppMain.qml @@ -1324,7 +1324,7 @@ Item { // Add Status links to whitelist whiteListedSites.push({title: "Status", address: Constants.deepLinkPrefix, imageSite: false}) - whiteListedSites.push({title: "Status", address: Constants.joinStatusLink, imageSite: false}) + whiteListedSites.push({title: "Status", address: Constants.externalStatusLink, imageSite: false}) let settings = localAccountSensitiveSettings.whitelistedUnfurlingSites if (!settings) { @@ -1332,9 +1332,9 @@ Item { } // Set Status links as true. We intercept those URLs so it is privacy-safe - if (!settings[Constants.deepLinkPrefix] || !settings[Constants.joinStatusLink]) { + if (!settings[Constants.deepLinkPrefix] || !settings[Constants.externalStatusLink]) { settings[Constants.deepLinkPrefix] = true - settings[Constants.joinStatusLink] = true + settings[Constants.externalStatusLink] = true settingsUpdated = true } diff --git a/ui/imports/utils/Constants.qml b/ui/imports/utils/Constants.qml index 9cf6b5c551..619edf11c7 100644 --- a/ui/imports/utils/Constants.qml +++ b/ui/imports/utils/Constants.qml @@ -803,9 +803,10 @@ QtObject { readonly property int repeatHeaderInterval: 2 readonly property string deepLinkPrefix: 'status-app://' - readonly property string joinStatusLink: 'join.status.im' - readonly property string communityLinkPrefix: 'https://join.status.im/c/' - readonly property string userLinkPrefix: 'https://join.status.im/u/' + readonly property string externalStatusLink: 'status.app' + readonly property string externalStatusLinkWithHttps: 'https://' + externalStatusLink + readonly property string communityLinkPrefix: externalStatusLinkWithHttps + '/c/' + readonly property string userLinkPrefix: externalStatusLinkWithHttps + '/u/' readonly property string statusLinkPrefix: 'https://status.im/' readonly property int maxUploadFiles: 5 diff --git a/ui/imports/utils/Utils.qml b/ui/imports/utils/Utils.qml index aaacccb94f..75b7bf6a0b 100644 --- a/ui/imports/utils/Utils.qml +++ b/ui/imports/utils/Utils.qml @@ -315,7 +315,7 @@ QtObject { } function isStatusDeepLink(link) { - return link.includes(Constants.deepLinkPrefix) || link.includes(Constants.joinStatusLink) + return link.includes(Constants.deepLinkPrefix) || link.includes(Constants.externalStatusLink) } function hasImageExtension(url) {