Optimize the relationships controller, support block relationships
This commit is contained in:
parent
63fb934220
commit
6d1375ba59
|
@ -1,20 +1,22 @@
|
|||
import { getFollows } from '@/queries.ts';
|
||||
import { eventsDB } from '@/db/events.ts';
|
||||
import { hasTag } from '@/tags.ts';
|
||||
|
||||
async function renderRelationship(sourcePubkey: string, targetPubkey: string) {
|
||||
const [source, target] = await Promise.all([
|
||||
getFollows(sourcePubkey),
|
||||
getFollows(targetPubkey),
|
||||
const [event3, target3, event10000, target10000] = await eventsDB.getEvents([
|
||||
{ kinds: [3], authors: [sourcePubkey], limit: 1 },
|
||||
{ kinds: [3], authors: [targetPubkey], limit: 1 },
|
||||
{ kinds: [10000], authors: [sourcePubkey], limit: 1 },
|
||||
{ kinds: [10000], authors: [targetPubkey], limit: 1 },
|
||||
]);
|
||||
|
||||
return {
|
||||
id: targetPubkey,
|
||||
following: source ? hasTag(source.tags, ['p', targetPubkey]) : false,
|
||||
following: event3 ? hasTag(event3.tags, ['p', targetPubkey]) : false,
|
||||
showing_reblogs: true,
|
||||
notifying: false,
|
||||
followed_by: target ? hasTag(target.tags, ['p', sourcePubkey]) : false,
|
||||
blocking: false,
|
||||
blocked_by: false,
|
||||
followed_by: target3 ? hasTag(target3?.tags, ['p', sourcePubkey]) : false,
|
||||
blocking: event10000 ? hasTag(target10000.tags, ['p', targetPubkey]) : false,
|
||||
blocked_by: target10000 ? hasTag(target10000.tags, ['p', sourcePubkey]) : false,
|
||||
muting: false,
|
||||
muting_notifications: false,
|
||||
requested: false,
|
||||
|
|
Loading…
Reference in New Issue