mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
fix: don't display posts from blocked users
This commit is contained in:
parent
620fd6bb74
commit
c0f5fc7b76
1 changed files with 13 additions and 2 deletions
|
|
@ -51,11 +51,22 @@ const getFollows = async (pubkey: string, signal?: AbortSignal): Promise<NostrEv
|
||||||
return event;
|
return event;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Get pubkeys the user follows. */
|
/** Get pubkeys the user follows that are not blocked. */
|
||||||
async function getFollowedPubkeys(pubkey: string, signal?: AbortSignal): Promise<string[]> {
|
async function getFollowedPubkeys(pubkey: string, signal?: AbortSignal): Promise<string[]> {
|
||||||
const event = await getFollows(pubkey, signal);
|
const event = await getFollows(pubkey, signal);
|
||||||
if (!event) return [];
|
if (!event) return [];
|
||||||
return [...getTagSet(event.tags, 'p')];
|
const followedPubkeys = getTagSet(event.tags, 'p');
|
||||||
|
|
||||||
|
const [blockedUsersEvent] = await eventsDB.query([{ authors: [pubkey], kinds: [10000], limit: 1 }], {
|
||||||
|
limit: 1,
|
||||||
|
signal,
|
||||||
|
});
|
||||||
|
if (blockedUsersEvent) {
|
||||||
|
const blockedPubkeys = getTagSet(blockedUsersEvent.tags, 'p');
|
||||||
|
blockedPubkeys.forEach((blockedPub) => followedPubkeys.delete(blockedPub));
|
||||||
|
}
|
||||||
|
|
||||||
|
return [...followedPubkeys];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get pubkeys the user follows, including the user's own pubkey. */
|
/** Get pubkeys the user follows, including the user's own pubkey. */
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue