From a1a57889fc1e5094b2ff10989295a2d2eab544ff Mon Sep 17 00:00:00 2001 From: Marie Date: Tue, 2 Jan 2024 13:35:03 +0100 Subject: [PATCH] upd: add bubble to instance federation page as state Closes #296 --- .../api/endpoints/federation/instances.ts | 18 ++++++++++++++++++ .../frontend/src/pages/about.federation.vue | 2 ++ 2 files changed, 20 insertions(+) diff --git a/packages/backend/src/server/api/endpoints/federation/instances.ts b/packages/backend/src/server/api/endpoints/federation/instances.ts index 617ca6573..053da421d 100644 --- a/packages/backend/src/server/api/endpoints/federation/instances.ts +++ b/packages/backend/src/server/api/endpoints/federation/instances.ts @@ -41,6 +41,7 @@ export const paramDef = { subscribing: { type: 'boolean', nullable: true }, publishing: { type: 'boolean', nullable: true }, nsfw: { type: 'boolean', nullable: true }, + bubble: { type: 'boolean', nullable: true }, limit: { type: 'integer', minimum: 1, maximum: 100, default: 30 }, offset: { type: 'integer', default: 0 }, sort: { @@ -148,6 +149,23 @@ export default class extends Endpoint { // eslint- } } + if (typeof ps.bubble === 'boolean') { + const meta = await this.metaService.fetch(true); + + if (ps.bubble) { + if (meta.bubbleInstances.length === 0) { + return []; + } + query.andWhere('instance.host IN (:...bubble)', { + silences: meta.bubbleInstances, + }); + } else if (meta.bubbleInstances.length > 0) { + query.andWhere('instance.host NOT IN (:...bubble)', { + bubble: meta.bubbleInstances, + }); + } + } + if (typeof ps.federating === 'boolean') { if (ps.federating) { query.andWhere('((instance.followingCount > 0) OR (instance.followersCount > 0))'); diff --git a/packages/frontend/src/pages/about.federation.vue b/packages/frontend/src/pages/about.federation.vue index 0de000ee3..32942f413 100644 --- a/packages/frontend/src/pages/about.federation.vue +++ b/packages/frontend/src/pages/about.federation.vue @@ -17,6 +17,7 @@ SPDX-License-Identifier: AGPL-3.0-only + @@ -80,6 +81,7 @@ const pagination = { state.value === 'silenced' ? { silenced: true } : state.value === 'notResponding' ? { notResponding: true } : state.value === 'nsfw' ? { nsfw: true } : + state.value === 'bubble' ? { nsfw: true } : {}), })), } as Paging;