Skip to content

Commit

Permalink
fix: "share" button in Safari, also support i.delta.chat bot URLs in …
Browse files Browse the repository at this point in the history
…data.json
  • Loading branch information
adbenitez committed Sep 18, 2024
1 parent 36b0a4f commit 70cd41e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
22 changes: 11 additions & 11 deletions frontend/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,67 +4,67 @@
"description": "Web to PDF converter",
"lang": "en",
"admin": "merlinux",
"url": "OPENPGP4FPR:43B48FD6AFE0B780E08DEDE70A0DB16EDBE137EC#a=web2pdf01%40bcc.chat&n=Web%20to%20PDF&i=aVeg_0fMaME&s=48WGSWyaIru"
"url": "https://i.delta.chat/#43B48FD6AFE0B780E08DEDE70A0DB16EDBE137EC&a=web2pdf01%40bcc.chat&n=Web%20to%20PDF&i=aVeg_0fMaME&s=48WGSWyaIru"
},
{
"description": "Web to PDF converter",
"lang": "en",
"admin": "merlinux",
"url": "OPENPGP4FPR:036AB60803636BFE628487D52910CB443DC82A14#a=web2pdf01%40chatd.de&n=Web%20to%20PDF&i=sNjYQWgFM8l&s=PA4ZYzoj3Gj"
"url": "https://i.delta.chat/#036AB60803636BFE628487D52910CB443DC82A14&a=web2pdf01%40chatd.de&n=Web%20to%20PDF&i=sNjYQWgFM8l&s=PA4ZYzoj3Gj"
},
{
"description": "Web to PDF converter",
"lang": "en",
"admin": "merlinux",
"url": "OPENPGP4FPR:F9E20FD1B062C8CB3CD90A3ADF54C732669F52BE#a=web2pdf01%40deltachat.jurkiewicz.chat&n=Web%20to%20PDF&i=ZH9xqcz2Yra&s=ksFvupfwbiD"
"url": "https://i.delta.chat/#F9E20FD1B062C8CB3CD90A3ADF54C732669F52BE&a=web2pdf01%40deltachat.jurkiewicz.chat&n=Web%20to%20PDF&i=ZH9xqcz2Yra&s=ksFvupfwbiD"
},
{
"description": "Telegram puppeting bridge, use your Telegram account from Delta Chat",
"lang": "en",
"admin": "Nelson",
"url": "OPENPGP4FPR:86AB6AADA7896473AC198C180E9F66EE8539422B#a=telegrbot%40nine.testrun.org&n=Telegram%20Bridge&i=ZgHg_yRaeKG&s=xZQJtzESp0j"
"url": "https://i.delta.chat/#86AB6AADA7896473AC198C180E9F66EE8539422B&a=telegrbot%40nine.testrun.org&n=Telegram%20Bridge&i=ZgHg_yRaeKG&s=xZQJtzESp0j"
},
{
"description": "Conversational AI chat-bot assistant for Delta Chat",
"lang": "en",
"admin": "merlinux",
"url": "OPENPGP4FPR:A11808CEE7890F00B54EB64183C1FA40200635D5#a=chatbot%40testrun.org&n=Mia&i=1uiiAtibina&s=iyHlIA_MABH"
"url": "https://i.delta.chat/#A11808CEE7890F00B54EB64183C1FA40200635D5&a=chatbot%40testrun.org&n=Mia&i=1uiiAtibina&s=iyHlIA_MABH"
},
{
"description": "Conversational AI chat-bot assistant for Delta Chat",
"lang": "en",
"admin": "merlinux",
"url": "OPENPGP4FPR:1EDD34FF7513D09F6DA300A765285E7A1C9DA72A#a=simplebot08%40gmail.com&n=Mia&i=9BnkBMZU3lZ&s=l5CJimJA-tV"
"url": "https://i.delta.chat/#1EDD34FF7513D09F6DA300A765285E7A1C9DA72A&a=simplebot08%40gmail.com&n=Mia&i=9BnkBMZU3lZ&s=l5CJimJA-tV"
},
{
"description": "Bot to generate images given a text prompt",
"lang": "en",
"admin": "merlinux",
"url": "OPENPGP4FPR:2FE05BD53A28A912A4AA74BF7BE6FD5E547473CC#a=txt2image%40nine.testrun.org&n=Text%20To%20Image&i=cbTmzlMa0-C&s=EWZ_FsPcd0R"
"url": "https://i.delta.chat/#2FE05BD53A28A912A4AA74BF7BE6FD5E547473CC&a=txt2image%40nine.testrun.org&n=Text%20To%20Image&i=cbTmzlMa0-C&s=EWZ_FsPcd0R"
},
{
"description": "Bot to generate images given a text prompt",
"lang": "en",
"admin": "merlinux",
"url": "OPENPGP4FPR:793E87929F3B318AE30321C298260C27A4D813E4#a=d3lt4b0t02%40gmail.com&n=Text%20To%20Image&i=Ep0SGi9JzQH&s=EVOpL4okIV7"
"url": "https://i.delta.chat/#793E87929F3B318AE30321C298260C27A4D813E4&a=d3lt4b0t02%40gmail.com&n=Text%20To%20Image&i=Ep0SGi9JzQH&s=EVOpL4okIV7"
},
{
"description": "Bot that can help you extract text from voice messages, also works in groups",
"lang": "multi",
"admin": "merlinux",
"url": "OPENPGP4FPR:81EDFA2AEBCF4ECDF357A5E6F383F813547CB9D7#a=voice2text%40testrun.org&n=Voice%20To%20Text&i=zSBD_nJBpTn&s=NVYndJrYBOU"
"url": "https://i.delta.chat/#81EDFA2AEBCF4ECDF357A5E6F383F813547CB9D7&a=voice2text%40testrun.org&n=Voice%20To%20Text&i=zSBD_nJBpTn&s=NVYndJrYBOU"
},
{
"description": "Bot that can help you extract text from voice messages, also works in groups",
"lang": "multi",
"admin": "merlinux",
"url": "OPENPGP4FPR:924B09EB934CF0F836ADD3D1C8F56A8070D5506E#a=voice2txt%40nine.testrun.org&n=Voice%20To%20Text&i=PYu7OFENQUo&s=7vGNO0Q4zE4"
"url": "https://i.delta.chat/#924B09EB934CF0F836ADD3D1C8F56A8070D5506E&a=voice2txt%40nine.testrun.org&n=Voice%20To%20Text&i=PYu7OFENQUo&s=7vGNO0Q4zE4"
},
{
"description": "Bot that can help you extract text from voice messages, also works in groups",
"lang": "multi",
"admin": "merlinux",
"url": "OPENPGP4FPR:55477D81DA0B25AE2CEF67B5FBEB871642BC9DBD#a=voice2txt%40deltachat.jurkiewicz.chat&n=Voice%20To%20Text&i=FowjxBzf4G7&s=YJIyngjmI-u"
"url": "https://i.delta.chat/#55477D81DA0B25AE2CEF67B5FBEB871642BC9DBD&a=voice2txt%40deltachat.jurkiewicz.chat&n=Voice%20To%20Text&i=FowjxBzf4G7&s=YJIyngjmI-u"
},
{
"description": "Web gateway, get URL previews and download files",
Expand Down
2 changes: 1 addition & 1 deletion frontend/public/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.6.0
2.6.1
22 changes: 17 additions & 5 deletions frontend/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ function isOnline(lastSync: Date, lastSeen?: Date): boolean {
return timeAgo <= recently;
}

function getInviteLink(string uri): string {
if (uri.startsWith('https://i.delta.chat')) {
return uri;
}
return 'https://i.delta.chat/#' + uri.replace(/openpgp4fpr:/i, '').replace('#', '&');
}

function getQrData(string uri): string {
if (uri.startsWith('https://i.delta.chat')) {
return 'openpgp4fpr:' + uri.replace(/https:\/\/i.delta.chat\/?#/, '').replace(/&/, '#');
}
return uri;
}

export const api = (() => {
return {
sync: (force: boolean = false) => {
Expand Down Expand Up @@ -98,14 +112,12 @@ export const useStore = create<State>()((set) => ({
if (bot.lastSeen) {
bot.lastSeen = new Date(bot.lastSeen);
}
const url = new URL(bot.url);
bot.inviteLink = getInviteLink(bot.url);
bot.url = getQrData(bot.url);
const url = new URL(bot.inviteLink);
const params = new URLSearchParams(url.hash.substring(1));
bot.addr = params.get("a");
bot.name = params.get("n");
url.protocol = "https:"; // this must be done before using url.host
url.hash = "#" + url.host + "&" + url.hash.substring(1);
url.host = "i.delta.chat";
bot.inviteLink = url.toString();
});
state.hash = botsData.hash;
state.bots = botsData.bots;
Expand Down

0 comments on commit 70cd41e

Please sign in to comment.