1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-11-23 22:56:53 +09:00

feat: 사용자 메뉴에서 원격 서버를 관리할 수 있음 (kokonect-link/cherrypick#502)

- 서버 차단, 서버 사일런스, 서버 미디어 사일런스
This commit is contained in:
NoriDev 2024-10-01 16:39:01 +09:00
parent fd3d2812fb
commit 61bfadc286
2 changed files with 75 additions and 2 deletions

View File

@ -35,6 +35,8 @@ Misskey의 전체 변경 사항을 확인하려면, [CHANGELOG.md#2024xx](CHANGE
- Feat: 내용이 긴 노트의 간략화 여부를 선택할 수 있음 (kokonect-link/cherrypick#495)
- Feat: 답글로 작성된 노트를 간략화하여 표시할 수 있음 (kokonect-link/cherrypick#495)
- 리액션한 노트는 옵션 활성화 유무와 상관없이 항상 표시됩니다.
- Feat: 사용자 메뉴에서 원격 서버를 관리할 수 있음 (kokonect-link/cherrypick#502)
- 서버 차단, 서버 사일런스, 서버 미디어 사일런스
- Enhance: CherryPick 업데이트 페이지를 제어판 목록에 추가함
- Enhance: Webhook 추가 버튼을 헤더로 이동해 디자인 개선
- Enhance: 노트 번역 영역에서도 이모지를 눌러 이모지 메뉴를 열 수 있음

View File

@ -13,7 +13,7 @@ import { copyToClipboard } from '@/scripts/copy-to-clipboard.js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { defaultStore, userActions } from '@/store.js';
import { $i, iAmModerator } from '@/account.js';
import { $i, iAmAdmin, iAmModerator } from '@/account.js';
import { notesSearchAvailable, canSearchNonLocalNotes } from '@/scripts/check-permissions.js';
import { IRouter } from '@/nirax.js';
import { antennasCache, rolesCache, userListsCache } from '@/cache.js';
@ -49,6 +49,41 @@ export function getUserMenu(user: Misskey.entities.UserDetailed, router: IRouter
});
}
const meta = ref<Misskey.entities.AdminMetaResponse | null>(null);
const instance = ref<Misskey.entities.FederationInstance | null>(null);
async function toggleInstanceBlock(): Promise<void> {
if (!iAmAdmin) return;
if (!meta.value) throw new Error('No meta?');
if (!instance.value) throw new Error('No instance?');
const { instanceHost } = instance.value;
await misskeyApi('admin/update-meta', {
blockedHosts: isBlocked.value ? meta.value.blockedHosts.concat([instanceHost]) : meta.value.blockedHosts.filter(x => x !== instanceHost),
});
}
async function toggleInstanceSilenced(): Promise<void> {
if (!iAmAdmin) return;
if (!meta.value) throw new Error('No meta?');
if (!instance.value) throw new Error('No instance?');
const { instanceHost } = instance.value;
const silencedHosts = meta.value.silencedHosts ?? [];
await misskeyApi('admin/update-meta', {
silencedHosts: isSilenced.value ? silencedHosts.concat([instanceHost]) : silencedHosts.filter(x => x !== instanceHost),
});
}
async function toggleInstanceMediaSilenced(): Promise<void> {
if (!iAmAdmin) return;
if (!meta.value) throw new Error('No meta?');
if (!instance.value) throw new Error('No instance?');
const { instanceHost } = instance.value;
const mediaSilencedHosts = meta.value.mediaSilencedHosts ?? [];
await misskeyApi('admin/update-meta', {
mediaSilencedHosts: isMediaSilenced.value ? mediaSilencedHosts.concat([instanceHost]) : mediaSilencedHosts.filter(x => x !== instanceHost),
});
}
async function toggleMute() {
if (user.isMuted) {
os.apiWithDialog('mute/delete', {
@ -425,7 +460,43 @@ export function getUserMenu(user: Misskey.entities.UserDetailed, router: IRouter
});
//}
menuItems.push({ type: 'divider' }, {
menuItems.push({ type: 'divider' });
const isInstanceBlocked = ref(instance.value?.isBlocked ?? false);
const isInstanceSilenced = ref(instance.value?.isSilenced ?? false);
const isInstanceMediaSilenced = ref(instance.value?.isMediaSilenced ?? false);
if (iAmAdmin && (meta.value || instance.value)) {
menuItems.push({
type: 'parent',
icon: 'ti ti-server-cog',
text: i18n.ts.instances,
children: async () => {
const federationChildMenu = [] as MenuItem[];
federationChildMenu.push({
type: 'switch',
text: i18n.ts.blockThisInstance,
ref: isInstanceBlocked,
action: toggleInstanceBlock,
}, {
type: 'switch',
text: i18n.ts.silenceThisInstance,
ref: isInstanceSilenced,
action: toggleInstanceSilenced,
}, {
type: 'switch',
text: i18n.ts.mediaSilenceThisInstance,
ref: isInstanceMediaSilenced,
action: toggleInstanceMediaSilenced,
});
return federationChildMenu;
},
});
}
menuItems.push({
icon: user.isMuted ? 'ti ti-eye' : 'ti ti-eye-off',
text: user.isMuted ? i18n.ts.unmute : i18n.ts.mute,
action: toggleMute,