mirror of
https://github.com/kokonect-link/cherrypick
synced 2025-01-23 02:04:33 +09:00
feat: 사용자 메뉴에서 서버를 뮤트할 수 있음 (kokonect-link/cherrypick#502)
- 이전 빌드에 추가된 기능은 관리자 전용이며, 이 빌드에서 추가된 기능은 일반 사용자용 기능입니다.
This commit is contained in:
parent
e4cbb93860
commit
7586c6403f
@ -28,6 +28,10 @@ Misskey의 전체 변경 사항을 확인하려면, [CHANGELOG.md#2024xx](CHANGE
|
||||
기반 Misskey 버전: 2024.x.x<br>
|
||||
Misskey의 전체 변경 사항을 확인하려면, [CHANGELOG.md#2024xx](CHANGELOG.md#2024xx) 문서를 참고하십시오.
|
||||
|
||||
### General
|
||||
- Feat: 사용자 메뉴에서 서버를 뮤트할 수 있음 (kokonect-link/cherrypick#502)
|
||||
- 이전 빌드에 추가된 기능은 관리자 전용이며, 이 빌드에서 추가된 기능은 일반 사용자용 기능입니다.
|
||||
|
||||
### Client
|
||||
- Enhance: (Friendly) 모바일 환경에서 계정 목록을 표시할 때 내 프로필을 표시함
|
||||
- Enhance: 업데이트 및 마이그레이션 알림에서 CherryPick의 변경 사항만 표시함
|
||||
|
@ -51,9 +51,11 @@ 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);
|
||||
|
||||
const isInstanceBlocked = ref(false);
|
||||
const isInstanceSilenced = ref(false);
|
||||
const isInstanceMediaSilenced = ref(false);
|
||||
const isAdminInstanceBlocked = ref(false);
|
||||
const isAdminInstanceSilenced = ref(false);
|
||||
const isAdminInstanceMediaSilenced = ref(false);
|
||||
|
||||
const isInstanceMuted = ref(false);
|
||||
|
||||
async function fetch(): Promise<void> {
|
||||
if (iAmAdmin) {
|
||||
@ -62,25 +64,27 @@ export function getUserMenu(user: Misskey.entities.UserDetailed, router: IRouter
|
||||
instance.value = await misskeyApi('federation/show-instance', {
|
||||
host: user.host ?? host,
|
||||
});
|
||||
isInstanceBlocked.value = instance.value?.isBlocked ?? false;
|
||||
isInstanceSilenced.value = instance.value?.isSilenced ?? false;
|
||||
isInstanceMediaSilenced.value = instance.value?.isMediaSilenced ?? false;
|
||||
isAdminInstanceBlocked.value = instance.value?.isBlocked ?? false;
|
||||
isAdminInstanceSilenced.value = instance.value?.isSilenced ?? false;
|
||||
isAdminInstanceMediaSilenced.value = instance.value?.isMediaSilenced ?? false;
|
||||
|
||||
isInstanceMuted.value = $i?.mutedInstances?.some((mutedInstance: string) => mutedInstance === instance.value?.host) ?? false;
|
||||
}
|
||||
|
||||
fetch();
|
||||
|
||||
async function toggleInstanceBlock(): Promise<void> {
|
||||
async function toggleAdminInstanceBlock(): Promise<void> {
|
||||
if (!iAmAdmin) return;
|
||||
if (!meta.value) throw new Error('No meta?');
|
||||
if (!instance.value) throw new Error('No instance?');
|
||||
// eslint-disable-next-line no-shadow
|
||||
const { host } = instance.value;
|
||||
await misskeyApi('admin/update-meta', {
|
||||
blockedHosts: isInstanceBlocked.value ? meta.value.blockedHosts.concat([host]) : meta.value.blockedHosts.filter(x => x !== host),
|
||||
blockedHosts: isAdminInstanceBlocked.value ? meta.value.blockedHosts.concat([host]) : meta.value.blockedHosts.filter(x => x !== host),
|
||||
});
|
||||
}
|
||||
|
||||
async function toggleInstanceSilenced(): Promise<void> {
|
||||
async function toggleAdminInstanceSilenced(): Promise<void> {
|
||||
if (!iAmAdmin) return;
|
||||
if (!meta.value) throw new Error('No meta?');
|
||||
if (!instance.value) throw new Error('No instance?');
|
||||
@ -88,11 +92,11 @@ export function getUserMenu(user: Misskey.entities.UserDetailed, router: IRouter
|
||||
const { host } = instance.value;
|
||||
const silencedHosts = meta.value.silencedHosts ?? [];
|
||||
await misskeyApi('admin/update-meta', {
|
||||
silencedHosts: isInstanceSilenced.value ? silencedHosts.concat([host]) : silencedHosts.filter(x => x !== host),
|
||||
silencedHosts: isAdminInstanceSilenced.value ? silencedHosts.concat([host]) : silencedHosts.filter(x => x !== host),
|
||||
});
|
||||
}
|
||||
|
||||
async function toggleInstanceMediaSilenced(): Promise<void> {
|
||||
async function toggleAdminInstanceMediaSilenced(): Promise<void> {
|
||||
if (!iAmAdmin) return;
|
||||
if (!meta.value) throw new Error('No meta?');
|
||||
if (!instance.value) throw new Error('No instance?');
|
||||
@ -100,7 +104,19 @@ export function getUserMenu(user: Misskey.entities.UserDetailed, router: IRouter
|
||||
const { host } = instance.value;
|
||||
const mediaSilencedHosts = meta.value.mediaSilencedHosts ?? [];
|
||||
await misskeyApi('admin/update-meta', {
|
||||
mediaSilencedHosts: isInstanceMediaSilenced.value ? mediaSilencedHosts.concat([host]) : mediaSilencedHosts.filter(x => x !== host),
|
||||
mediaSilencedHosts: isAdminInstanceMediaSilenced.value ? mediaSilencedHosts.concat([host]) : mediaSilencedHosts.filter(x => x !== host),
|
||||
});
|
||||
}
|
||||
|
||||
async function toggleInstanceMute(): Promise<void> {
|
||||
if (!instance.value) throw new Error('No instance?');
|
||||
// eslint-disable-next-line no-shadow
|
||||
const { host } = instance.value;
|
||||
const mutedInstances = $i?.mutedInstances ?? [];
|
||||
await misskeyApi('i/update', {
|
||||
mutedInstances: isInstanceMuted.value
|
||||
? [...new Set(mutedInstances.concat([host]))]
|
||||
: mutedInstances.filter(x => x !== host),
|
||||
});
|
||||
}
|
||||
|
||||
@ -227,16 +243,20 @@ export function getUserMenu(user: Misskey.entities.UserDetailed, router: IRouter
|
||||
});
|
||||
}
|
||||
|
||||
watch(isInstanceBlocked, () => {
|
||||
toggleInstanceBlock();
|
||||
watch(isAdminInstanceBlocked, () => {
|
||||
toggleAdminInstanceBlock();
|
||||
});
|
||||
|
||||
watch(isInstanceSilenced, () => {
|
||||
toggleInstanceSilenced();
|
||||
watch(isAdminInstanceSilenced, () => {
|
||||
toggleAdminInstanceSilenced();
|
||||
});
|
||||
|
||||
watch(isInstanceMediaSilenced, () => {
|
||||
toggleInstanceMediaSilenced();
|
||||
watch(isAdminInstanceMediaSilenced, () => {
|
||||
toggleAdminInstanceMediaSilenced();
|
||||
});
|
||||
|
||||
watch(isInstanceMuted, () => {
|
||||
toggleInstanceMute();
|
||||
});
|
||||
|
||||
const menuItems: MenuItem[] = [];
|
||||
@ -500,25 +520,45 @@ export function getUserMenu(user: Misskey.entities.UserDetailed, router: IRouter
|
||||
menuItems.push({
|
||||
type: 'parent',
|
||||
icon: 'ti ti-server-cog',
|
||||
text: i18n.ts.instances,
|
||||
text: `${i18n.ts.instances} (${i18n.ts.administrator})`,
|
||||
children: async () => {
|
||||
const federationChildMenu = [] as MenuItem[];
|
||||
|
||||
federationChildMenu.push({
|
||||
type: 'switch',
|
||||
text: i18n.ts.blockThisInstance,
|
||||
ref: isInstanceBlocked,
|
||||
action: toggleInstanceBlock,
|
||||
ref: isAdminInstanceBlocked,
|
||||
action: toggleAdminInstanceBlock,
|
||||
}, {
|
||||
type: 'switch',
|
||||
text: i18n.ts.silenceThisInstance,
|
||||
ref: isInstanceSilenced,
|
||||
action: toggleInstanceSilenced,
|
||||
ref: isAdminInstanceSilenced,
|
||||
action: toggleAdminInstanceSilenced,
|
||||
}, {
|
||||
type: 'switch',
|
||||
text: i18n.ts.mediaSilenceThisInstance,
|
||||
ref: isInstanceMediaSilenced,
|
||||
action: toggleInstanceMediaSilenced,
|
||||
ref: isAdminInstanceMediaSilenced,
|
||||
action: toggleAdminInstanceMediaSilenced,
|
||||
});
|
||||
|
||||
return federationChildMenu;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (user.host !== null) {
|
||||
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.instanceMute,
|
||||
ref: isInstanceMuted,
|
||||
action: toggleInstanceMute,
|
||||
});
|
||||
|
||||
return federationChildMenu;
|
||||
|
Loading…
Reference in New Issue
Block a user