feat: add back status link whitelisting and public chat links

This commit is contained in:
Jonathan Rainville 2021-03-05 13:45:39 -05:00 committed by Iuri Matias
parent 907fbc21b8
commit c5c348b0b1
2 changed files with 59 additions and 21 deletions

View File

@ -169,17 +169,30 @@ RowLayout {
try {
const whiteListedSites = JSON.parse(whitelist)
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
// 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 = []
// Add whitelisted sites in to app settings that are not already there
whiteListedSites.forEach(site => {
if (!settings.hasOwnProperty(site.address)) {
settings[site.address] = false
settingsUpdated = true
}
whitelistedHostnames.push(site.address)
})
if (!settings.hasOwnProperty(site.address)) {
settings[site.address] = false
settingsUpdated = true
}
whitelistedHostnames.push(site.address)
})
// Remove any whitelisted sites from app settings that don't exist in the
// whitelist from status-go
Object.keys(settings).forEach(settingsHostname => {
@ -425,7 +438,7 @@ RowLayout {
browserLayoutContainer.active = true;
}
timelineLayoutContainer.active = this.children[currentIndex] == timelineLayoutContainer
timelineLayoutContainer.active = this.children[currentIndex] === timelineLayoutContainer
if(this.children[currentIndex] === walletLayoutContainer){
walletLayoutContainer.showSigningPhrasePopup();

View File

@ -308,32 +308,57 @@ QtObject {
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) {
if (!link.includes(Constants.deepLinkPrefix) && !link.includes(Constants.joinStatusLink)) {
return
}
let title = "Status"
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);
}
}
const result = getLinkTitleAndCb(link)
return {
site: qsTr("Status app link"),
title: title,
title: result.title,
thumbnailUrl: "../../../../img/status.png",
contentType: "",
height: 0,
width: 0,
callback: callback
callback: result.callback
}
}