Allowlist implementation
This commit is contained in:
parent
d1e8653449
commit
9dcc7645ea
22 changed files with 158 additions and 5 deletions
|
@ -21,6 +21,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<option value="suspended">{{ i18n.ts.suspended }}</option>
|
||||
<option value="silenced">{{ i18n.ts.silence }}</option>
|
||||
<option value="blocked">{{ i18n.ts.blocked }}</option>
|
||||
<option value="allowed">{{ i18n.ts.allowed }}</option>
|
||||
<option value="notResponding">{{ i18n.ts.notResponding }}</option>
|
||||
</MkSelect>
|
||||
<MkSelect v-model="sort">
|
||||
|
@ -77,6 +78,7 @@ const pagination = {
|
|||
state.value === 'publishing' ? { publishing: true } :
|
||||
state.value === 'suspended' ? { suspended: true } :
|
||||
state.value === 'blocked' ? { blocked: true } :
|
||||
state.value === 'allowed' ? { allowed: true } :
|
||||
state.value === 'silenced' ? { silenced: true } :
|
||||
state.value === 'notResponding' ? { notResponding: true } :
|
||||
state.value === 'nsfw' ? { nsfw: true } :
|
||||
|
|
|
@ -24,6 +24,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<option value="nsfw">NSFW</option>
|
||||
<option value="suspended">{{ i18n.ts.suspended }}</option>
|
||||
<option value="blocked">{{ i18n.ts.blocked }}</option>
|
||||
<option value="allowed">{{ i18n.ts.allowed }}</option>
|
||||
<option value="silenced">{{ i18n.ts.silence }}</option>
|
||||
<option value="notResponding">{{ i18n.ts.notResponding }}</option>
|
||||
</MkSelect>
|
||||
|
@ -85,6 +86,7 @@ const pagination = {
|
|||
state.value === 'publishing' ? { publishing: true } :
|
||||
state.value === 'suspended' ? { suspended: true } :
|
||||
state.value === 'blocked' ? { blocked: true } :
|
||||
state.value === 'allowed' ? { allowed: true } :
|
||||
state.value === 'silenced' ? { silenced: true } :
|
||||
state.value === 'notResponding' ? { notResponding: true } :
|
||||
state.value === 'nsfw' ? { nsfw: true } :
|
||||
|
@ -98,6 +100,7 @@ function getStatus(instance) {
|
|||
if (instance.isSilenced) return 'Silenced';
|
||||
if (instance.isNotResponding) return 'Error';
|
||||
if (instance.isNSFW) return 'NSFW';
|
||||
if (instance.isAllowed) return 'Allowed';
|
||||
return 'Alive';
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,14 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<span>{{ i18n.ts.silencedInstances }}</span>
|
||||
<template #caption>{{ i18n.ts.silencedInstancesDescription }}</template>
|
||||
</MkTextarea>
|
||||
<template v-else-if="tab === 'allow'">
|
||||
<MkSwitch v-model="allowlistMode">{{ i18n.ts.allowlistModeDescription }}</MkSwitch>
|
||||
<br />
|
||||
<MkTextarea v-model="allowedHosts" class="_formBlock">
|
||||
<span>{{ i18n.ts.allowedInstances }}</span>
|
||||
<template #caption>{{ i18n.ts.allowedInstancesDescription }}</template>
|
||||
</MkTextarea>
|
||||
</template>
|
||||
<MkButton primary @click="save"><i class="ph-floppy-disk ph-bold ph-lg"></i> {{ i18n.ts.save }}</MkButton>
|
||||
</FormSuspense>
|
||||
</MkSpacer>
|
||||
|
@ -27,6 +35,7 @@ import { ref, computed } from 'vue';
|
|||
import XHeader from './_header_.vue';
|
||||
import MkButton from '@/components/MkButton.vue';
|
||||
import MkTextarea from '@/components/MkTextarea.vue';
|
||||
import MkSwitch from '@/components/MkSwitch.vue';
|
||||
import FormSuspense from '@/components/form/suspense.vue';
|
||||
import * as os from '@/os.js';
|
||||
import { fetchInstance } from '@/instance.js';
|
||||
|
@ -35,18 +44,24 @@ import { definePageMetadata } from '@/scripts/page-metadata.js';
|
|||
|
||||
const blockedHosts = ref<string>('');
|
||||
const silencedHosts = ref<string>('');
|
||||
const tab = ref('block');
|
||||
const allowedHosts = ref<string>('');
|
||||
const allowlistMode = ref<boolean>(false);
|
||||
const tab = ref('allow');
|
||||
|
||||
async function init() {
|
||||
const meta = await os.api('admin/meta');
|
||||
blockedHosts.value = meta.blockedHosts.join('\n');
|
||||
silencedHosts.value = meta.silencedHosts.join('\n');
|
||||
allowedHosts.value = meta.allowedHosts.join('\n');
|
||||
allowlistMode.value = meta.allowlistMode;
|
||||
}
|
||||
|
||||
function save() {
|
||||
os.apiWithDialog('admin/update-meta', {
|
||||
blockedHosts: blockedHosts.value.split('\n') || [],
|
||||
silencedHosts: silencedHosts.value.split('\n') || [],
|
||||
allowedHosts: allowedHosts.value.split('\n') || [],
|
||||
allowlistMode: allowlistMode.value || false,
|
||||
|
||||
}).then(() => {
|
||||
fetchInstance();
|
||||
|
@ -63,6 +78,10 @@ const headerTabs = computed(() => [{
|
|||
key: 'silence',
|
||||
title: i18n.ts.silence,
|
||||
icon: 'ph-eye-closed ph-bold ph-lg',
|
||||
}, {
|
||||
key: 'allow',
|
||||
title: i18n.ts.allow,
|
||||
icon: 'ph-prohibit ph-bold ph-lg',
|
||||
}]);
|
||||
|
||||
definePageMetadata({
|
||||
|
|
|
@ -36,6 +36,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<div class="_gaps_s">
|
||||
<MkSwitch v-model="suspended" :disabled="!instance" @update:modelValue="toggleSuspend">{{ i18n.ts.stopActivityDelivery }}</MkSwitch>
|
||||
<MkSwitch v-model="isBlocked" :disabled="!meta || !instance" @update:modelValue="toggleBlock">{{ i18n.ts.blockThisInstance }}</MkSwitch>
|
||||
<MkSwitch v-model="isAllowed" :disabled="!meta || !instance" @update:modelValue="toggleAllow">{{ i18n.ts.allowThisInstance }}</MkSwitch>
|
||||
<MkSwitch v-model="isSilenced" :disabled="!meta || !instance" @update:modelValue="toggleSilenced">{{ i18n.ts.silenceThisInstance }}</MkSwitch>
|
||||
<MkSwitch v-model="isNSFW" :disabled="!instance" @update:modelValue="toggleNSFW">Mark as NSFW</MkSwitch>
|
||||
<MkButton @click="refreshMetadata"><i class="ph-arrows-counter-clockwise ph-bold ph-lg"></i> Refresh metadata</MkButton>
|
||||
|
@ -149,6 +150,7 @@ const meta = ref<Misskey.entities.AdminMetaResponse | null>(null);
|
|||
const instance = ref<Misskey.entities.FederationInstance | null>(null);
|
||||
const suspended = ref(false);
|
||||
const isBlocked = ref(false);
|
||||
const isAllowed = ref(false);
|
||||
const isSilenced = ref(false);
|
||||
const isNSFW = ref(false);
|
||||
const faviconUrl = ref<string | null>(null);
|
||||
|
@ -173,6 +175,7 @@ async function fetch(): Promise<void> {
|
|||
});
|
||||
suspended.value = instance.value?.isSuspended ?? false;
|
||||
isBlocked.value = instance.value?.isBlocked ?? false;
|
||||
isAllowed.value = instance.value?.isAllowed ?? false;
|
||||
isSilenced.value = instance.value?.isSilenced ?? false;
|
||||
isNSFW.value = instance.value?.isNSFW ?? false;
|
||||
faviconUrl.value = getProxiedImageUrlNullable(instance.value?.faviconUrl, 'preview') ?? getProxiedImageUrlNullable(instance.value?.iconUrl, 'preview');
|
||||
|
@ -187,6 +190,15 @@ async function toggleBlock(): Promise<void> {
|
|||
});
|
||||
}
|
||||
|
||||
async function toggleAllow(): Promise<void> {
|
||||
if (!meta.value) throw new Error('No meta?');
|
||||
if (!instance.value) throw new Error('No instance?');
|
||||
const { host } = instance.value;
|
||||
await os.api('admin/update-meta', {
|
||||
allowedHosts: isAllowed.value ? meta.value.allowedHosts.concat([host]) : meta.value.allowedHosts.filter(x => x !== host),
|
||||
});
|
||||
}
|
||||
|
||||
async function toggleSilenced(): Promise<void> {
|
||||
if (!meta.value) throw new Error('No meta?');
|
||||
if (!instance.value) throw new Error('No instance?');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue