fix broken status links

sven/fix-broken-status-link
Sven Sauleau 2023-02-20 14:33:56 +00:00
rodzic 5e77067324
commit 06a435fbfc
5 zmienionych plików z 7 dodań i 7 usunięć

Wyświetl plik

@ -254,7 +254,7 @@ export async function getNotifications(db: D1Database, actor: Actor, domain: str
id: result.mastodon_id,
content: properties.content,
uri: result.id,
url: new URL('/statuses/' + result.mastodon_id, 'https://' + domain),
url: new URL(`/@${actor.preferredUsername}/${result.mastodon_id}`, 'https://' + domain),
created_at: new Date(result.cdate).toISOString(),
account,

Wyświetl plik

@ -87,7 +87,7 @@ export async function toMastodonStatusFromObject(
content: obj.content || '',
id: obj[mastodonIdSymbol] || '',
uri: obj.id,
url: new URL('/statuses/' + obj[mastodonIdSymbol], 'https://' + domain),
url: new URL(`/@${actor.preferredUsername}/${obj[mastodonIdSymbol]}`, 'https://' + domain),
created_at: obj.published || '',
account,
@ -135,7 +135,7 @@ export async function toMastodonStatusFromRow(
const status: MastodonStatus = {
id: row.mastodon_id,
url: new URL('/statuses/' + row.mastodon_id, 'https://' + domain),
url: new URL(`/@${author.preferredUsername}/${row.mastodon_id}`, 'https://' + domain),
uri: row.id,
created_at: new Date(row.cdate).toISOString(),
emojis: [],

Wyświetl plik

@ -358,7 +358,7 @@ describe('Mastodon APIs', () => {
assert.equal(data[0].favourites_count, 0)
assert.equal(data[0].reblogs_count, 1)
assert.equal(new URL(data[0].uri).pathname, '/ap/o/' + data[0].id)
assert.equal(new URL(data[0].url).pathname, '/statuses/' + data[0].id)
assert.equal(new URL(data[0].url).pathname, '/@sven/' + data[0].id)
assert(isUUID(data[1].id))
assert.equal(data[1].content, 'my first status')

Wyświetl plik

@ -61,7 +61,7 @@ export async function handleRequest(
id: row.mastodon_id,
content: properties.content,
uri: row.id,
url: new URL('/statuses/' + row.mastodon_id, 'https://' + domain),
url: new URL(`/@${fromActor.preferredUsername}/${row.mastodon_id}`, 'https://' + domain),
created_at: new Date(row.cdate).toISOString(),
emojis: [],

Wyświetl plik

@ -45,7 +45,7 @@ test.describe('Presence of appropriate SEO metadata across the application', ()
title: "Raffa123$: I'm Rafael and I am a web desi… - Wildebeest",
description: "I'm Rafael and I am a web designer! 💪💪",
ogType: 'article',
ogUrl: /https:\/\/127.0.0.1\/statuses\/[\w-]*\/?/,
ogUrl: /https:\/\/127.0.0.1\/@Rafael\/[\w-]*\/?/,
ogImage: 'https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/157.jpg',
})
@ -55,7 +55,7 @@ test.describe('Presence of appropriate SEO metadata across the application', ()
title: 'Ben, just Ben: A very simple update: all good… - Wildebeest',
description: 'A very simple update: all good!',
ogType: 'article',
ogUrl: /https:\/\/127.0.0.1\/statuses\/[\w-]*\/?/,
ogUrl: /https:\/\/127.0.0.1\/@Ben\/[\w-]*\/?/,
ogImage: 'https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/1148.jpg',
})
})