fix(@desktop/chat): Accept profile deep link in "Send Contact Request to chat key"

Fix #8070
This commit is contained in:
Michal Iskierko 2022-10-28 10:48:59 +02:00 committed by Michał Iskierko
parent 6a72773ab6
commit 234a164597
3 changed files with 16 additions and 5 deletions

View File

@ -414,12 +414,8 @@ QtObject {
return result return result
} }
function isStatusDeepLink(link) {
return link.includes(Constants.deepLinkPrefix) || link.includes(Constants.joinStatusLink)
}
function getLinkDataForStatusLinks(link) { function getLinkDataForStatusLinks(link) {
if (!isStatusDeepLink(link)) { if (!Utils.isStatusDeepLink(link)) {
return return
} }

View File

@ -56,6 +56,9 @@ StatusModal {
return return
} }
if (Utils.isStatusDeepLink(text)) {
text = Utils.getChatKeyFromShareLink(text)
}
Qt.callLater(d.lookupContact, text); Qt.callLater(d.lookupContact, text);
} }
} }

View File

@ -451,6 +451,10 @@ QtObject {
return matches[0].substring(3) return matches[0].substring(3)
} }
function isStatusDeepLink(link) {
return link.includes(Constants.deepLinkPrefix) || link.includes(Constants.joinStatusLink)
}
function hasImageExtension(url) { function hasImageExtension(url) {
return Constants.acceptedImageExtensions.some(ext => url.toLowerCase().includes(ext)) return Constants.acceptedImageExtensions.some(ext => url.toLowerCase().includes(ext))
} }
@ -604,6 +608,14 @@ QtObject {
return colorForColorId(pubKeyColorId) return colorForColorId(pubKeyColorId)
} }
function getChatKeyFromShareLink(link) {
let index = link.lastIndexOf("/u/")
if (index === -1) {
return link
}
return link.substring(index + 3)
}
function getCompressedPk(publicKey) { function getCompressedPk(publicKey) {
if (publicKey === "") { if (publicKey === "") {
return "" return ""