Don't display posts of disabled user on their profile

This commit is contained in:
Alex Gleason 2024-06-19 14:02:43 -05:00
parent 8bd67720d6
commit 003d60c959
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
5 changed files with 11 additions and 6 deletions

View file

@ -180,6 +180,13 @@ const accountStatusesController: AppController = async (c) => {
const store = await Storages.db(); const store = await Storages.db();
const [user] = await store.query([{ kinds: [30382], authors: [Conf.pubkey], '#d': [pubkey], limit: 1 }], { signal });
const names = getTagSet(user?.tags, 'n');
if (names.has('disabled')) {
return c.json([]);
}
if (pinned) { if (pinned) {
const [pinEvent] = await store.query([{ kinds: [10001], authors: [pubkey], limit: 1 }], { signal }); const [pinEvent] = await store.query([{ kinds: [10001], authors: [pubkey], limit: 1 }], { signal });
if (pinEvent) { if (pinEvent) {

View file

@ -146,6 +146,7 @@ const adminActionController: AppController = async (c) => {
n.silenced = true; n.silenced = true;
} }
if (data.type === 'suspend') { if (data.type === 'suspend') {
n.disabled = true;
n.suspended = true; n.suspended = true;
store.remove([{ authors: [authorId] }]).catch(console.warn); store.remove([{ authors: [authorId] }]).catch(console.warn);
} }

View file

@ -48,9 +48,6 @@ async function handleEvent(event: DittoEvent, signal: AbortSignal): Promise<void
if (n.has('disabled')) { if (n.has('disabled')) {
throw new RelayError('blocked', 'user is disabled'); throw new RelayError('blocked', 'user is disabled');
} }
if (n.has('suspended')) {
throw new RelayError('blocked', 'user is suspended');
}
await Promise.all([ await Promise.all([
storeEvent(event, signal), storeEvent(event, signal),

View file

@ -31,7 +31,7 @@ export class AdminStore implements NStore {
const n = getTagSet(user?.tags ?? [], 'n'); const n = getTagSet(user?.tags ?? [], 'n');
if (n.has('disabled') || n.has('suspended')) { if (n.has('disabled')) {
return false; return false;
} }

View file

@ -23,7 +23,7 @@ async function renderAccount(
const { pubkey } = event; const { pubkey } = event;
const names = getTagSet(event.user?.tags ?? [], 'n'); const names = getTagSet(event.user?.tags ?? [], 'n');
if (names.has('disabled') || names.has('suspended')) { if (names.has('disabled')) {
const account = await accountFromPubkey(pubkey, opts); const account = await accountFromPubkey(pubkey, opts);
account.pleroma.deactivated = true; account.pleroma.deactivated = true;
return account; return account;
@ -84,7 +84,7 @@ async function renderAccount(
accepts_zaps: Boolean(getLnurl({ lud06, lud16 })), accepts_zaps: Boolean(getLnurl({ lud06, lud16 })),
}, },
pleroma: { pleroma: {
deactivated: names.has('disabled') || names.has('suspended'), deactivated: names.has('disabled'),
is_admin: names.has('admin'), is_admin: names.has('admin'),
is_moderator: names.has('admin') || names.has('moderator'), is_moderator: names.has('admin') || names.has('moderator'),
is_suggested: names.has('suggested'), is_suggested: names.has('suggested'),