mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-19 18:18:38 +00:00
feat: add back status link whitelisting and public chat links
This commit is contained in:
parent
907fbc21b8
commit
c5c348b0b1
@ -169,17 +169,30 @@ RowLayout {
|
|||||||
try {
|
try {
|
||||||
const whiteListedSites = JSON.parse(whitelist)
|
const whiteListedSites = JSON.parse(whitelist)
|
||||||
let settingsUpdated = false
|
let settingsUpdated = false
|
||||||
|
|
||||||
|
// Add Status links to whitelist
|
||||||
|
whiteListedSites.push({title: "Status", address: Constants.deepLinkPrefix, imageSite: false})
|
||||||
|
whiteListedSites.push({title: "Status", address: Constants.joinStatusLink, imageSite: false})
|
||||||
|
|
||||||
const settings = appSettings.whitelistedUnfurlingSites
|
const settings = appSettings.whitelistedUnfurlingSites
|
||||||
|
|
||||||
|
// Set Status links as true. We intercept thoseURLs so it is privacy-safe
|
||||||
|
if (!settings[Constants.deepLinkPrefix] || !settings[Constants.joinStatusLink]) {
|
||||||
|
settings[Constants.deepLinkPrefix] = true
|
||||||
|
settings[Constants.joinStatusLink] = true
|
||||||
|
settingsUpdated = true
|
||||||
|
}
|
||||||
|
|
||||||
const whitelistedHostnames = []
|
const whitelistedHostnames = []
|
||||||
|
|
||||||
// Add whitelisted sites in to app settings that are not already there
|
// Add whitelisted sites in to app settings that are not already there
|
||||||
whiteListedSites.forEach(site => {
|
whiteListedSites.forEach(site => {
|
||||||
if (!settings.hasOwnProperty(site.address)) {
|
if (!settings.hasOwnProperty(site.address)) {
|
||||||
settings[site.address] = false
|
settings[site.address] = false
|
||||||
settingsUpdated = true
|
settingsUpdated = true
|
||||||
}
|
}
|
||||||
whitelistedHostnames.push(site.address)
|
whitelistedHostnames.push(site.address)
|
||||||
})
|
})
|
||||||
// Remove any whitelisted sites from app settings that don't exist in the
|
// Remove any whitelisted sites from app settings that don't exist in the
|
||||||
// whitelist from status-go
|
// whitelist from status-go
|
||||||
Object.keys(settings).forEach(settingsHostname => {
|
Object.keys(settings).forEach(settingsHostname => {
|
||||||
@ -425,7 +438,7 @@ RowLayout {
|
|||||||
browserLayoutContainer.active = true;
|
browserLayoutContainer.active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
timelineLayoutContainer.active = this.children[currentIndex] == timelineLayoutContainer
|
timelineLayoutContainer.active = this.children[currentIndex] === timelineLayoutContainer
|
||||||
|
|
||||||
if(this.children[currentIndex] === walletLayoutContainer){
|
if(this.children[currentIndex] === walletLayoutContainer){
|
||||||
walletLayoutContainer.showSigningPhrasePopup();
|
walletLayoutContainer.showSigningPhrasePopup();
|
||||||
|
@ -308,32 +308,57 @@ QtObject {
|
|||||||
return (/( |\t|\n|\r)/.test(c))
|
return (/( |\t|\n|\r)/.test(c))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getLinkTitleAndCb(link) {
|
||||||
|
const result = {
|
||||||
|
title: "Status",
|
||||||
|
callback: null
|
||||||
|
}
|
||||||
|
|
||||||
|
// Link to send a direct message
|
||||||
|
let index = link.indexOf("/u/")
|
||||||
|
if (index === -1) {
|
||||||
|
// Try /p/ as well
|
||||||
|
index = link.indexOf("/p/")
|
||||||
|
}
|
||||||
|
if (index > -1) {
|
||||||
|
const pk = link.substring(index + 3)
|
||||||
|
result.title = qsTr("Start a 1 on 1 chat with %1").arg(utilsModel.generateAlias(pk))
|
||||||
|
result.callback = function () {
|
||||||
|
chatsModel.joinChat(pk, Constants.chatTypeOneToOne);
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
// Public chat
|
||||||
|
// This needs to be the last check because it is as VERY loose check
|
||||||
|
index = link.lastIndexOf("/")
|
||||||
|
if (index > -1) {
|
||||||
|
const chatId = link.substring(index + 1)
|
||||||
|
result.title = qsTr("Join the %1 public channel").arg(chatId)
|
||||||
|
result.callback = function () {
|
||||||
|
chatsModel.joinChat(chatId, Constants.chatTypePublic);
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
function getLinkDataForStatusLinks(link) {
|
function getLinkDataForStatusLinks(link) {
|
||||||
if (!link.includes(Constants.deepLinkPrefix) && !link.includes(Constants.joinStatusLink)) {
|
if (!link.includes(Constants.deepLinkPrefix) && !link.includes(Constants.joinStatusLink)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let title = "Status"
|
const result = getLinkTitleAndCb(link)
|
||||||
let callback = function () {}
|
|
||||||
|
|
||||||
// Link to send a direct message
|
|
||||||
let index = link.indexOf("/u/")
|
|
||||||
if (index > -1) {
|
|
||||||
const pk = link.substring(index + 3)
|
|
||||||
title = qsTr("Start a 1 on 1 chat with %1").arg(utilsModel.generateAlias(pk))
|
|
||||||
callback = function () {
|
|
||||||
chatsModel.joinChat(pk, Constants.chatTypeOneToOne);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
site: qsTr("Status app link"),
|
site: qsTr("Status app link"),
|
||||||
title: title,
|
title: result.title,
|
||||||
thumbnailUrl: "../../../../img/status.png",
|
thumbnailUrl: "../../../../img/status.png",
|
||||||
contentType: "",
|
contentType: "",
|
||||||
height: 0,
|
height: 0,
|
||||||
width: 0,
|
width: 0,
|
||||||
callback: callback
|
callback: result.callback
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user