upd: add bubble to instance federation page as state

Closes #296
This commit is contained in:
Marie 2024-01-02 13:35:03 +01:00
parent 81dea75eb7
commit a1a57889fc
No known key found for this signature in database
GPG key ID: 56569BBE47D2C828
2 changed files with 20 additions and 0 deletions

View file

@ -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<typeof meta, typeof paramDef> { // 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))');