fix: reblogged field boolean value takes into account viewerPubkey

This commit is contained in:
P. Reis 2024-04-19 11:12:11 -03:00
parent ae5fe1e0ac
commit e2b377d9c7
4 changed files with 7 additions and 6 deletions

View File

@ -245,7 +245,7 @@ const reblogStatusController: AppController = async (c) => {
signal: signal,
});
const status = await renderReblog(reblogEvent);
const status = await renderReblog(reblogEvent, { viewerPubkey: c.get('pubkey') });
return c.json(status);
};

View File

@ -73,7 +73,7 @@ const streamingController: AppController = (c) => {
signal: AbortSignal.timeout(1000),
});
const status = await renderReblog(event);
const status = await renderReblog(event, { viewerPubkey: c.get('pubkey') });
if (status) {
send('update', status);
}

View File

@ -63,7 +63,7 @@ async function renderStatuses(c: AppContext, filters: NostrFilter[]) {
const statuses = (await Promise.all(events.map((event) => {
if (event.kind === 6) {
return renderReblog(event);
return renderReblog(event, { viewerPubkey: c.get('pubkey') });
}
return renderStatus(event, { viewerPubkey: c.get('pubkey') });
}))).filter((boolean) => boolean);

View File

@ -111,7 +111,9 @@ async function renderStatus(event: DittoEvent, opts: statusOpts): Promise<any> {
};
}
async function renderReblog(event: DittoEvent) {
async function renderReblog(event: DittoEvent, opts: statusOpts) {
const { viewerPubkey } = opts;
if (!event.author) return;
const repostId = event.tags.find(([name]) => name === 'e')?.[1];
@ -119,8 +121,7 @@ async function renderReblog(event: DittoEvent) {
if (!event.repost) return;
const reblog = await renderStatus(event.repost, {});
reblog.reblogged = true;
const reblog = await renderStatus(event.repost, { viewerPubkey });
return {
id: event.id,