Fix follow notification get

Follow notifications don't have a corresponding Object so make the SQL
join optional.
pull/94/head
Sven Sauleau 2023-01-12 13:57:22 +00:00
rodzic 1d5f4b0b0d
commit a2722a18d9
2 zmienionych plików z 20 dodań i 2 usunięć

Wyświetl plik

@ -72,7 +72,7 @@ describe('Mastodon APIs', () => {
assert.equal(notifications[2].status, undefined)
})
test('get single non existant notification', async () => {
test('get single favourite notification', async () => {
const db = await makeDB()
const actor = await createPerson(domain, db, userKEK, 'sven@cloudflare.com')
const fromActor = await createPerson(domain, db, userKEK, 'from@cloudflare.com')
@ -91,6 +91,24 @@ describe('Mastodon APIs', () => {
assert.equal(data.status.content, 'my first status')
})
test('get single follow notification', async () => {
const db = await makeDB()
const actor = await createPerson(domain, db, userKEK, 'sven@cloudflare.com')
const fromActor = await createPerson(domain, db, userKEK, 'from@cloudflare.com')
await insertFollowNotification(db, actor, fromActor)
const res = await notifications_get.handleRequest(domain, '1', db, actor)
assert.equal(res.status, 200)
assertJSON(res)
const data = await res.json<any>()
assert.equal(data.id, '1')
assert.equal(data.type, 'follow')
assert.equal(data.account.acct, 'from@cloudflare.com')
assert.equal(data.status, undefined)
})
test('send like notification', async () => {
const db = await makeDB()

Wyświetl plik

@ -32,7 +32,7 @@ export async function handleRequest(
actor_notifications.cdate as notif_cdate,
actor_notifications.id as notif_id
FROM actor_notifications
INNER JOIN objects ON objects.id=actor_notifications.object_id
LEFT JOIN objects ON objects.id=actor_notifications.object_id
WHERE actor_notifications.id=? AND actor_notifications.actor_id=?
`