Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

連合に関する情報を隠す #2

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions packages/backend/src/server/api/ApiServerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,7 @@ export class ApiServerService {
fastify.post<{ Body: { code: string; } }>('/signup-pending', (request, reply) => this.signupApiService.signupPending(request, reply));

fastify.get('/v1/instance/peers', async (request, reply) => {
const instances = await this.instancesRepository.find({
select: ['host'],
where: {
isSuspended: false,
},
});

return instances.map(instance => instance.host);
reply.code(404).send();
});

fastify.post<{ Params: { session: string; } }>('/miauth/:session/check', async (request, reply) => {
Expand Down
5 changes: 3 additions & 2 deletions packages/backend/src/server/api/endpoints/charts/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ export const meta = {

res: getJsonSchema(schema),

allowGet: true,
cacheSec: 60 * 60,
requireCredential: true,

kind: 'read:account',
} as const;

export const paramDef = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import { sqlLikeEscape } from '@/misc/sql-like-escape.js';
export const meta = {
tags: ['federation'],

requireCredential: false,
allowGet: true,
cacheSec: 3600,
requireCredential: true,

kind: 'read:account',

res: {
type: 'array',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import { DI } from '@/di-symbols.js';
export const meta = {
tags: ['federation'],

requireCredential: false,
requireCredential: true,

kind: 'read:account',

res: {
type: 'object',
Expand Down
5 changes: 2 additions & 3 deletions packages/backend/src/server/api/endpoints/federation/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ import { DI } from '@/di-symbols.js';
export const meta = {
tags: ['federation'],

requireCredential: false,
requireCredential: true,

allowGet: true,
cacheSec: 60 * 60,
kind: 'read:account',

res: {
type: 'object',
Expand Down
14 changes: 7 additions & 7 deletions packages/frontend/src/components/MkChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ SPDX-License-Identifier: AGPL-3.0-only
*/
import { onMounted, ref, shallowRef, watch, PropType } from 'vue';
import { Chart } from 'chart.js';
import { misskeyApiGet } from '@/scripts/misskey-api.js';
import { misskeyApi, misskeyApiGet } from '@/scripts/misskey-api.js';
import { defaultStore } from '@/store.js';
import { useChartTooltip } from '@/scripts/use-chart-tooltip.js';
import { chartVLine } from '@/scripts/chart-vline.js';
Expand Down Expand Up @@ -570,7 +570,7 @@ const fetchDriveFilesChart = async (): Promise<typeof chartData> => {
};

const fetchInstanceRequestsChart = async (): Promise<typeof chartData> => {
const raw = await misskeyApiGet('charts/instance', { host: props.args?.host, limit: props.limit, span: props.span });
const raw = await misskeyApi('charts/instance', { host: props.args?.host, limit: props.limit, span: props.span });
return {
series: [{
name: 'In',
Expand All @@ -592,7 +592,7 @@ const fetchInstanceRequestsChart = async (): Promise<typeof chartData> => {
};

const fetchInstanceUsersChart = async (total: boolean): Promise<typeof chartData> => {
const raw = await misskeyApiGet('charts/instance', { host: props.args?.host, limit: props.limit, span: props.span });
const raw = await misskeyApi('charts/instance', { host: props.args?.host, limit: props.limit, span: props.span });
return {
series: [{
name: 'Users',
Expand All @@ -607,7 +607,7 @@ const fetchInstanceUsersChart = async (total: boolean): Promise<typeof chartData
};

const fetchInstanceNotesChart = async (total: boolean): Promise<typeof chartData> => {
const raw = await misskeyApiGet('charts/instance', { host: props.args?.host, limit: props.limit, span: props.span });
const raw = await misskeyApi('charts/instance', { host: props.args?.host, limit: props.limit, span: props.span });
return {
series: [{
name: 'Notes',
Expand All @@ -622,7 +622,7 @@ const fetchInstanceNotesChart = async (total: boolean): Promise<typeof chartData
};

const fetchInstanceFfChart = async (total: boolean): Promise<typeof chartData> => {
const raw = await misskeyApiGet('charts/instance', { host: props.args?.host, limit: props.limit, span: props.span });
const raw = await misskeyApi('charts/instance', { host: props.args?.host, limit: props.limit, span: props.span });
return {
series: [{
name: 'Following',
Expand All @@ -645,7 +645,7 @@ const fetchInstanceFfChart = async (total: boolean): Promise<typeof chartData> =
};

const fetchInstanceDriveUsageChart = async (total: boolean): Promise<typeof chartData> => {
const raw = await misskeyApiGet('charts/instance', { host: props.args?.host, limit: props.limit, span: props.span });
const raw = await misskeyApi('charts/instance', { host: props.args?.host, limit: props.limit, span: props.span });
return {
bytes: true,
series: [{
Expand All @@ -661,7 +661,7 @@ const fetchInstanceDriveUsageChart = async (total: boolean): Promise<typeof char
};

const fetchInstanceDriveFilesChart = async (total: boolean): Promise<typeof chartData> => {
const raw = await misskeyApiGet('charts/instance', { host: props.args?.host, limit: props.limit, span: props.span });
const raw = await misskeyApi('charts/instance', { host: props.args?.host, limit: props.limit, span: props.span });
return {
series: [{
name: 'Drive files',
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/components/MkInstanceCardMini.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { ref } from 'vue';
import * as Misskey from 'misskey-js';
import MkMiniChart from '@/components/MkMiniChart.vue';
import { misskeyApiGet } from '@/scripts/misskey-api.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { getProxiedImageUrlNullable } from '@/scripts/media-proxy.js';

const props = defineProps<{
Expand All @@ -27,7 +27,7 @@ const props = defineProps<{

const chartValues = ref<number[] | null>(null);

misskeyApiGet('charts/instance', { host: props.instance.host, limit: 16 + 1, span: 'day' }).then(res => {
misskeyApi('charts/instance', { host: props.instance.host, limit: 16 + 1, span: 'day' }).then(res => {
// 今日のぶんの値はまだ途中の値であり、それも含めると大抵の場合前日よりも下降しているようなグラフになってしまうため今日は弾く
res['requests.received'].splice(0, 1);
chartValues.value = res['requests.received'];
Expand Down
8 changes: 5 additions & 3 deletions packages/frontend/src/components/MkInstanceStats.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</div>
</MkFoldableSection>

<MkFoldableSection class="item">
<MkFoldableSection v-if="$i" class="item">
<template #header>Federation</template>
<div :class="$style.federation">
<div class="pies">
Expand All @@ -90,13 +90,14 @@ import MkSelect from '@/components/MkSelect.vue';
import MkChart from '@/components/MkChart.vue';
import { useChartTooltip } from '@/scripts/use-chart-tooltip.js';
import * as os from '@/os.js';
import { misskeyApiGet } from '@/scripts/misskey-api.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
import MkHeatmap, { type HeatmapSource } from '@/components/MkHeatmap.vue';
import MkFoldableSection from '@/components/MkFoldableSection.vue';
import MkRetentionHeatmap from '@/components/MkRetentionHeatmap.vue';
import MkRetentionLineChart from '@/components/MkRetentionLineChart.vue';
import { initChart } from '@/scripts/init-chart.js';
import { $i } from '@/account.js';

initChart();

Expand Down Expand Up @@ -164,7 +165,8 @@ function createDoughnut(chartEl, tooltip, data) {
}

onMounted(() => {
misskeyApiGet('federation/stats', { limit: 30 }).then(fedStats => {
if (!$i) { return; }
misskeyApi('federation/stats', { limit: 30 }).then(fedStats => {
type ChartData = {
name: string,
color: string | null,
Expand Down
7 changes: 4 additions & 3 deletions packages/frontend/src/pages/about.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkSpacer v-else-if="tab === 'emojis'" :contentMax="1000" :marginMin="20">
<XEmojis/>
</MkSpacer>
<MkSpacer v-else-if="tab === 'federation'" :contentMax="1000" :marginMin="20">
<MkSpacer v-else-if="tab === 'federation' && $i" :contentMax="1000" :marginMin="20">
<XFederation/>
</MkSpacer>
<MkSpacer v-else-if="tab === 'charts'" :contentMax="1000" :marginMin="20">
Expand Down Expand Up @@ -150,6 +150,7 @@ import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
import { claimAchievement } from '@/scripts/achievements.js';
import { instance } from '@/instance.js';
import { $i } from '@/account.js';

const props = withDefaults(defineProps<{
initialTab?: string;
Expand Down Expand Up @@ -180,11 +181,11 @@ const headerTabs = computed(() => [{
key: 'emojis',
title: i18n.ts.customEmojis,
icon: 'ti ti-icons',
}, {
}, ...$i ? [{
key: 'federation',
title: i18n.ts.federation,
icon: 'ti ti-whirl',
}, {
}] : [], {
key: 'charts',
title: i18n.ts.charts,
icon: 'ti ti-chart-line',
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/pages/admin/overview.federation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { onMounted, ref } from 'vue';
import XPie, { type InstanceForPie } from './overview.pie.vue';
import * as os from '@/os.js';
import { misskeyApiGet } from '@/scripts/misskey-api.js';
import { misskeyApi, misskeyApiGet } from '@/scripts/misskey-api.js';
import number from '@/filters/number.js';
import MkNumberDiff from '@/components/MkNumberDiff.vue';
import { i18n } from '@/i18n.js';
Expand All @@ -72,7 +72,7 @@ onMounted(async () => {
federationSubActive.value = chart.subActive[0];
federationSubActiveDiff.value = chart.subActive[0] - chart.subActive[1];

misskeyApiGet('federation/stats', { limit: 10 }).then(res => {
misskeyApi('federation/stats', { limit: 10 }).then(res => {
topSubInstancesForPie.value = [
...res.topSubInstances.map(x => ({
name: x.host,
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/pages/admin/overview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ onMounted(async () => {
federationSubActiveDiff.value = chart.subActive[0] - chart.subActive[1];
});

misskeyApiGet('federation/stats', { limit: 10 }).then(res => {
misskeyApi('federation/stats', { limit: 10 }).then(res => {
topSubInstancesForPie.value = [
...res.topSubInstances.map(x => ({
name: x.host,
Expand Down
7 changes: 0 additions & 7 deletions packages/frontend/src/pages/welcome.entrance.a.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,6 @@ function getInstanceIcon(instance: Misskey.entities.FederationInstance): string
misskeyApi('meta', { detail: true }).then(_meta => {
meta.value = _meta;
});

misskeyApiGet('federation/instances', {
sort: '+pubSub',
limit: 20,
}).then(_instances => {
instances.value = _instances;
});
</script>

<style lang="scss" scoped>
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/widgets/WidgetFederation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { useWidgetPropsManager, WidgetComponentEmits, WidgetComponentExpose, Wid
import { GetFormResultType } from '@/scripts/form.js';
import MkContainer from '@/components/MkContainer.vue';
import MkMiniChart from '@/components/MkMiniChart.vue';
import { misskeyApi, misskeyApiGet } from '@/scripts/misskey-api.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { useInterval } from '@/scripts/use-interval.js';
import { i18n } from '@/i18n.js';
import { getProxiedImageUrlNullable } from '@/scripts/media-proxy.js';
Expand Down Expand Up @@ -66,7 +66,7 @@ const fetch = async () => {
sort: '+latestRequestReceivedAt',
limit: 5,
});
const fetchedCharts = await Promise.all(fetchedInstances.map(i => misskeyApiGet('charts/instance', { host: i.host, limit: 16, span: 'hour' })));
const fetchedCharts = await Promise.all(fetchedInstances.map(i => misskeyApi('charts/instance', { host: i.host, limit: 16, span: 'hour' })));
instances.value = fetchedInstances;
charts.value = fetchedCharts;
fetching.value = false;
Expand Down
Loading