kopia lustrzana https://github.com/cloudflare/wildebeest
MOW-114: fix id in account's statuses
rodzic
6f86378812
commit
2f9c55dd17
|
@ -3,7 +3,9 @@ import type { UUID } from 'wildebeest/backend/src/types'
|
||||||
// https://www.w3.org/TR/activitystreams-vocabulary/#object-types
|
// https://www.w3.org/TR/activitystreams-vocabulary/#object-types
|
||||||
export interface Object {
|
export interface Object {
|
||||||
type: string
|
type: string
|
||||||
|
// ObjectId, URL used for federation. Called `uri` in Mastodon APIs.
|
||||||
id: URL
|
id: URL
|
||||||
|
// Link to the HTML representation of the object
|
||||||
url: URL
|
url: URL
|
||||||
published?: string
|
published?: string
|
||||||
icon?: Object
|
icon?: Object
|
||||||
|
|
|
@ -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_unfollow from 'wildebeest/functions/api/v1/accounts/[id]/unfollow'
|
||||||
import * as accounts_statuses from 'wildebeest/functions/api/v1/accounts/[id]/statuses'
|
import * as accounts_statuses from 'wildebeest/functions/api/v1/accounts/[id]/statuses'
|
||||||
import * as accounts_get from 'wildebeest/functions/api/v1/accounts/[id]'
|
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_verify_creds from 'wildebeest/functions/api/v1/accounts/verify_credentials'
|
||||||
import * as accounts_update_creds from 'wildebeest/functions/api/v1/accounts/update_credentials'
|
import * as accounts_update_creds from 'wildebeest/functions/api/v1/accounts/update_credentials'
|
||||||
import { createPerson, getPersonById } from 'wildebeest/backend/src/activitypub/actors'
|
import { createPerson, getPersonById } from 'wildebeest/backend/src/activitypub/actors'
|
||||||
|
@ -353,13 +353,15 @@ describe('Mastodon APIs', () => {
|
||||||
const data = await res.json<Array<any>>()
|
const data = await res.json<Array<any>>()
|
||||||
assert.equal(data.length, 2)
|
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].content, 'my second status')
|
||||||
assert.equal(data[0].account.acct, 'sven@' + domain)
|
assert.equal(data[0].account.acct, 'sven@' + domain)
|
||||||
assert.equal(data[0].favourites_count, 0)
|
assert.equal(data[0].favourites_count, 0)
|
||||||
assert.equal(data[0].reblogs_count, 1)
|
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].content, 'my first status')
|
||||||
assert.equal(data[1].favourites_count, 1)
|
assert.equal(data[1].favourites_count, 1)
|
||||||
assert.equal(data[1].reblogs_count, 0)
|
assert.equal(data[1].reblogs_count, 0)
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
||||||
|
|
|
@ -169,9 +169,9 @@ LIMIT ?
|
||||||
const account = await loadExternalMastodonAccount(acct, author)
|
const account = await loadExternalMastodonAccount(acct, author)
|
||||||
|
|
||||||
out.push({
|
out.push({
|
||||||
id: result.mastodonId,
|
id: result.mastodon_id,
|
||||||
uri: objects.uri(domain, result.id),
|
uri: result.id,
|
||||||
url: new URL('/statuses/' + result.mastodonId, 'https://' + domain),
|
url: new URL('/statuses/' + result.mastodon_id, 'https://' + domain),
|
||||||
created_at: new Date(result.cdate).toISOString(),
|
created_at: new Date(result.cdate).toISOString(),
|
||||||
content: properties.content,
|
content: properties.content,
|
||||||
emojis: [],
|
emojis: [],
|
||||||
|
|
Ładowanie…
Reference in New Issue