This commit is contained in:
浪子
2026-05-15 22:40:43 +08:00
parent e2fcf08e2f
commit cba4901058
7 changed files with 205 additions and 9 deletions
+4 -3
View File
@@ -451,8 +451,8 @@ async function handleCreate(ctx: InboxContext): Promise<Response> {
return new Response(null, { status: 202 });
}
async function cacheRemoteNote(env: Env, actorId: string, note: Json, activity: Json = {}, fallback?: CachedStatus): Promise<void> {
if (typeof note.id !== "string") return;
export async function cacheRemoteNote(env: Env, actorId: string, note: Json, activity: Json = {}, fallback?: CachedStatus): Promise<CachedStatus | null> {
if (typeof note.id !== "string") return null;
const cachedId = note.id;
const recipients = collectRecipients(activity, note);
const mentions = note.tag === undefined ? parseJsonArray<CachedStatusMention>(fallback?.mentions_json) : extractRemoteMentions(note);
@@ -474,7 +474,7 @@ async function cacheRemoteNote(env: Env, actorId: string, note: Json, activity:
tags_json: JSON.stringify(tags),
local_recipients_json: JSON.stringify(localRecipients)
});
if (!stored) return;
if (!stored) return null;
await env.DB.prepare("DELETE FROM cached_status_attachments WHERE cached_status_id = ?").bind(stored.id).run();
const attachments = Array.isArray(note.attachment) ? note.attachment : note.attachment ? [note.attachment] : [];
let position = 0;
@@ -493,6 +493,7 @@ async function cacheRemoteNote(env: Env, actorId: string, note: Json, activity:
).bind(stored.id, position, url, null, mime, description).run();
position++;
}
return stored;
}
function inferRemoteVisibility(actorId: string, activity: Json, object: Json, fallback: string): string {