Merge branch 'fix-reblogged-always-on' into 'main'
Fix reblogged always on problem See merge request soapbox-pub/ditto!165
This commit is contained in:
commit
dd3604908b
|
@ -245,7 +245,7 @@ const reblogStatusController: AppController = async (c) => {
|
||||||
signal: signal,
|
signal: signal,
|
||||||
});
|
});
|
||||||
|
|
||||||
const status = await renderReblog(reblogEvent);
|
const status = await renderReblog(reblogEvent, { viewerPubkey: c.get('pubkey') });
|
||||||
|
|
||||||
return c.json(status);
|
return c.json(status);
|
||||||
};
|
};
|
||||||
|
|
|
@ -73,7 +73,7 @@ const streamingController: AppController = (c) => {
|
||||||
signal: AbortSignal.timeout(1000),
|
signal: AbortSignal.timeout(1000),
|
||||||
});
|
});
|
||||||
|
|
||||||
const status = await renderReblog(event);
|
const status = await renderReblog(event, { viewerPubkey: c.get('pubkey') });
|
||||||
if (status) {
|
if (status) {
|
||||||
send('update', status);
|
send('update', status);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ async function renderStatuses(c: AppContext, filters: NostrFilter[]) {
|
||||||
|
|
||||||
const statuses = (await Promise.all(events.map((event) => {
|
const statuses = (await Promise.all(events.map((event) => {
|
||||||
if (event.kind === 6) {
|
if (event.kind === 6) {
|
||||||
return renderReblog(event);
|
return renderReblog(event, { viewerPubkey: c.get('pubkey') });
|
||||||
}
|
}
|
||||||
return renderStatus(event, { viewerPubkey: c.get('pubkey') });
|
return renderStatus(event, { viewerPubkey: c.get('pubkey') });
|
||||||
}))).filter((boolean) => boolean);
|
}))).filter((boolean) => boolean);
|
||||||
|
|
|
@ -139,7 +139,12 @@ async function hydrateRepostEvents(opts: Omit<HydrateEventOpts, 'relations'>): P
|
||||||
const originalPostEvent = results.find((event) => event.id === originalPostId);
|
const originalPostEvent = results.find((event) => event.id === originalPostId);
|
||||||
if (!originalPostEvent) continue;
|
if (!originalPostEvent) continue;
|
||||||
|
|
||||||
await hydrateEvents({ events: [originalPostEvent], storage: storage, signal: signal, relations: ['author'] });
|
await hydrateEvents({
|
||||||
|
events: [originalPostEvent],
|
||||||
|
storage: storage,
|
||||||
|
signal: signal,
|
||||||
|
relations: ['author', 'event_stats'],
|
||||||
|
});
|
||||||
event.repost = originalPostEvent;
|
event.repost = originalPostEvent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
if (!event.author) return;
|
||||||
|
|
||||||
const repostId = event.tags.find(([name]) => name === 'e')?.[1];
|
const repostId = event.tags.find(([name]) => name === 'e')?.[1];
|
||||||
|
@ -119,8 +121,7 @@ async function renderReblog(event: DittoEvent) {
|
||||||
|
|
||||||
if (!event.repost) return;
|
if (!event.repost) return;
|
||||||
|
|
||||||
const reblog = await renderStatus(event.repost, {});
|
const reblog = await renderStatus(event.repost, { viewerPubkey });
|
||||||
reblog.reblogged = true;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: event.id,
|
id: event.id,
|
||||||
|
|
Loading…
Reference in New Issue