add role policy "canViewFederation"
This commit is contained in:
parent
aff1603788
commit
479e6daa1d
22 changed files with 84 additions and 13 deletions
20
locales/index.d.ts
vendored
20
locales/index.d.ts
vendored
|
|
@ -6005,6 +6005,22 @@ export interface Locale extends ILocale {
|
|||
* New
|
||||
*/
|
||||
"new": string;
|
||||
/**
|
||||
* Restrict to roles
|
||||
*/
|
||||
"onlyForRoles": string;
|
||||
/**
|
||||
* Change role restrictions
|
||||
*/
|
||||
"onlyForRolesChange": string;
|
||||
/**
|
||||
* Shown to everyone
|
||||
*/
|
||||
"onlyForRolesUnrestricted": string;
|
||||
/**
|
||||
* Shown to members of {roles} roles
|
||||
*/
|
||||
"onlyForRolesRestricted": ParameterizedString<"roles">;
|
||||
/**
|
||||
* Throw confetti
|
||||
*/
|
||||
|
|
@ -7651,6 +7667,10 @@ export interface Locale extends ILocale {
|
|||
* Can appear in trending notes / users
|
||||
*/
|
||||
"canTrend": string;
|
||||
/**
|
||||
* Can view federation stats and details of remote instances
|
||||
*/
|
||||
"canViewFederation": string;
|
||||
};
|
||||
"_condition": {
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ export type RolePolicies = {
|
|||
canImportUserLists: boolean;
|
||||
chatAvailability: 'available' | 'readonly' | 'unavailable';
|
||||
canTrend: boolean;
|
||||
canViewFederation: boolean;
|
||||
};
|
||||
|
||||
export const DEFAULT_POLICIES: RolePolicies = {
|
||||
|
|
@ -110,6 +111,7 @@ export const DEFAULT_POLICIES: RolePolicies = {
|
|||
canImportUserLists: true,
|
||||
chatAvailability: 'available',
|
||||
canTrend: true,
|
||||
canViewFederation: true,
|
||||
};
|
||||
|
||||
@Injectable()
|
||||
|
|
@ -472,6 +474,7 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
|
|||
canImportUserLists: calc('canImportUserLists', vs => vs.some(v => v === true)),
|
||||
chatAvailability: calc('chatAvailability', aggregateChatAvailability),
|
||||
canTrend: calc('canTrend', vs => vs.some(v => v === true)),
|
||||
canViewFederation: calc('canViewFederation', vs => vs.some(v => v === true)),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -313,6 +313,10 @@ export const packedRolePoliciesSchema = {
|
|||
type: 'boolean',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
canViewFederation: {
|
||||
type: 'boolean',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ import { schema } from '@/core/chart/charts/entities/federation.js';
|
|||
export const meta = {
|
||||
tags: ['charts'],
|
||||
|
||||
requiredRolePolicy: 'canViewFederation',
|
||||
|
||||
res: getJsonSchema(schema),
|
||||
|
||||
allowGet: true,
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ import { schema } from '@/core/chart/charts/entities/instance.js';
|
|||
export const meta = {
|
||||
tags: ['charts'],
|
||||
|
||||
requiredRolePolicy: 'canViewFederation',
|
||||
|
||||
res: getJsonSchema(schema),
|
||||
|
||||
allowGet: true,
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import { FollowingEntityService } from '@/core/entities/FollowingEntityService.j
|
|||
export const meta = {
|
||||
tags: ['federation'],
|
||||
|
||||
requiredRolePolicy: 'canViewFederation',
|
||||
requireCredential: true,
|
||||
kind: 'read:account',
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import { FollowingEntityService } from '@/core/entities/FollowingEntityService.j
|
|||
export const meta = {
|
||||
tags: ['federation'],
|
||||
|
||||
requiredRolePolicy: 'canViewFederation',
|
||||
requireCredential: true,
|
||||
kind: 'read:account',
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import { sqlLikeEscape } from '@/misc/sql-like-escape.js';
|
|||
export const meta = {
|
||||
tags: ['federation'],
|
||||
|
||||
requiredRolePolicy: 'canViewFederation',
|
||||
requireCredential: false,
|
||||
allowGet: true,
|
||||
cacheSec: 3600,
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import { DI } from '@/di-symbols.js';
|
|||
export const meta = {
|
||||
tags: ['federation'],
|
||||
|
||||
requiredRolePolicy: 'canViewFederation',
|
||||
requireCredential: false,
|
||||
|
||||
res: {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import { DI } from '@/di-symbols.js';
|
|||
export const meta = {
|
||||
tags: ['federation'],
|
||||
|
||||
requiredRolePolicy: 'canViewFederation',
|
||||
requireCredential: false,
|
||||
|
||||
allowGet: true,
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import { DI } from '@/di-symbols.js';
|
|||
export const meta = {
|
||||
tags: ['federation'],
|
||||
|
||||
requiredRolePolicy: 'canViewFederation',
|
||||
requireCredential: false,
|
||||
|
||||
res: {
|
||||
|
|
|
|||
|
|
@ -178,6 +178,7 @@ export const ROLE_POLICIES = [
|
|||
'canImportUserLists',
|
||||
'chatAvailability',
|
||||
'canTrend',
|
||||
'canViewFederation',
|
||||
] as const;
|
||||
|
||||
export const MFM_TAGS = ['tada', 'jelly', 'twitch', 'shake', 'spin', 'jump', 'bounce', 'flip', 'x2', 'x3', 'x4', 'scale', 'position', 'fg', 'bg', 'border', 'font', 'blur', 'rainbow', 'sparkle', 'rotate', 'ruby', 'unixtime', 'crop', 'fade', 'followmouse'];
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ import { useChartTooltip } from '@/use/use-chart-tooltip.js';
|
|||
import { $i } from '@/i.js';
|
||||
import * as os from '@/os.js';
|
||||
import { misskeyApiGet } from '@/utility/misskey-api.js';
|
||||
import { instance } from '@/instance.js';
|
||||
import { instance, policies } from '@/instance.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import MkHeatmap from '@/components/MkHeatmap.vue';
|
||||
import MkFoldableSection from '@/components/MkFoldableSection.vue';
|
||||
|
|
@ -103,7 +103,7 @@ import { initChart } from '@/utility/init-chart.js';
|
|||
|
||||
initChart();
|
||||
|
||||
const shouldShowFederation = computed(() => instance.federation !== 'none' || $i?.isModerator);
|
||||
const shouldShowFederation = computed(() => (instance.federation !== 'none' || $i?.isModerator) && policies.canViewFederation);
|
||||
|
||||
const chartLimit = 500;
|
||||
const chartSpan = ref<'hour' | 'day'>('hour');
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ import MkButton from '@/components/MkButton.vue';
|
|||
import { widgets as widgetDefs, federationWidgets } from '@/widgets/index.js';
|
||||
import * as os from '@/os.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import { instance } from '@/instance.js';
|
||||
import { instance, policies } from '@/instance.js';
|
||||
|
||||
const Sortable = defineAsyncComponent(() => import('vuedraggable').then(x => x.default));
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ const props = defineProps<{
|
|||
}>();
|
||||
|
||||
const _widgetDefs = computed(() => {
|
||||
if (instance.federation === 'none') {
|
||||
if (instance.federation === 'none' || !policies.value.canViewFederation) {
|
||||
return widgetDefs.filter(x => !federationWidgets.includes(x));
|
||||
} else {
|
||||
return widgetDefs;
|
||||
|
|
|
|||
|
|
@ -22,10 +22,11 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
|
||||
<script lang="ts" setup>
|
||||
import { computed, defineAsyncComponent, ref, watch } from 'vue';
|
||||
import { instance } from '@/instance.js';
|
||||
import { instance, policies } from '@/instance.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import { claimAchievement } from '@/utility/achievements.js';
|
||||
import { definePage } from '@/page.js';
|
||||
import type { Tab } from '@/components/global/MkPageHeader.tabs.vue';
|
||||
|
||||
const XOverview = defineAsyncComponent(() => import('@/pages/about.overview.vue'));
|
||||
const XEmojis = defineAsyncComponent(() => import('@/pages/about.emojis.vue'));
|
||||
|
|
@ -49,7 +50,7 @@ watch(tab, () => {
|
|||
const headerActions = computed(() => []);
|
||||
|
||||
const headerTabs = computed(() => {
|
||||
const items = [];
|
||||
const items: Tab[] = [];
|
||||
|
||||
items.push({
|
||||
key: 'overview',
|
||||
|
|
@ -60,7 +61,7 @@ const headerTabs = computed(() => {
|
|||
icon: 'ph-smiley ph-bold ph-lg',
|
||||
});
|
||||
|
||||
if (instance.federation !== 'none') {
|
||||
if (instance.federation !== 'none' && policies.value.canViewFederation) {
|
||||
items.push({
|
||||
key: 'federation',
|
||||
title: i18n.ts.federation,
|
||||
|
|
|
|||
|
|
@ -817,6 +817,26 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
</MkRange>
|
||||
</div>
|
||||
</MkFolder>
|
||||
|
||||
<MkFolder v-if="matchQuery([i18n.ts._role._options.canViewFederation, 'canViewFederation'])">
|
||||
<template #label>{{ i18n.ts._role._options.canViewFederation }}</template>
|
||||
<template #suffix>
|
||||
<span v-if="role.policies.canViewFederation.useDefault" :class="$style.useDefaultLabel">{{ i18n.ts._role.useBaseValue }}</span>
|
||||
<span v-else>{{ role.policies.canViewFederation.value ? i18n.ts.yes : i18n.ts.no }}</span>
|
||||
<span :class="$style.priorityIndicator"><i :class="getPriorityIcon(role.policies.canViewFederation)"></i></span>
|
||||
</template>
|
||||
<div class="_gaps">
|
||||
<MkSwitch v-model="role.policies.canViewFederation.useDefault" :readonly="readonly">
|
||||
<template #label>{{ i18n.ts._role.useBaseValue }}</template>
|
||||
</MkSwitch>
|
||||
<MkSwitch v-model="role.policies.canViewFederation.value" :disabled="role.policies.canViewFederation.useDefault" :readonly="readonly">
|
||||
<template #label>{{ i18n.ts.enable }}</template>
|
||||
</MkSwitch>
|
||||
<MkRange v-model="role.policies.canViewFederation.priority" :min="0" :max="2" :step="1" easing :textConverter="(v) => v === 0 ? i18n.ts._role._priority.low : v === 1 ? i18n.ts._role._priority.middle : v === 2 ? i18n.ts._role._priority.high : ''">
|
||||
<template #label>{{ i18n.ts._role.priority }}</template>
|
||||
</MkRange>
|
||||
</div>
|
||||
</MkFolder>
|
||||
</div>
|
||||
</FormSlot>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -308,6 +308,14 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<template #label>{{ i18n.ts.enable }}</template>
|
||||
</MkSwitch>
|
||||
</MkFolder>
|
||||
|
||||
<MkFolder v-if="matchQuery([i18n.ts._role._options.canViewFederation, 'canViewFederation'])">
|
||||
<template #label>{{ i18n.ts._role._options.canViewFederation }}</template>
|
||||
<template #suffix>{{ policies.canViewFederation ? i18n.ts.yes : i18n.ts.no }}</template>
|
||||
<MkSwitch v-model="policies.canViewFederation">
|
||||
<template #label>{{ i18n.ts.enable }}</template>
|
||||
</MkSwitch>
|
||||
</MkFolder>
|
||||
</div>
|
||||
</MkFolder>
|
||||
<MkButton primary rounded @click="create"><i class="ti ti-plus"></i> {{ i18n.ts._role.new }}</MkButton>
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<MkSelect v-model="statusbar.type" placeholder="Please select">
|
||||
<template #label>{{ i18n.ts.type }}</template>
|
||||
<option value="rss">RSS</option>
|
||||
<option v-if="instance.federation !== 'none'" value="federation">Federation</option>
|
||||
<option v-if="instance.federation !== 'none' && policies.canViewFederation" value="federation">Federation</option>
|
||||
<option value="userList">User list timeline</option>
|
||||
</MkSelect>
|
||||
|
||||
|
|
@ -95,7 +95,7 @@ import MkRadios from '@/components/MkRadios.vue';
|
|||
import MkButton from '@/components/MkButton.vue';
|
||||
import MkRange from '@/components/MkRange.vue';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import { instance } from '@/instance.js';
|
||||
import { instance, policies } from '@/instance.js';
|
||||
import { deepClone } from '@/utility/clone.js';
|
||||
import { prefer } from '@/preferences.js';
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
import { defineAsyncComponent } from 'vue';
|
||||
import type { MenuItem } from '@/types/menu.js';
|
||||
import * as os from '@/os.js';
|
||||
import { instance } from '@/instance.js';
|
||||
import { instance, policies } from '@/instance.js';
|
||||
import { host } from '@@/js/config.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import { $i } from '@/i.js';
|
||||
|
|
@ -58,7 +58,7 @@ export function openInstanceMenu(ev: MouseEvent) {
|
|||
to: '/about#emojis',
|
||||
});
|
||||
|
||||
if (instance.federation !== 'none') {
|
||||
if (instance.federation !== 'none' && policies.value.canViewFederation) {
|
||||
menuItems.push({
|
||||
type: 'link',
|
||||
text: i18n.ts.federation,
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
>
|
||||
<span :class="$style.name">{{ x.name }}</span>
|
||||
<XRss v-if="x.type === 'rss'" :class="$style.body" :refreshIntervalSec="x.props.refreshIntervalSec" :marqueeDuration="x.props.marqueeDuration" :marqueeReverse="x.props.marqueeReverse" :display="x.props.display" :url="x.props.url" :shuffle="x.props.shuffle"/>
|
||||
<XFederation v-else-if="x.type === 'federation' && instance.federation !== 'none'" :class="$style.body" :refreshIntervalSec="x.props.refreshIntervalSec" :marqueeDuration="x.props.marqueeDuration" :marqueeReverse="x.props.marqueeReverse" :display="x.props.display" :colored="x.props.colored"/>
|
||||
<XFederation v-else-if="x.type === 'federation' && instance.federation !== 'none' && policies.canViewFederation" :class="$style.body" :refreshIntervalSec="x.props.refreshIntervalSec" :marqueeDuration="x.props.marqueeDuration" :marqueeReverse="x.props.marqueeReverse" :display="x.props.display" :colored="x.props.colored"/>
|
||||
<XUserList v-else-if="x.type === 'userList'" :class="$style.body" :refreshIntervalSec="x.props.refreshIntervalSec" :marqueeDuration="x.props.marqueeDuration" :marqueeReverse="x.props.marqueeReverse" :display="x.props.display" :userListId="x.props.userListId"/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -23,7 +23,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
|
||||
<script lang="ts" setup>
|
||||
import { defineAsyncComponent } from 'vue';
|
||||
import { instance } from '@/instance.js';
|
||||
import { instance, policies } from '@/instance.js';
|
||||
import { prefer } from '@/preferences.js';
|
||||
const XRss = defineAsyncComponent(() => import('./statusbar-rss.vue'));
|
||||
const XFederation = defineAsyncComponent(() => import('./statusbar-federation.vue'));
|
||||
|
|
|
|||
|
|
@ -5558,6 +5558,7 @@ export type components = {
|
|||
/** @enum {string} */
|
||||
chatAvailability: 'available' | 'readonly' | 'unavailable';
|
||||
canTrend: boolean;
|
||||
canViewFederation: boolean;
|
||||
};
|
||||
ReversiGameLite: {
|
||||
/** Format: id */
|
||||
|
|
@ -5642,6 +5643,7 @@ export type components = {
|
|||
*/
|
||||
uri: string;
|
||||
description: string | null;
|
||||
about: string | null;
|
||||
langs: string[];
|
||||
tosUrl: string | null;
|
||||
/** @default https://github.com/misskey-dev/misskey */
|
||||
|
|
@ -12256,6 +12258,7 @@ export type operations = {
|
|||
name?: string | null;
|
||||
shortName?: string | null;
|
||||
description?: string | null;
|
||||
about?: string | null;
|
||||
defaultLightTheme?: string | null;
|
||||
defaultDarkTheme?: string | null;
|
||||
defaultLike?: string;
|
||||
|
|
|
|||
|
|
@ -250,6 +250,7 @@ _role:
|
|||
canUpdateBioMedia: "Allow users to edit their avatar or banner"
|
||||
scheduleNoteMax: "Maximum number of scheduled notes"
|
||||
canTrend: "Can appear in trending notes / users"
|
||||
canViewFederation: "Can view federation stats and details of remote instances"
|
||||
_condition:
|
||||
isLocked: "Private account"
|
||||
isExplorable: "Account is discoverable"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue