kopia lustrzana https://github.com/cloudflare/wildebeest
53 wiersze
1.2 KiB
TypeScript
53 wiersze
1.2 KiB
TypeScript
// https://www.w3.org/TR/activitystreams-vocabulary/#object-types
|
|
|
|
import type { Actor } from 'wildebeest/backend/src/activitypub/actors'
|
|
import type { Document } from 'wildebeest/backend/src/activitypub/objects'
|
|
import { followersURL } from 'wildebeest/backend/src/activitypub/actors'
|
|
import * as objects from '.'
|
|
|
|
const NOTE = 'Note'
|
|
export const PUBLIC = 'https://www.w3.org/ns/activitystreams#Public'
|
|
|
|
// https://www.w3.org/TR/activitystreams-vocabulary/#dfn-note
|
|
export interface Note extends objects.Object {
|
|
content: string
|
|
attributedTo?: string
|
|
summary?: string
|
|
inReplyTo?: string
|
|
replies?: string
|
|
to: Array<string>
|
|
attachment: Array<Document>
|
|
cc?: Array<string>
|
|
tag?: Array<string>
|
|
}
|
|
|
|
export async function createPublicNote(
|
|
domain: string,
|
|
db: D1Database,
|
|
content: string,
|
|
actor: Actor,
|
|
attachment: Array<Document> = [],
|
|
extraProperties: any = {}
|
|
): Promise<Note> {
|
|
const actorId = new URL(actor.id)
|
|
|
|
const properties = {
|
|
attributedTo: actorId,
|
|
content,
|
|
to: [PUBLIC],
|
|
cc: [followersURL(actorId)],
|
|
|
|
// FIXME: stub values
|
|
inReplyTo: null,
|
|
replies: null,
|
|
sensitive: false,
|
|
summary: null,
|
|
tag: [],
|
|
attachment,
|
|
|
|
...extraProperties,
|
|
}
|
|
|
|
return (await objects.createObject(domain, db, NOTE, properties, actorId, true)) as Note
|
|
}
|