chore(links): update to use the new external link format

Fixes #10777
This commit is contained in:
Jonathan Rainville 2023-05-23 16:01:39 -04:00
parent d04e121ab5
commit 7d0a77ef0d
8 changed files with 23 additions and 18 deletions

View File

@ -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/"

View File

@ -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()

View File

@ -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"] = %*{

View File

@ -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

View File

@ -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,

View File

@ -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
}

View File

@ -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

View File

@ -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) {