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';
|
import { hasTag } from '@/tags.ts';
|
||||||
|
|
||||||
async function renderRelationship(sourcePubkey: string, targetPubkey: string) {
|
async function renderRelationship(sourcePubkey: string, targetPubkey: string) {
|
||||||
const [source, target] = await Promise.all([
|
const [event3, target3, event10000, target10000] = await eventsDB.getEvents([
|
||||||
getFollows(sourcePubkey),
|
{ kinds: [3], authors: [sourcePubkey], limit: 1 },
|
||||||
getFollows(targetPubkey),
|
{ kinds: [3], authors: [targetPubkey], limit: 1 },
|
||||||
|
{ kinds: [10000], authors: [sourcePubkey], limit: 1 },
|
||||||
|
{ kinds: [10000], authors: [targetPubkey], limit: 1 },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: targetPubkey,
|
id: targetPubkey,
|
||||||
following: source ? hasTag(source.tags, ['p', targetPubkey]) : false,
|
following: event3 ? hasTag(event3.tags, ['p', targetPubkey]) : false,
|
||||||
showing_reblogs: true,
|
showing_reblogs: true,
|
||||||
notifying: false,
|
notifying: false,
|
||||||
followed_by: target ? hasTag(target.tags, ['p', sourcePubkey]) : false,
|
followed_by: target3 ? hasTag(target3?.tags, ['p', sourcePubkey]) : false,
|
||||||
blocking: false,
|
blocking: event10000 ? hasTag(target10000.tags, ['p', targetPubkey]) : false,
|
||||||
blocked_by: false,
|
blocked_by: target10000 ? hasTag(target10000.tags, ['p', sourcePubkey]) : false,
|
||||||
muting: false,
|
muting: false,
|
||||||
muting_notifications: false,
|
muting_notifications: false,
|
||||||
requested: false,
|
requested: false,
|
||||||
|
|
Loading…
Reference in New Issue