Merge pull request #130 from cloudflare/sven/MOW-114

MOW-114: fix id in account's statuses
pull/135/head
Sven Sauleau 2023-01-18 11:47:27 +01:00 zatwierdzone przez GitHub
commit 09499aad11
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
4 zmienionych plików z 18 dodań i 6 usunięć

Wyświetl plik

@ -3,7 +3,9 @@ import type { UUID } from 'wildebeest/backend/src/types'
// https://www.w3.org/TR/activitystreams-vocabulary/#object-types
export interface Object {
type: string
// ObjectId, URL used for federation. Called `uri` in Mastodon APIs.
id: URL
// Link to the HTML representation of the object
url: URL
published?: string
icon?: Object

Wyświetl plik

@ -11,7 +11,7 @@ import * as accounts_follow from 'wildebeest/functions/api/v1/accounts/[id]/foll
import * as accounts_unfollow from 'wildebeest/functions/api/v1/accounts/[id]/unfollow'
import * as accounts_statuses from 'wildebeest/functions/api/v1/accounts/[id]/statuses'
import * as accounts_get from 'wildebeest/functions/api/v1/accounts/[id]'
import { isUrlValid, makeDB, assertCORS, assertJSON, makeQueue } from '../utils'
import { isUUID, isUrlValid, makeDB, assertCORS, assertJSON, makeQueue } from '../utils'
import * as accounts_verify_creds from 'wildebeest/functions/api/v1/accounts/verify_credentials'
import * as accounts_update_creds from 'wildebeest/functions/api/v1/accounts/update_credentials'
import { createPerson, getPersonById } from 'wildebeest/backend/src/activitypub/actors'
@ -353,13 +353,15 @@ describe('Mastodon APIs', () => {
const data = await res.json<Array<any>>()
assert.equal(data.length, 2)
assert(!isUrlValid(data[0].id))
assert(isUUID(data[0].id))
assert.equal(data[0].content, 'my second status')
assert.equal(data[0].account.acct, 'sven@' + domain)
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(!isUrlValid(data[1].id))
assert(isUUID(data[1].id))
assert.equal(data[1].content, 'my first status')
assert.equal(data[1].favourites_count, 1)
assert.equal(data[1].reblogs_count, 0)

Wyświetl plik

@ -90,3 +90,11 @@ export function makeQueue(): TestQueue {
},
}
}
export function isUUID(v: string): boolean {
assert.equal(typeof v, 'string')
if (v.match('^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$') === null) {
return false
}
return true
}

Wyświetl plik

@ -169,9 +169,9 @@ LIMIT ?
const account = await loadExternalMastodonAccount(acct, author)
out.push({
id: result.mastodonId,
uri: objects.uri(domain, result.id),
url: new URL('/statuses/' + result.mastodonId, 'https://' + domain),
id: result.mastodon_id,
uri: result.id,
url: new URL('/statuses/' + result.mastodon_id, 'https://' + domain),
created_at: new Date(result.cdate).toISOString(),
content: properties.content,
emojis: [],