Add root tags to replies

This commit is contained in:
Alex Gleason 2024-05-21 14:27:49 -05:00
parent f21a7191ef
commit fc325880d2
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 13 additions and 4 deletions

View File

@ -76,14 +76,23 @@ const createStatusController: AppController = async (c) => {
const tags: string[][] = []; const tags: string[][] = [];
if (data.quote_id) { if (data.in_reply_to_id) {
tags.push(['q', data.quote_id]); const ancestor = await getEvent(data.in_reply_to_id);
if (!ancestor) {
return c.json({ error: 'Original post not found.' }, 404);
} }
if (data.in_reply_to_id) { const root = ancestor.tags.find((tag) => tag[0] === 'e' && tag[3] === 'root')?.[1] ?? ancestor.id;
tags.push(['e', root, 'root']);
tags.push(['e', data.in_reply_to_id, 'reply']); tags.push(['e', data.in_reply_to_id, 'reply']);
} }
if (data.quote_id) {
tags.push(['q', data.quote_id]);
}
if (data.sensitive && data.spoiler_text) { if (data.sensitive && data.spoiler_text) {
tags.push(['content-warning', data.spoiler_text]); tags.push(['content-warning', data.spoiler_text]);
} else if (data.sensitive) { } else if (data.sensitive) {