Merge remote-tracking branch 'misskey-original/develop' into develop

# Conflicts:
#	packages/frontend/src/components/MkChannelFollowButton.vue
#	packages/frontend/src/components/MkDrive.folder.vue
#	packages/frontend/src/components/MkDrive.navFolder.vue
#	packages/frontend/src/components/MkEmojiEditDialog.vue
#	packages/frontend/src/components/MkFollowButton.vue
#	packages/frontend/src/components/MkNote.vue
#	packages/frontend/src/components/MkPostForm.vue
#	packages/frontend/src/components/MkSignupDialog.form.vue
#	packages/frontend/src/pages/about.vue
#	packages/frontend/src/pages/admin/index.vue
#	packages/frontend/src/pages/admin/instance-block.vue
#	packages/frontend/src/pages/avatar-decorations.vue
#	packages/frontend/src/pages/custom-emojis-manager.vue
#	packages/frontend/src/pages/settings/mute-block.vue
#	packages/frontend/src/pages/settings/profile.vue
#	packages/frontend/src/pages/timeline.vue
#	packages/frontend/src/pages/user/home.vue
This commit is contained in:
mattyatea 2024-01-06 14:24:39 +09:00
commit de3f4ce29c
216 changed files with 758 additions and 568 deletions

View File

@ -19,6 +19,10 @@
- Fix: v2023.12.0で追加された「モデレーターがユーザーのアイコンもしくはバナー画像を未設定状態にできる機能」が管理画面上で正しく表示されていない問題を修正
- Enhance: チャンネルノートのピン留めをノートのメニューからできるよ
### Server
- Enhance: 連合先のレートリミットに引っかかった際にリトライするようになりました
- Enhance: ActivityPub Deliver queueでBodyを事前処理するように (#12916)
## 2023.12.2
### General

View File

@ -16,6 +16,7 @@ import type { DbQueue, DeliverQueue, EndedPollNotificationQueue, InboxQueue, Obj
import type { DbJobData, DeliverJobData, RelationshipJobData, ThinUser } from '../queue/types.js';
import type httpSignature from '@peertube/http-signature';
import type * as Bull from 'bullmq';
import { ApRequestCreator } from '@/core/activitypub/ApRequestService.js';
@Injectable()
export class QueueService {
@ -75,11 +76,15 @@ export class QueueService {
if (content == null) return null;
if (to == null) return null;
const contentBody = JSON.stringify(content);
const digest = ApRequestCreator.createDigest(contentBody);
const data: DeliverJobData = {
user: {
id: user.id,
},
content,
content: contentBody,
digest,
to,
isSharedInbox,
};
@ -104,6 +109,8 @@ export class QueueService {
@bindThis
public async deliverMany(user: ThinUser, content: IActivity | null, inboxes: Map<string, boolean>) {
if (content == null) return null;
const contentBody = JSON.stringify(content);
const digest = ApRequestCreator.createDigest(contentBody);
const opts = {
attempts: this.config.deliverJobMaxAttempts ?? 12,
@ -118,7 +125,8 @@ export class QueueService {
name: d[0],
data: {
user,
content,
content: contentBody,
digest,
to: d[0],
isSharedInbox: d[1],
} as DeliverJobData,

View File

@ -97,6 +97,8 @@ export class ApInboxService {
} catch (err) {
if (err instanceof Error || typeof err === 'string') {
this.logger.error(err);
} else {
throw err;
}
}
}
@ -256,7 +258,7 @@ export class ApInboxService {
const targetUri = getApId(activity.object);
this.announceNote(actor, activity, targetUri);
await this.announceNote(actor, activity, targetUri);
}
@bindThis
@ -288,7 +290,7 @@ export class ApInboxService {
} catch (err) {
// 対象が4xxならスキップ
if (err instanceof StatusError) {
if (err.isClientError) {
if (!err.isRetryable) {
this.logger.warn(`Ignored announce target ${targetUri} - ${err.statusCode}`);
return;
}
@ -373,7 +375,7 @@ export class ApInboxService {
});
if (isPost(object)) {
this.createNote(resolver, actor, object, false, activity);
await this.createNote(resolver, actor, object, false, activity);
} else {
this.logger.warn(`Unknown type: ${getApType(object)}`);
}
@ -404,7 +406,7 @@ export class ApInboxService {
await this.apNoteService.createNote(note, resolver, silent);
return 'ok';
} catch (err) {
if (err instanceof StatusError && err.isClientError) {
if (err instanceof StatusError && !err.isRetryable) {
return `skip ${err.statusCode}`;
} else {
throw err;

View File

@ -34,9 +34,9 @@ type PrivateKey = {
};
export class ApRequestCreator {
static createSignedPost(args: { key: PrivateKey, url: string, body: string, additionalHeaders: Record<string, string> }): Signed {
static createSignedPost(args: { key: PrivateKey, url: string, body: string, digest?: string, additionalHeaders: Record<string, string> }): Signed {
const u = new URL(args.url);
const digestHeader = `SHA-256=${crypto.createHash('sha256').update(args.body).digest('base64')}`;
const digestHeader = args.digest ?? this.createDigest(args.body);
const request: Request = {
url: u.href,
@ -59,6 +59,10 @@ export class ApRequestCreator {
};
}
static createDigest(body: string) {
return `SHA-256=${crypto.createHash('sha256').update(body).digest('base64')}`;
}
static createSignedGet(args: { key: PrivateKey, url: string, additionalHeaders: Record<string, string> }): Signed {
const u = new URL(args.url);
@ -145,8 +149,8 @@ export class ApRequestService {
}
@bindThis
public async signedPost(user: { id: MiUser['id'] }, url: string, object: unknown): Promise<void> {
const body = JSON.stringify(object);
public async signedPost(user: { id: MiUser['id'] }, url: string, object: unknown, digest?: string): Promise<void> {
const body = typeof object === 'string' ? object : JSON.stringify(object);
const keypair = await this.userKeypairService.getUserKeypair(user.id);
@ -157,6 +161,7 @@ export class ApRequestService {
},
url,
body,
digest,
additionalHeaders: {
},
});

View File

@ -216,7 +216,7 @@ export class ApNoteService {
return { status: 'ok', res };
} catch (e) {
return {
status: (e instanceof StatusError && e.isClientError) ? 'permerror' : 'temperror',
status: (e instanceof StatusError && !e.isRetryable) ? 'permerror' : 'temperror',
};
}
};

View File

@ -7,6 +7,7 @@ export class StatusError extends Error {
public statusCode: number;
public statusMessage?: string;
public isClientError: boolean;
public isRetryable: boolean;
constructor(message: string, statusCode: number, statusMessage?: string) {
super(message);
@ -14,5 +15,6 @@ export class StatusError extends Error {
this.statusCode = statusCode;
this.statusMessage = statusMessage;
this.isClientError = typeof this.statusCode === 'number' && this.statusCode >= 400 && this.statusCode < 500;
this.isRetryable = !this.isClientError || this.statusCode === 429;
}
}

View File

@ -72,7 +72,7 @@ export class DeliverProcessorService {
}
try {
await this.apRequestService.signedPost(job.data.user, job.data.to, job.data.content);
await this.apRequestService.signedPost(job.data.user, job.data.to, job.data.content, job.data.digest);
// Update stats
this.federatedInstanceService.fetch(host).then(i => {
@ -111,7 +111,7 @@ export class DeliverProcessorService {
if (res instanceof StatusError) {
// 4xx
if (res.isClientError) {
if (!res.isRetryable) {
// 相手が閉鎖していることを明示しているため、配送停止する
if (job.data.isSharedInbox && res.statusCode === 410) {
this.federatedInstanceService.fetch(host).then(i => {

View File

@ -85,7 +85,7 @@ export class InboxProcessorService {
} catch (err) {
// 対象が4xxならスキップ
if (err instanceof StatusError) {
if (err.isClientError) {
if (!err.isRetryable) {
throw new Bull.UnrecoverableError(`skip: Ignored deleted actors on both ends ${activity.actor} - ${err.statusCode}`);
}
throw new Error(`Error in actor ${activity.actor} - ${err.statusCode}`);

View File

@ -71,7 +71,7 @@ export class WebhookDeliverProcessorService {
if (res instanceof StatusError) {
// 4xx
if (res.isClientError) {
if (!res.isRetryable) {
throw new Bull.UnrecoverableError(`${res.statusCode} ${res.statusMessage}`);
}

View File

@ -19,7 +19,9 @@ export type DeliverJobData = {
/** Actor */
user: ThinUser;
/** Activity */
content: unknown;
content: string;
/** Digest header */
digest: string;
/** inbox URL to deliver */
to: string;
/** whether it is sharedInbox */

View File

@ -11,7 +11,8 @@ import { miLocalStorage } from '@/local-storage.js';
import { MenuButton } from '@/types/menu.js';
import { del, get, set } from '@/scripts/idb-proxy.js';
import { apiUrl } from '@/config.js';
import { waiting, api, popup, popupMenu, success, alert } from '@/os.js';
import { waiting, popup, popupMenu, success, alert } from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { unisonReload, reloadChannel } from '@/scripts/unison-reload.js';
// TODO: 他のタブと永続化されたstateを同期
@ -23,9 +24,14 @@ const accountData = miLocalStorage.getItem('account');
// TODO: 外部からはreadonlyに
export const $i = accountData ? reactive(JSON.parse(accountData) as Account) : null;
export const iAmModerator = $i != null && ($i.isAdmin || $i.isModerator);
export const iAmModerator = $i != null && ($i.isAdmin === true || $i.isModerator === true);
export const iAmAdmin = $i != null && $i.isAdmin;
export function signinRequired() {
if ($i == null) throw new Error('signin required');
return $i;
}
export let notesCount = $i == null ? 0 : $i.notesCount;
export function incNotesCount() {
notesCount++;
@ -246,7 +252,7 @@ export async function openAccountMenu(opts: {
}
const storedAccounts = await getAccounts().then(accounts => accounts.filter(x => x.id !== $i.id));
const accountsPromise = api('users/show', { userIds: storedAccounts.map(x => x.id) });
const accountsPromise = misskeyApi('users/show', { userIds: storedAccounts.map(x => x.id) });
function createItem(account: Misskey.entities.UserDetailed) {
return {

View File

@ -5,9 +5,9 @@
import * as Misskey from 'misskey-js';
import { Cache } from '@/scripts/cache.js';
import { api } from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
export const clipsCache = new Cache<Misskey.entities.Clip[]>(1000 * 60 * 30, () => api('clips/list'));
export const rolesCache = new Cache(1000 * 60 * 30, () => api('admin/roles/list'));
export const userListsCache = new Cache<Misskey.entities.UserList[]>(1000 * 60 * 30, () => api('users/lists/list'));
export const antennasCache = new Cache<Misskey.entities.Antenna[]>(1000 * 60 * 30, () => api('antennas/list'));
export const clipsCache = new Cache<Misskey.entities.Clip[]>(1000 * 60 * 30, () => misskeyApi('clips/list'));
export const rolesCache = new Cache(1000 * 60 * 30, () => misskeyApi('admin/roles/list'));
export const userListsCache = new Cache<Misskey.entities.UserList[]>(1000 * 60 * 30, () => misskeyApi('users/lists/list'));
export const antennasCache = new Cache<Misskey.entities.Antenna[]>(1000 * 60 * 30, () => misskeyApi('antennas/list'));

View File

@ -17,7 +17,7 @@ import * as Misskey from 'misskey-js';
import MkMention from './MkMention.vue';
import { i18n } from '@/i18n.js';
import { host as localHost } from '@/config.js';
import { api } from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
const user = ref<Misskey.entities.UserLite>();
@ -25,7 +25,7 @@ const props = defineProps<{
movedTo: string; // user id
}>();
api('users/show', { userId: props.movedTo }).then(u => user.value = u);
misskeyApi('users/show', { userId: props.movedTo }).then(u => user.value = u);
</script>
<style lang="scss" module>

View File

@ -55,6 +55,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import * as Misskey from 'misskey-js';
import { onMounted, ref, computed } from 'vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
import { ACHIEVEMENT_TYPES, ACHIEVEMENT_BADGES, claimAchievement } from '@/scripts/achievements.js';
@ -71,7 +72,7 @@ const achievements = ref<Misskey.entities.UsersAchievementsResponse | null>(null
const lockedAchievements = computed(() => ACHIEVEMENT_TYPES.filter(x => !(achievements.value ?? []).some(a => a.name === x)));
function fetch() {
os.api('users/achievements', { userId: props.user.id }).then(res => {
misskeyApi('users/achievements', { userId: props.user.id }).then(res => {
achievements.value = [];
for (const t of ACHIEVEMENT_TYPES) {
const a = res.find(x => x.name === t);

View File

@ -25,6 +25,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { onMounted, shallowRef } from 'vue';
import * as Misskey from 'misskey-js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import MkModal from '@/components/MkModal.vue';
import MkButton from '@/components/MkButton.vue';
import { i18n } from '@/i18n.js';
@ -49,7 +50,7 @@ async function ok() {
}
modal.value.close();
os.api('i/read-announcement', { announcementId: props.announcement.id });
misskeyApi('i/read-announcement', { announcementId: props.announcement.id });
updateAccount({
unreadAnnouncements: $i!.unreadAnnouncements.filter(a => a.id !== props.announcement.id),
});

View File

@ -45,6 +45,7 @@ import contains from '@/scripts/contains.js';
import { char2twemojiFilePath, char2fluentEmojiFilePath } from '@/scripts/emoji-base.js';
import { acct } from '@/filters/user.js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { defaultStore } from '@/store.js';
import { emojilist, getEmojiName } from '@/scripts/emojilist.js';
import { i18n } from '@/i18n.js';
@ -205,7 +206,7 @@ function exec() {
users.value = JSON.parse(cache);
fetching.value = false;
} else {
os.api('users/search-by-username-and-host', {
misskeyApi('users/search-by-username-and-host', {
username: props.q,
limit: 10,
detail: false,
@ -228,7 +229,7 @@ function exec() {
hashtags.value = hashtags;
fetching.value = false;
} else {
os.api('hashtags/search', {
misskeyApi('hashtags/search', {
query: props.q,
limit: 30,
}).then(searchedHashtags => {

View File

@ -15,7 +15,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import { onMounted, ref } from 'vue';
import * as Misskey from 'misskey-js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
const props = withDefaults(defineProps<{
userIds: string[];
@ -27,7 +27,7 @@ const props = withDefaults(defineProps<{
const users = ref<Misskey.entities.UserLite[]>([]);
onMounted(async () => {
users.value = await os.api('users/show', {
users.value = await misskeyApi('users/show', {
userIds: props.userIds,
}) as unknown as Misskey.entities.UserLite[];
});

View File

@ -36,7 +36,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import {computed, ref, watch} from 'vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import {i18n} from '@/i18n.js';
import {defaultStore} from "@/store.js";
@ -57,12 +57,12 @@ async function onClick() {
try {
if (isFollowing.value) {
await os.api('channels/unfollow', {
await misskeyApi('channels/unfollow', {
channelId: props.channel.id,
});
isFollowing.value = false;
} else {
await os.api('channels/follow', {
await misskeyApi('channels/follow', {
channelId: props.channel.id,
});
isFollowing.value = true;

View File

@ -22,7 +22,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { onMounted, ref, shallowRef, watch, PropType } from 'vue';
import { Chart } from 'chart.js';
import gradient from 'chartjs-plugin-gradient';
import * as os from '@/os.js';
import { 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';
@ -277,7 +277,7 @@ const exportData = () => {
};
const fetchFederationChart = async (): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/federation', { limit: props.limit, span: props.span });
const raw = await misskeyApiGet('charts/federation', { limit: props.limit, span: props.span });
return {
series: [{
name: 'Received',
@ -327,7 +327,7 @@ const fetchFederationChart = async (): Promise<typeof chartData> => {
};
const fetchApRequestChart = async (): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/ap-request', { limit: props.limit, span: props.span });
const raw = await misskeyApiGet('charts/ap-request', { limit: props.limit, span: props.span });
return {
series: [{
name: 'In',
@ -349,7 +349,7 @@ const fetchApRequestChart = async (): Promise<typeof chartData> => {
};
const fetchNotesChart = async (type: string): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/notes', { limit: props.limit, span: props.span });
const raw = await misskeyApiGet('charts/notes', { limit: props.limit, span: props.span });
return {
series: [{
name: 'All',
@ -396,7 +396,7 @@ const fetchNotesChart = async (type: string): Promise<typeof chartData> => {
};
const fetchNotesTotalChart = async (): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/notes', { limit: props.limit, span: props.span });
const raw = await misskeyApiGet('charts/notes', { limit: props.limit, span: props.span });
return {
series: [{
name: 'Combined',
@ -415,7 +415,7 @@ const fetchNotesTotalChart = async (): Promise<typeof chartData> => {
};
const fetchUsersChart = async (total: boolean): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/users', { limit: props.limit, span: props.span });
const raw = await misskeyApiGet('charts/users', { limit: props.limit, span: props.span });
return {
series: [{
name: 'Combined',
@ -443,7 +443,7 @@ const fetchUsersChart = async (total: boolean): Promise<typeof chartData> => {
};
const fetchActiveUsersChart = async (): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/active-users', { limit: props.limit, span: props.span });
const raw = await misskeyApiGet('charts/active-users', { limit: props.limit, span: props.span });
return {
series: [{
name: 'Read & Write',
@ -495,7 +495,7 @@ const fetchActiveUsersChart = async (): Promise<typeof chartData> => {
};
const fetchDriveChart = async (): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/drive', { limit: props.limit, span: props.span });
const raw = await misskeyApiGet('charts/drive', { limit: props.limit, span: props.span });
return {
bytes: true,
series: [{
@ -531,7 +531,7 @@ const fetchDriveChart = async (): Promise<typeof chartData> => {
};
const fetchDriveFilesChart = async (): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/drive', { limit: props.limit, span: props.span });
const raw = await misskeyApiGet('charts/drive', { limit: props.limit, span: props.span });
return {
series: [{
name: 'All',
@ -566,7 +566,7 @@ const fetchDriveFilesChart = async (): Promise<typeof chartData> => {
};
const fetchInstanceRequestsChart = async (): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/instance', { host: props.args.host, limit: props.limit, span: props.span });
const raw = await misskeyApiGet('charts/instance', { host: props.args.host, limit: props.limit, span: props.span });
return {
series: [{
name: 'In',
@ -588,7 +588,7 @@ const fetchInstanceRequestsChart = async (): Promise<typeof chartData> => {
};
const fetchInstanceUsersChart = async (total: boolean): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/instance', { host: props.args.host, limit: props.limit, span: props.span });
const raw = await misskeyApiGet('charts/instance', { host: props.args.host, limit: props.limit, span: props.span });
return {
series: [{
name: 'Users',
@ -603,7 +603,7 @@ const fetchInstanceUsersChart = async (total: boolean): Promise<typeof chartData
};
const fetchInstanceNotesChart = async (total: boolean): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/instance', { host: props.args.host, limit: props.limit, span: props.span });
const raw = await misskeyApiGet('charts/instance', { host: props.args.host, limit: props.limit, span: props.span });
return {
series: [{
name: 'Notes',
@ -618,7 +618,7 @@ const fetchInstanceNotesChart = async (total: boolean): Promise<typeof chartData
};
const fetchInstanceFfChart = async (total: boolean): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/instance', { host: props.args.host, limit: props.limit, span: props.span });
const raw = await misskeyApiGet('charts/instance', { host: props.args.host, limit: props.limit, span: props.span });
return {
series: [{
name: 'Following',
@ -641,7 +641,7 @@ const fetchInstanceFfChart = async (total: boolean): Promise<typeof chartData> =
};
const fetchInstanceDriveUsageChart = async (total: boolean): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/instance', { host: props.args.host, limit: props.limit, span: props.span });
const raw = await misskeyApiGet('charts/instance', { host: props.args.host, limit: props.limit, span: props.span });
return {
bytes: true,
series: [{
@ -657,7 +657,7 @@ const fetchInstanceDriveUsageChart = async (total: boolean): Promise<typeof char
};
const fetchInstanceDriveFilesChart = async (total: boolean): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/instance', { host: props.args.host, limit: props.limit, span: props.span });
const raw = await misskeyApiGet('charts/instance', { host: props.args.host, limit: props.limit, span: props.span });
return {
series: [{
name: 'Drive files',
@ -672,7 +672,7 @@ const fetchInstanceDriveFilesChart = async (total: boolean): Promise<typeof char
};
const fetchPerUserNotesChart = async (): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/user/notes', { userId: props.args.user.id, limit: props.limit, span: props.span });
const raw = await misskeyApiGet('charts/user/notes', { userId: props.args.user.id, limit: props.limit, span: props.span });
return {
series: [...(props.args.withoutAll ? [] : [{
name: 'All',
@ -704,7 +704,7 @@ const fetchPerUserNotesChart = async (): Promise<typeof chartData> => {
};
const fetchPerUserPvChart = async (): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/user/pv', { userId: props.args.user.id, limit: props.limit, span: props.span });
const raw = await misskeyApiGet('charts/user/pv', { userId: props.args.user.id, limit: props.limit, span: props.span });
return {
series: [{
name: 'Unique PV (user)',
@ -731,7 +731,7 @@ const fetchPerUserPvChart = async (): Promise<typeof chartData> => {
};
const fetchPerUserFollowingChart = async (): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/user/following', { userId: props.args.user.id, limit: props.limit, span: props.span });
const raw = await misskeyApiGet('charts/user/following', { userId: props.args.user.id, limit: props.limit, span: props.span });
return {
series: [{
name: 'Local',
@ -746,7 +746,7 @@ const fetchPerUserFollowingChart = async (): Promise<typeof chartData> => {
};
const fetchPerUserFollowersChart = async (): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/user/following', { userId: props.args.user.id, limit: props.limit, span: props.span });
const raw = await misskeyApiGet('charts/user/following', { userId: props.args.user.id, limit: props.limit, span: props.span });
return {
series: [{
name: 'Local',
@ -761,7 +761,7 @@ const fetchPerUserFollowersChart = async (): Promise<typeof chartData> => {
};
const fetchPerUserDriveChart = async (): Promise<typeof chartData> => {
const raw = await os.apiGet('charts/user/drive', { userId: props.args.user.id, limit: props.limit, span: props.span });
const raw = await misskeyApiGet('charts/user/drive', { userId: props.args.user.id, limit: props.limit, span: props.span });
return {
series: [{
name: 'Inc',

View File

@ -35,6 +35,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { computed, defineAsyncComponent, ref } from 'vue';
import * as Misskey from 'misskey-js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
import { defaultStore } from '@/store.js';
import { claimAchievement } from '@/scripts/achievements.js';
@ -147,13 +148,13 @@ function onDrop(ev: DragEvent) {
emit('removeFile', file.id);
if (props.selectedFiles.length > 0) {
props.selectedFiles.forEach((e)=>{
os.api('drive/files/update', {
misskeyApi('drive/files/update', {
fileId: e.id,
folderId: props.folder.id,
});
})
}else{
os.api('drive/files/update', {
misskeyApi('drive/files/update', {
fileId: file.id,
folderId: props.folder.id,
});
@ -170,7 +171,7 @@ function onDrop(ev: DragEvent) {
if (folder.id === props.folder.id) return;
emit('removeFolder', folder.id);
os.api('drive/folders/update', {
misskeyApi('drive/folders/update', {
folderId: folder.id,
parentId: props.folder.id,
}).then(() => {
@ -224,7 +225,7 @@ function rename() {
default: props.folder.name,
}).then(({ canceled, result: name }) => {
if (canceled) return;
os.api('drive/folders/update', {
misskeyApi('drive/folders/update', {
folderId: props.folder.id,
name: name,
});
@ -232,7 +233,7 @@ function rename() {
}
function deleteFolder() {
os.api('drive/folders/show', {
misskeyApi('drive/folders/show', {
folderId: props.folder.id,
}).then(async (r) => {
@ -266,7 +267,7 @@ function deleteFolder() {
})
os.api('drive/folders/show', {
misskeyApi('drive/folders/show', {
folderId: props.folder.id,
}).then(async (r) =>{
if (r.filesCount > 0) {
@ -283,7 +284,7 @@ function deleteFolder() {
os.api('drive/files/delete',{fileId: r.id})
})
os.api('drive/folders/delete', {
misskeyApi('drive/folders/delete', {
folderId: props.folder.id,
}).then(() => {
if (defaultStore.state.uploadFolder === props.folder.id) {
@ -306,11 +307,11 @@ function deleteFolder() {
}
});
os.api('drive/folders/delete', {
misskeyApi('drive/folders/delete', {
folderId: props.folder.id,
})
}else{
os.api('drive/folders/delete', {
misskeyApi('drive/folders/delete', {
folderId: props.folder.id,
})
}
@ -318,7 +319,7 @@ function deleteFolder() {
} else {
await os.api('drive/folders/delete', {
await misskeyApi('drive/folders/delete', {
folderId: props.folder.id,
}).then(() => {
if (defaultStore.state.uploadFolder === props.folder.id) {

View File

@ -20,7 +20,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import { ref } from 'vue';
import * as Misskey from 'misskey-js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
const props = defineProps<{
@ -115,13 +115,13 @@ function onDrop(ev: DragEvent) {
emit('removeFile', file.id);
if (props.selectedFiles.length > 0) {
props.selectedFiles.forEach((e) => {
os.api('drive/files/update', {
misskeyApi('drive/files/update', {
fileId: e.id,
folderId: props.folder ? props.folder.id : null,
});
});
} else {
os.api('drive/files/update', {
misskeyApi('drive/files/update', {
fileId: file.id,
folderId: props.folder ? props.folder.id : null,
});
@ -136,7 +136,7 @@ function onDrop(ev: DragEvent) {
// reject
if (props.folder && folder.id === props.folder.id) return;
emit('removeFolder', folder.id);
os.api('drive/folders/update', {
misskeyApi('drive/folders/update', {
folderId: folder.id,
parentId: props.folder ? props.folder.id : null,
});

View File

@ -127,6 +127,7 @@ import XNavFolder from '@/components/MkDrive.navFolder.vue';
import XFolder from '@/components/MkDrive.folder.vue';
import XFile from '@/components/MkDrive.file.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { useStream } from '@/stream.js';
import { defaultStore } from '@/store.js';
import { i18n } from '@/i18n.js';
@ -282,7 +283,7 @@ function onDrop(ev: DragEvent): any {
const file = JSON.parse(driveFile);
if (files.value.some(f => f.id === file.id)) return;
removeFile(file.id);
os.api('drive/files/update', {
misskeyApi('drive/files/update', {
fileId: file.id,
folderId: folder.value ? folder.value.id : null,
});
@ -298,7 +299,7 @@ function onDrop(ev: DragEvent): any {
if (folder.value && droppedFolder.id === folder.value.id) return false;
if (folders.value.some(f => f.id === droppedFolder.id)) return false;
removeFolder(droppedFolder.id);
os.api('drive/folders/update', {
misskeyApi('drive/folders/update', {
folderId: droppedFolder.id,
parentId: folder.value ? folder.value.id : null,
}).then(() => {
@ -335,7 +336,7 @@ function urlUpload() {
placeholder: i18n.ts.uploadFromUrlDescription,
}).then(({ canceled, result: url }) => {
if (canceled || !url) return;
os.api('drive/files/upload-from-url', {
misskeyApi('drive/files/upload-from-url', {
url: url,
folderId: folder.value ? folder.value.id : undefined,
});
@ -353,7 +354,7 @@ function createFolder() {
placeholder: i18n.ts.folderName,
}).then(({ canceled, result: name }) => {
if (canceled) return;
os.api('drive/folders/create', {
misskeyApi('drive/folders/create', {
name: name,
parentId: folder.value ? folder.value.id : undefined,
}).then(createdFolder => {
@ -369,7 +370,7 @@ function renameFolder(folderToRename: Misskey.entities.DriveFolder) {
default: folderToRename.name,
}).then(({ canceled, result: name }) => {
if (canceled) return;
os.api('drive/folders/update', {
misskeyApi('drive/folders/update', {
folderId: folderToRename.id,
name: name,
}).then(updatedFolder => {
@ -380,7 +381,7 @@ function renameFolder(folderToRename: Misskey.entities.DriveFolder) {
}
function deleteFolder(folderToDelete: Misskey.entities.DriveFolder) {
os.api('drive/folders/delete', {
misskeyApi('drive/folders/delete', {
folderId: folderToDelete.id,
}).then(() => {
//
@ -464,7 +465,7 @@ function move(target?: Misskey.entities.DriveFolder) {
fetching.value = true;
os.api('drive/folders/show', {
misskeyApi('drive/folders/show', {
folderId: target,
}).then(folderToMove => {
folder.value = folderToMove;
@ -564,7 +565,7 @@ async function fetch() {
const foldersMax = 30;
const filesMax = 30;
const foldersPromise = os.api('drive/folders', {
const foldersPromise = misskeyApi('drive/folders', {
folderId: folder.value ? folder.value.id : null,
limit: foldersMax + 1,
}).then(fetchedFolders => {
@ -575,7 +576,7 @@ async function fetch() {
return fetchedFolders;
});
const filesPromise = os.api('drive/files', {
const filesPromise = misskeyApi('drive/files', {
folderId: folder.value ? folder.value.id : null,
type: props.type,
limit: filesMax + 1,
@ -600,7 +601,7 @@ function fetchMoreFolders() {
const max = 30;
os.api('drive/folders', {
misskeyApi('drive/folders', {
folderId: folder.value ? folder.value.id : null,
type: props.type,
untilId: folders.value.at(-1)?.id,
@ -623,7 +624,7 @@ function fetchMoreFiles() {
const max = 30;
//
os.api('drive/files', {
misskeyApi('drive/files', {
folderId: folder.value ? folder.value.id : null,
type: props.type,
untilId: files.value.at(-1)?.id,

View File

@ -96,6 +96,7 @@ import MkInput from '@/components/MkInput.vue';
import MkInfo from '@/components/MkInfo.vue';
import MkFolder from '@/components/MkFolder.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
import { customEmojiCategories } from '@/custom-emojis.js';
import MkSwitch from '@/components/MkSwitch.vue';
@ -119,7 +120,7 @@ let rolesThatCanBeUsedThisEmojiAsReaction = ref<Misskey.entities.Role[]>([]);
let file = ref<Misskey.entities.DriveFile>();
let isRequest = ref(props.isRequest ?? false);
watch((roleIdsThatCanBeUsedThisEmojiAsReaction), async () => {
rolesThatCanBeUsedThisEmojiAsReaction.value = (await Promise.all(roleIdsThatCanBeUsedThisEmojiAsReaction.value.map((id) => os.api('admin/roles/show', { roleId: id }).catch(() => null)))).filter(x => x != null);
rolesThatCanBeUsedThisEmojiAsReaction.value = (await Promise.all(roleIdsThatCanBeUsedThisEmojiAsReaction.value.map((id) => misskeyApi('admin/roles/show', { roleId: id }).catch(() => null)))).filter(x => x != null);
}, { immediate: true });
const isNotifyIsHome = ref(props.emoji ? props.emoji.isNotifyIsHome : false);
const imgUrl = computed(() => file.value ? file.value.url : props.emoji && !isRequest.value ? `/emoji/${props.emoji.name}.webp` : props.emoji && props.emoji.url ? props.emoji.url : null);
@ -140,7 +141,7 @@ async function changeImage(ev) {
}
async function addRole() {
const roles = await os.api('admin/roles/list');
const roles = await misskeyApi('admin/roles/list');
const currentRoleIds = rolesThatCanBeUsedThisEmojiAsReaction.value.map(x => x.id);
const { canceled, result: role } = await os.select({
@ -211,7 +212,7 @@ async function del() {
});
if (canceled) return;
os.api('admin/emoji/delete', {
misskeyApi('admin/emoji/delete', {
id: props.emoji.id,
}).then(() => {
emit('done', {

View File

@ -10,11 +10,11 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import { ref } from 'vue';
import * as Misskey from 'misskey-js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
const meta = ref<Misskey.entities.MetaResponse>();
os.api('meta', { detail: true }).then(gotMeta => {
misskeyApi('meta', { detail: true }).then(gotMeta => {
meta.value = gotMeta;
});
</script>

View File

@ -58,11 +58,12 @@ SPDX-License-Identifier: AGPL-3.0-only
import {computed, onBeforeUnmount, onMounted, ref, watch} from 'vue';
import * as Misskey from 'misskey-js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import {useStream} from '@/stream.js';
import {i18n} from '@/i18n.js';
import {claimAchievement} from '@/scripts/achievements.js';
import {$i} from '@/account.js';
import {defaultStore} from "@/store.js";
import {defaultStore} from '@/store.js';
const gamingType = computed(defaultStore.makeGetterSetter('gamingType'));
@ -85,7 +86,7 @@ const wait = ref(false);
const connection = useStream().useChannel('main');
if (props.user.isFollowing == null) {
os.api('users/show', {
misskeyApi('users/show', {
userId: props.user.id,
})
.then(onFollowChange);
@ -110,17 +111,17 @@ async function onClick() {
if (canceled) return;
await os.api('following/delete', {
await misskeyApi('following/delete', {
userId: props.user.id,
});
} else {
if (hasPendingFollowRequestFromYou.value) {
await os.api('following/requests/cancel', {
await misskeyApi('following/requests/cancel', {
userId: props.user.id,
});
hasPendingFollowRequestFromYou.value = false;
} else {
await os.api('following/create', {
await misskeyApi('following/create', {
userId: props.user.id,
withReplies: defaultStore.state.defaultWithReplies,
});

View File

@ -15,7 +15,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import { onMounted, nextTick, watch, shallowRef, ref } from 'vue';
import { Chart } from 'chart.js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { defaultStore } from '@/store.js';
import { useChartTooltip } from '@/scripts/use-chart-tooltip.js';
import { alpha } from '@/scripts/color.js';
@ -72,19 +72,19 @@ async function renderChart() {
let values;
if (props.src === 'active-users') {
const raw = await os.api('charts/active-users', { limit: chartLimit, span: 'day' });
const raw = await misskeyApi('charts/active-users', { limit: chartLimit, span: 'day' });
values = raw.readWrite;
} else if (props.src === 'notes') {
const raw = await os.api('charts/notes', { limit: chartLimit, span: 'day' });
const raw = await misskeyApi('charts/notes', { limit: chartLimit, span: 'day' });
values = raw.local.inc;
} else if (props.src === 'ap-requests-inbox-received') {
const raw = await os.api('charts/ap-request', { limit: chartLimit, span: 'day' });
const raw = await misskeyApi('charts/ap-request', { limit: chartLimit, span: 'day' });
values = raw.inboxReceived;
} else if (props.src === 'ap-requests-deliver-succeeded') {
const raw = await os.api('charts/ap-request', { limit: chartLimit, span: 'day' });
const raw = await misskeyApi('charts/ap-request', { limit: chartLimit, span: 'day' });
values = raw.deliverSucceeded;
} else if (props.src === 'ap-requests-deliver-failed') {
const raw = await os.api('charts/ap-request', { limit: chartLimit, span: 'day' });
const raw = await misskeyApi('charts/ap-request', { limit: chartLimit, span: 'day' });
values = raw.deliverFailed;
}

View File

@ -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 * as os from '@/os.js';
import { misskeyApiGet } from '@/scripts/misskey-api.js';
import { getProxiedImageUrlNullable } from '@/scripts/media-proxy.js';
const props = defineProps<{
@ -27,7 +27,7 @@ const props = defineProps<{
const chartValues = ref<number[] | null>(null);
os.apiGet('charts/instance', { host: props.instance.host, limit: 16 + 1, span: 'day' }).then(res => {
misskeyApiGet('charts/instance', { host: props.instance.host, limit: 16 + 1, span: 'day' }).then(res => {
//
res['requests.received'].splice(0, 1);
chartValues.value = res['requests.received'];

View File

@ -90,6 +90,7 @@ 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 { i18n } from '@/i18n.js';
import MkHeatmap from '@/components/MkHeatmap.vue';
import MkFoldableSection from '@/components/MkFoldableSection.vue';
@ -162,7 +163,7 @@ function createDoughnut(chartEl, tooltip, data) {
}
onMounted(() => {
os.apiGet('federation/stats', { limit: 30 }).then(fedStats => {
misskeyApiGet('federation/stats', { limit: 30 }).then(fedStats => {
createDoughnut(subDoughnutEl.value, externalTooltipHandler1, fedStats.topSubInstances.map(x => ({
name: x.host,
color: x.themeColor,

View File

@ -178,6 +178,7 @@ import {checkWordMute} from '@/scripts/check-word-mute.js';
import {userPage} from '@/filters/user.js';
import * as os from '@/os.js';
import * as sound from '@/scripts/sound.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import {defaultStore, noteViewInterruptors} from '@/store.js';
import {reactionPicker} from '@/scripts/reaction-picker.js';
import {extractUrlFromMfm} from '@/scripts/extract-url-from-mfm.js';
@ -284,7 +285,7 @@ const keymap = {
};
provide('react', (reaction: string) => {
os.api('notes/reactions/create', {
misskeyApi('notes/reactions/create', {
noteId: appearNote.value.id,
reaction: reaction,
});
@ -305,7 +306,7 @@ if (props.mock) {
if (!props.mock) {
useTooltip(renoteButton, async (showing) => {
const renotes = await os.api('notes/renotes', {
const renotes = await misskeyApi('notes/renotes', {
noteId: appearNote.value.id,
limit: 11,
});
@ -357,7 +358,7 @@ function react(viaKeyboard = false): void {
return;
}
os.api('notes/reactions/create', {
misskeyApi('notes/reactions/create', {
noteId: appearNote.value.id,
reaction: '❤️',
});
@ -378,7 +379,7 @@ function react(viaKeyboard = false): void {
return;
}
os.api('notes/reactions/create', {
misskeyApi('notes/reactions/create', {
noteId: appearNote.value.id,
reaction: reaction,
});
@ -400,7 +401,7 @@ function undoReact(note): void {
return;
}
os.api('notes/reactions/delete', {
misskeyApi('notes/reactions/delete', {
noteId: note.id,
});
}
@ -478,7 +479,7 @@ function showRenoteMenu(viaKeyboard = false): void {
icon: 'ti ti-trash',
danger: true,
action: () => {
os.api('notes/delete', {
misskeyApi('notes/delete', {
noteId: note.value.id,
});
isDeleted.value = true;
@ -524,7 +525,7 @@ function focusAfter() {
}
function readPromo() {
os.api('promo/read', {
misskeyApi('promo/read', {
noteId: appearNote.value.id,
});
isDeleted.value = true;

View File

@ -204,6 +204,7 @@ import { checkWordMute } from '@/scripts/check-word-mute.js';
import { userPage } from '@/filters/user.js';
import { notePage } from '@/filters/note.js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import * as sound from '@/scripts/sound.js';
import { defaultStore, noteViewInterruptors } from '@/store.js';
import { reactionPicker } from '@/scripts/reaction-picker.js';
@ -318,7 +319,7 @@ const keymap = {
};
provide('react', (reaction: string) => {
os.api('notes/reactions/create', {
misskeyApi('notes/reactions/create', {
noteId: appearNote.value.id,
reaction: reaction,
});
@ -352,7 +353,7 @@ useNoteCapture({
});
useTooltip(renoteButton, async (showing) => {
const renotes = await os.api('notes/renotes', {
const renotes = await misskeyApi('notes/renotes', {
noteId: appearNote.value.id,
limit: 11,
});
@ -397,7 +398,7 @@ function react(viaKeyboard = false): void {
if (appearNote.value.reactionAcceptance === 'likeOnly') {
sound.play('reaction');
os.api('notes/reactions/create', {
misskeyApi('notes/reactions/create', {
noteId: appearNote.value.id,
reaction: '❤️',
});
@ -413,7 +414,7 @@ function react(viaKeyboard = false): void {
reactionPicker.show(reactButton.value, reaction => {
sound.play('reaction');
os.api('notes/reactions/create', {
misskeyApi('notes/reactions/create', {
noteId: appearNote.value.id,
reaction: reaction,
});
@ -429,7 +430,7 @@ function react(viaKeyboard = false): void {
function undoReact(note): void {
const oldReaction = note.myReaction;
if (!oldReaction) return;
os.api('notes/reactions/delete', {
misskeyApi('notes/reactions/delete', {
noteId: note.id,
});
}
@ -472,7 +473,7 @@ function showRenoteMenu(viaKeyboard = false): void {
icon: 'ti ti-trash',
danger: true,
action: () => {
os.api('notes/delete', {
misskeyApi('notes/delete', {
noteId: note.value.id,
});
isDeleted.value = true;
@ -494,7 +495,7 @@ const repliesLoaded = ref(false);
function loadReplies() {
repliesLoaded.value = true;
os.api('notes/children', {
misskeyApi('notes/children', {
noteId: appearNote.value.id,
limit: 30,
}).then(res => {
@ -506,7 +507,7 @@ const conversationLoaded = ref(false);
function loadConversation() {
conversationLoaded.value = true;
os.api('notes/conversation', {
misskeyApi('notes/conversation', {
noteId: appearNote.value.replyId,
}).then(res => {
conversation.value = res.reverse();

View File

@ -38,7 +38,7 @@ import MkNoteHeader from '@/components/MkNoteHeader.vue';
import MkSubNoteContent from '@/components/MkSubNoteContent.vue';
import MkCwButton from '@/components/MkCwButton.vue';
import { notePage } from '@/filters/note.js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
import { $i } from '@/account.js';
import { userPage } from '@/filters/user.js';
@ -60,7 +60,7 @@ const showContent = ref(false);
const replies = ref<Misskey.entities.Note[]>([]);
if (props.detail) {
os.api('notes/children', {
misskeyApi('notes/children', {
noteId: props.note.id,
limit: 5,
}).then(res => {

View File

@ -145,7 +145,7 @@ import { getNoteSummary } from '@/scripts/get-note-summary.js';
import { notePage } from '@/filters/note.js';
import { userPage } from '@/filters/user.js';
import { i18n } from '@/i18n.js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { $i } from '@/account.js';
import { infoImageUrl } from '@/instance.js';
@ -162,12 +162,12 @@ const followRequestDone = ref(false);
const acceptFollowRequest = () => {
followRequestDone.value = true;
os.api('following/requests/accept', { userId: props.notification.user.id });
misskeyApi('following/requests/accept', { userId: props.notification.user.id });
};
const rejectFollowRequest = () => {
followRequestDone.value = true;
os.api('following/requests/reject', { userId: props.notification.user.id });
misskeyApi('following/requests/reject', { userId: props.notification.user.id });
};
</script>

View File

@ -46,6 +46,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { computed, ComputedRef, isRef, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onDeactivated, ref, shallowRef, watch } from 'vue';
import * as Misskey from 'misskey-js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { onScrollTop, isTopVisible, getBodyScrollHeight, getScrollContainer, onScrollBottom, scrollToBottom, scroll, isBottomVisible } from '@/scripts/scroll.js';
import { useDocumentVisibility } from '@/scripts/use-document-visibility.js';
import { defaultStore } from '@/store.js';
@ -203,7 +204,7 @@ async function init(): Promise<void> {
queue.value = new Map();
fetching.value = true;
const params = props.pagination.params ? isRef(props.pagination.params) ? props.pagination.params.value : props.pagination.params : {};
await os.api(props.pagination.endpoint, {
await misskeyApi(props.pagination.endpoint, {
...params,
limit: props.pagination.limit ?? 10,
allowPartial: true,
@ -237,7 +238,7 @@ const fetchMore = async (): Promise<void> => {
if (!more.value || fetching.value || moreFetching.value || items.value.size === 0) return;
moreFetching.value = true;
const params = props.pagination.params ? isRef(props.pagination.params) ? props.pagination.params.value : props.pagination.params : {};
await os.api(props.pagination.endpoint, {
await misskeyApi(props.pagination.endpoint, {
...params,
limit: SECOND_FETCH_LIMIT,
...(props.pagination.offsetMode ? {
@ -301,7 +302,7 @@ const fetchMoreAhead = async (): Promise<void> => {
if (!more.value || fetching.value || moreFetching.value || items.value.size === 0) return;
moreFetching.value = true;
const params = props.pagination.params ? isRef(props.pagination.params) ? props.pagination.params.value : props.pagination.params : {};
await os.api(props.pagination.endpoint, {
await misskeyApi(props.pagination.endpoint, {
...params,
limit: SECOND_FETCH_LIMIT,
...(props.pagination.offsetMode ? {

View File

@ -41,7 +41,9 @@ import MkInput from '@/components/MkInput.vue';
import MkButton from '@/components/MkButton.vue';
import MkModalWindow from '@/components/MkModalWindow.vue';
import { i18n } from '@/i18n.js';
import { $i } from '@/account.js';
import { signinRequired } from '@/account.js';
const $i = signinRequired();
const emit = defineEmits<{
(ev: 'done', v: { password: string; token: string | null; }): void;

View File

@ -32,11 +32,13 @@ import * as Misskey from 'misskey-js';
import { sum } from '@/scripts/array.js';
import { pleaseLogin } from '@/scripts/please-login.js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
import { useInterval } from '@/scripts/use-interval.js';
import { WithNonNullable } from '@/type.js';
const props = defineProps<{
note: Misskey.entities.Note;
note: WithNonNullable<Misskey.entities.Note, 'poll'>;
readOnly?: boolean;
}>();
@ -83,7 +85,7 @@ const vote = async (id) => {
});
if (canceled) return;
await os.api('notes/polls/vote', {
await misskeyApi('notes/polls/vote', {
noteId: props.note.id,
choice: id,
});

View File

@ -115,6 +115,7 @@ import { extractMentions } from '@/scripts/extract-mentions.js';
import { formatTimeString } from '@/scripts/format-time-string.js';
import { Autocomplete } from '@/scripts/autocomplete.js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { selectFiles } from '@/scripts/select-file.js';
import { dateTimeFormat } from '@/scripts/intl-const.js';
import {
@ -129,7 +130,7 @@ import {
import MkInfo from '@/components/MkInfo.vue';
import { i18n } from '@/i18n.js';
import { instance } from '@/instance.js';
import { $i, notesCount, incNotesCount, getAccounts, openAccountMenu as openAccountMenu_ } from '@/account.js';
import { signinRequired, notesCount, incNotesCount, getAccounts, openAccountMenu as openAccountMenu_ } from '@/account.js';
import { uploadFile } from '@/scripts/upload.js';
import { deepClone } from '@/scripts/clone.js';
import MkRippleEffect from '@/components/MkRippleEffect.vue';
@ -140,6 +141,8 @@ import { mfmFunctionPicker } from '@/scripts/mfm-function-picker.js';
import MkScheduleEditor from '@/components/MkScheduleEditor.vue';
import { listSchedulePost } from '@/os.js';
const $i = signinRequired();
const modal = inject('modal');
let gamingType = computed(defaultStore.makeGetterSetter('gamingType'));
@ -326,7 +329,7 @@ if (props.reply && props.reply.text != null) {
}
}
if ($i?.isSilenced && visibility.value === 'public') {
if ($i.isSilenced && visibility.value === 'public') {
visibility.value = 'home';
}
@ -347,7 +350,7 @@ if (props.reply && ['home', 'followers', 'specified'].includes(props.reply.visib
if (visibility.value === 'specified') {
if (props.reply.visibleUserIds) {
os.api('users/show', {
misskeyApi('users/show', {
userIds: props.reply.visibleUserIds.filter(uid => uid !== $i.id && uid !== props.reply.userId),
}).then(users => {
users.forEach(pushVisibleUser);
@ -355,7 +358,7 @@ if (props.reply && ['home', 'followers', 'specified'].includes(props.reply.visib
}
if (props.reply.userId !== $i.id) {
os.api('users/show', { userId: props.reply.userId }).then(user => {
misskeyApi('users/show', { userId: props.reply.userId }).then(user => {
pushVisibleUser(user);
});
}
@ -402,7 +405,7 @@ function addMissingMention() {
for (const x of extractMentions(ast)) {
if (!visibleUsers.value.some(u => (u.username === x.username) && (u.host === x.host))) {
os.api('users/show', { username: x.username, host: x.host }).then(user => {
misskeyApi('users/show', { username: x.username, host: x.host }).then(user => {
visibleUsers.value.push(user);
});
}
@ -487,7 +490,7 @@ function setVisibility() {
os.popup(defineAsyncComponent(() => import('@/components/MkVisibilityPicker.vue')), {
currentVisibility: visibility.value,
isSilenced: $i?.isSilenced,localOnly: localOnly.value,
isSilenced: $i.isSilenced,localOnly: localOnly.value,
src: visibilityButton.value,
}, {
changeVisibility: v => {
@ -807,7 +810,7 @@ async function post(ev?: MouseEvent) {
}
posting.value = true;
os.api(props.updateMode ? 'notes/update' : 'notes/create', postData, token).then(() => {
misskeyApi(props.updateMode ? 'notes/update' : 'notes/create', postData, token).then(() => {
if (props.freezeAfterPosted) {
posted.value = true;
} else {

View File

@ -24,6 +24,7 @@ import { defineAsyncComponent, inject } from 'vue';
import * as Misskey from 'misskey-js';
import MkDriveFileThumbnail from '@/components/MkDriveFileThumbnail.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
const Sortable = defineAsyncComponent(() => import('vuedraggable').then(x => x.default));
@ -61,7 +62,7 @@ function toggleSensitive(file) {
return;
}
os.api('drive/files/update', {
misskeyApi('drive/files/update', {
fileId: file.id,
isSensitive: !file.isSensitive,
}).then(() => {
@ -78,7 +79,7 @@ async function rename(file) {
allowEmpty: false,
});
if (canceled) return;
os.api('drive/files/update', {
misskeyApi('drive/files/update', {
fileId: file.id,
name: result,
}).then(() => {
@ -96,7 +97,7 @@ async function describe(file) {
}, {
done: caption => {
let comment = caption.length === 0 ? null : caption;
os.api('drive/files/update', {
misskeyApi('drive/files/update', {
fileId: file.id,
comment: comment,
}).then(() => {

View File

@ -45,7 +45,8 @@ import { ref } from 'vue';
import { $i, getAccounts } from '@/account.js';
import MkButton from '@/components/MkButton.vue';
import { instance } from '@/instance.js';
import { api, apiWithDialog, promiseDialog } from '@/os.js';
import { apiWithDialog, promiseDialog } from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
defineProps<{
@ -82,7 +83,7 @@ function subscribe() {
pushSubscription.value = subscription;
// Register
pushRegistrationInServer.value = await api('sw/register', {
pushRegistrationInServer.value = await misskeyApi('sw/register', {
endpoint: subscription.endpoint,
auth: encode(subscription.getKey('auth')),
publickey: encode(subscription.getKey('p256dh')),
@ -159,7 +160,7 @@ if (navigator.serviceWorker == null) {
supported.value = true;
if (pushSubscription.value) {
const res = await api('sw/show-registration', {
const res = await misskeyApi('sw/show-registration', {
endpoint: pushSubscription.value.endpoint,
});

View File

@ -22,6 +22,7 @@ import * as Misskey from 'misskey-js';
import XDetails from '@/components/MkReactionsViewer.details.vue';
import MkReactionIcon from '@/components/MkReactionIcon.vue';
import * as os from '@/os.js';
import { misskeyApi, misskeyApiGet } from '@/scripts/misskey-api.js';
import { useTooltip } from '@/scripts/use-tooltip.js';
import { $i } from '@/account.js';
import MkReactionEffect from '@/components/MkReactionEffect.vue';
@ -71,11 +72,11 @@ async function toggleReaction() {
return;
}
os.api('notes/reactions/delete', {
misskeyApi('notes/reactions/delete', {
noteId: props.note.id,
}).then(() => {
if (oldReaction !== props.reaction) {
os.api('notes/reactions/create', {
misskeyApi('notes/reactions/create', {
noteId: props.note.id,
reaction: props.reaction,
});
@ -89,7 +90,7 @@ async function toggleReaction() {
return;
}
os.api('notes/reactions/create', {
misskeyApi('notes/reactions/create', {
noteId: props.note.id,
reaction: props.reaction,
});
@ -119,7 +120,7 @@ onMounted(() => {
if (!mock) {
useTooltip(buttonEl, async (showing) => {
const reactions = await os.apiGet('notes/reactions', {
const reactions = await misskeyApiGet('notes/reactions', {
noteId: props.note.id,
type: props.reaction,
limit: 10,

View File

@ -15,7 +15,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import { onMounted, nextTick, shallowRef, ref } from 'vue';
import { Chart } from 'chart.js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { defaultStore } from '@/store.js';
import { useChartTooltip } from '@/scripts/use-chart-tooltip.js';
import { alpha } from '@/scripts/color.js';
@ -43,7 +43,7 @@ async function renderChart() {
const maxDays = wide ? 10 : narrow ? 5 : 7;
let raw = await os.api('retention', { });
let raw = await misskeyApi('retention', { });
raw = raw.slice(0, maxDays + 1);

View File

@ -16,7 +16,7 @@ import { useChartTooltip } from '@/scripts/use-chart-tooltip.js';
import { chartVLine } from '@/scripts/chart-vline.js';
import { alpha } from '@/scripts/color.js';
import { initChart } from '@/scripts/init-chart.js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
initChart();
@ -40,7 +40,7 @@ const getDate = (ymd: string) => {
};
onMounted(async () => {
let raw = await os.api('retention', { });
let raw = await misskeyApi('retention', { });
const vLineColor = defaultStore.state.darkMode ? 'rgba(255, 255, 255, 0.2)' : 'rgba(0, 0, 0, 0.2)';

View File

@ -77,7 +77,14 @@ const emit = defineEmits<{
(ev: 'end'): void;
}>();
const particles = [];
const particles: {
size: number;
xA: number;
yA: number;
xB: number;
yB: number;
color: string;
}[] = [];
const origin = 64;
const colors = ['#FF1493', '#00FFFF', '#FFE202'];
const zIndex = os.claimZIndex('high');

View File

@ -59,6 +59,7 @@ import MkInput from '@/components/MkInput.vue';
import MkInfo from '@/components/MkInfo.vue';
import { host as configHost } from '@/config.js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { login } from '@/account.js';
import { i18n } from '@/i18n.js';
@ -95,7 +96,7 @@ const props = defineProps({
});
function onUsernameChange(): void {
os.api('users/show', {
misskeyApi('users/show', {
username: username.value,
}).then(userResponse => {
user.value = userResponse;
@ -120,7 +121,7 @@ async function queryKey(): Promise<void> {
credentialRequest.value = null;
queryingKey.value = false;
signing.value = true;
return os.api('signin', {
return misskeyApi('signin', {
username: username.value,
password: password.value,
credential: credential.toJSON(),
@ -142,7 +143,7 @@ function onSubmit(): void {
signing.value = true;
if (!totpLogin.value && user.value && user.value.twoFactorEnabled) {
if (webAuthnSupported() && user.value.securityKeys) {
os.api('signin', {
misskeyApi('signin', {
username: username.value,
password: password.value,
}).then(res => {
@ -159,7 +160,7 @@ function onSubmit(): void {
signing.value = false;
}
} else {
os.api('signin', {
misskeyApi('signin', {
username: username.value,
password: password.value,
token: user.value?.twoFactorEnabled ? token.value : undefined,

View File

@ -119,6 +119,7 @@ import MkInput from './MkInput.vue';
import MkCaptcha, {type Captcha} from '@/components/MkCaptcha.vue';
import * as config from '@/config.js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import {login} from '@/account.js';
import {instance} from '@/instance.js';
import {i18n} from '@/i18n.js';
@ -219,7 +220,7 @@ function onChangeUsername(): void {
usernameState.value = 'wait';
usernameAbortController.value = new AbortController();
os.api('username/available', {
misskeyApi('username/available', {
username: username.value,
}, undefined, usernameAbortController.value.signal).then(result => {
usernameState.value = result.available ? 'ok' : 'unavailable';
@ -242,7 +243,7 @@ function onChangeEmail(): void {
emailState.value = 'wait';
emailAbortController.value = new AbortController();
os.api('email-address/available', {
misskeyApi('email-address/available', {
emailAddress: email.value,
}, undefined, emailAbortController.value.signal).then(result => {
emailState.value = result.available ? 'ok' :
@ -284,7 +285,7 @@ async function onSubmit(): Promise<void> {
submitting.value = true;
try {
await os.api('signup', {
await misskeyApi('signup', {
username: username.value,
password: password.value,
emailAddress: email.value,
@ -301,7 +302,7 @@ async function onSubmit(): Promise<void> {
});
emit('signupEmailPending');
} else {
const res = await os.api('signin', {
const res = await misskeyApi('signin', {
username: username.value,
password: password.value,
});

View File

@ -11,13 +11,13 @@ SPDX-License-Identifier: AGPL-3.0-only
:pagination="paginationQuery"
:noGap="!defaultStore.state.showGapBetweenNotesInTimeline"
@queue="emit('queue', $event)"
@status="prComponent.setDisabled($event)"
@status="prComponent?.setDisabled($event)"
/>
</MkPullToRefresh>
</template>
<script lang="ts" setup>
import { computed, watch, onUnmounted, provide, ref } from 'vue';
import { computed, watch, onUnmounted, provide, ref, shallowRef } from 'vue';
import { Connection } from 'misskey-js/built/streaming.js';
import MkNotes from '@/components/MkNotes.vue';
import MkPullToRefresh from '@/components/MkPullToRefresh.vue';
@ -62,12 +62,14 @@ type TimelineQueryType = {
roleId?: string
}
const prComponent = ref<InstanceType<typeof MkPullToRefresh>>();
const tlComponent = ref<InstanceType<typeof MkNotes>>();
const prComponent = shallowRef<InstanceType<typeof MkPullToRefresh>>();
const tlComponent = shallowRef<InstanceType<typeof MkNotes>>();
let tlNotesCount = 0;
const prepend = note => {
function prepend(note) {
if (tlComponent.value == null) return;
tlNotesCount++;
if (instance.notesPerOneAd > 0 && tlNotesCount % instance.notesPerOneAd === 0) {
@ -81,7 +83,7 @@ const prepend = note => {
if (props.sound) {
sound.play($i && (note.userId === $i.id) ? 'noteMy' : 'note');
}
};
}
let connection: Connection;
let connection2: Connection;
@ -260,6 +262,8 @@ onUnmounted(() => {
function reloadTimeline() {
return new Promise<void>((res) => {
if (tlComponent.value == null) return;
tlNotesCount = 0;
tlComponent.value.pagingComponent?.reload().then(() => {

View File

@ -11,7 +11,7 @@ SPDX-License-Identifier: AGPL-3.0-only
:withOkButton="true"
:okButtonDisabled="false"
:canClose="false"
@close="dialog.close()"
@close="dialog?.close()"
@closed="$emit('closed')"
@ok="ok()"
>
@ -87,7 +87,7 @@ function ok(): void {
name: name.value,
permissions: Object.keys(permissions.value).filter(p => permissions.value[p]),
});
dialog.value.close();
dialog.value?.close();
}
function disableAll(): void {

View File

@ -13,8 +13,10 @@ SPDX-License-Identifier: AGPL-3.0-only
>
<div v-show="showing" ref="el" :class="$style.root" class="_acrylic _shadow" :style="{ zIndex, maxWidth: maxWidth + 'px' }">
<slot>
<Mfm v-if="asMfm" :text="text"/>
<span v-else>{{ text }}</span>
<template v-if="text">
<Mfm v-if="asMfm" :text="text"/>
<span v-else>{{ text }}</span>
</template>
</slot>
</div>
</Transition>
@ -53,6 +55,7 @@ const el = shallowRef<HTMLElement>();
const zIndex = os.claimZIndex('high');
function setPosition() {
if (!el.value || !props.targetElement) return;
const data = calcPopupPosition(el.value, {
anchorElement: props.targetElement,
direction: props.direction,

View File

@ -4,12 +4,12 @@ SPDX-License-Identifier: AGPL-3.0-only
-->
<template>
<MkModal ref="modal" :zPriority="'middle'" @click="$refs.modal.close()" @closed="$emit('closed')">
<MkModal ref="modal" :zPriority="'middle'" @click="modal?.close()" @closed="$emit('closed')">
<div :class="$style.root">
<div :class="$style.title"><MkSparkle>{{ i18n.ts.misskeyUpdated }}</MkSparkle></div>
<div :class="$style.version">{{ version }}🚀</div>
<MkButton full @click="whatIsNew">{{ i18n.ts.whatIsNew }}</MkButton>
<MkButton :class="$style.gotIt" primary full @click="$refs.modal.close()">{{ i18n.ts.gotIt }}</MkButton>
<MkButton :class="$style.gotIt" primary full @click="modal?.close()">{{ i18n.ts.gotIt }}</MkButton>
</div>
</MkModal>
</template>
@ -25,10 +25,10 @@ import { confetti } from '@/scripts/confetti.js';
const modal = shallowRef<InstanceType<typeof MkModal>>();
const whatIsNew = () => {
modal.value.close();
function whatIsNew() {
modal.value?.close();
window.open(`https://misskey-hub.net/docs/releases/#_${version.replace(/\./g, '')}`, '_blank');
};
}
onMounted(() => {
confetti({

View File

@ -56,6 +56,7 @@ import MkModalWindow from '@/components/MkModalWindow.vue';
import MkButton from '@/components/MkButton.vue';
import MkInput from '@/components/MkInput.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
import MkTextarea from '@/components/MkTextarea.vue';
import MkSwitch from '@/components/MkSwitch.vue';
@ -121,7 +122,7 @@ async function del() {
});
if (canceled) return;
os.api('admin/announcements/delete', {
misskeyApi('admin/announcements/delete', {
id: props.announcement.id,
}).then(() => {
emit('done', {

View File

@ -18,7 +18,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import * as Misskey from 'misskey-js';
import { onMounted, ref } from 'vue';
import MkMiniChart from '@/components/MkMiniChart.vue';
import * as os from '@/os.js';
import { misskeyApiGet } from '@/scripts/misskey-api.js';
import { acct } from '@/filters/user.js';
const props = withDefaults(defineProps<{
@ -32,7 +32,7 @@ const chartValues = ref<number[] | null>(null);
onMounted(() => {
if (props.withChart) {
os.apiGet('charts/user/notes', { userId: props.user.id, limit: 16 + 1, span: 'day' }).then(res => {
misskeyApiGet('charts/user/notes', { userId: props.user.id, limit: 16 + 1, span: 'day' }).then(res => {
//
res.inc.splice(0, 1);
chartValues.value = res.inc;

View File

@ -60,6 +60,7 @@ import * as Misskey from 'misskey-js';
import MkFollowButton from '@/components/MkFollowButton.vue';
import { userPage } from '@/filters/user.js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { getUserMenu } from '@/scripts/get-user-menu.js';
import number from '@/filters/number.js';
import { i18n } from '@/i18n.js';
@ -97,7 +98,7 @@ onMounted(() => {
Misskey.acct.parse(props.q.substring(1)) :
{ userId: props.q };
os.api('users/show', query).then(res => {
misskeyApi('users/show', query).then(res => {
if (!props.showing) return;
user.value = res;
});

View File

@ -62,7 +62,7 @@ import * as Misskey from 'misskey-js';
import MkInput from '@/components/MkInput.vue';
import FormSplit from '@/components/form/split.vue';
import MkModalWindow from '@/components/MkModalWindow.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { defaultStore } from '@/store.js';
import { i18n } from '@/i18n.js';
import { $i } from '@/account.js';
@ -90,7 +90,7 @@ const search = () => {
users.value = [];
return;
}
os.api('users/search-by-username-and-host', {
misskeyApi('users/search-by-username-and-host', {
username: username.value,
host: host.value,
limit: 10,
@ -118,7 +118,7 @@ const cancel = () => {
};
onMounted(() => {
os.api('users/show', {
misskeyApi('users/show', {
userIds: defaultStore.state.recentlyUsedUsers,
}).then(users => {
if (props.includeSelf && users.find(x => $i ? x.id === $i.id : true) == null) {

View File

@ -49,7 +49,7 @@ import { i18n } from '@/i18n.js';
import MkSwitch from '@/components/MkSwitch.vue';
import MkInfo from '@/components/MkInfo.vue';
import MkFolder from '@/components/MkFolder.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
const isLocked = ref(false);
const hideOnlineStatus = ref(false);
@ -57,7 +57,7 @@ const noCrawle = ref(false);
const preventAiLearning = ref(true);
watch([isLocked, hideOnlineStatus, noCrawle, preventAiLearning], () => {
os.api('i/update', {
misskeyApi('i/update', {
isLocked: !!isLocked.value,
hideOnlineStatus: !!hideOnlineStatus.value,
noCrawle: !!noCrawle.value,

View File

@ -29,7 +29,7 @@ import * as Misskey from 'misskey-js';
import { ref } from 'vue';
import MkButton from '@/components/MkButton.vue';
import { i18n } from '@/i18n.js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
const props = defineProps<{
user: Misskey.entities.UserDetailed;
@ -39,7 +39,7 @@ const isFollowing = ref(false);
async function follow() {
isFollowing.value = true;
os.api('following/create', {
misskeyApi('following/create', {
userId: props.user.id,
});
}

View File

@ -17,7 +17,7 @@ import { onMounted, shallowRef, ref } from 'vue';
import { Chart } from 'chart.js';
import gradient from 'chartjs-plugin-gradient';
import tinycolor from 'tinycolor2';
import * as os from '@/os.js';
import { misskeyApi } 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';
@ -53,7 +53,7 @@ async function renderChart() {
}));
};
const raw = await os.api('charts/active-users', { limit: chartLimit, span: 'day' });
const raw = await misskeyApi('charts/active-users', { limit: chartLimit, span: 'day' });
const vLineColor = defaultStore.state.darkMode ? 'rgba(255, 255, 255, 0.2)' : 'rgba(0, 0, 0, 0.2)';

View File

@ -60,6 +60,7 @@ import MkTimeline from '@/components/MkTimeline.vue';
import MkInfo from '@/components/MkInfo.vue';
import { instanceName } from '@/config.js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
import { instance } from '@/instance.js';
import MkNumber from '@/components/MkNumber.vue';
@ -68,11 +69,11 @@ import XActiveUsersChart from '@/components/MkVisitorDashboard.ActiveUsersChart.
const meta = ref<Misskey.entities.MetaResponse | null>(null);
const stats = ref<Misskey.entities.StatsResponse | null>(null);
os.api('meta', { detail: true }).then(_meta => {
misskeyApi('meta', { detail: true }).then(_meta => {
meta.value = _meta;
});
os.api('stats', {}).then((res) => {
misskeyApi('stats', {}).then((res) => {
stats.value = res;
});

View File

@ -143,6 +143,7 @@ function top() {
}
function maximize() {
if (rootEl.value == null) return;
maximized.value = true;
unResizedTop = rootEl.value.style.top;
unResizedLeft = rootEl.value.style.left;
@ -155,6 +156,7 @@ function maximize() {
}
function unMaximize() {
if (rootEl.value == null) return;
maximized.value = false;
rootEl.value.style.top = unResizedTop;
rootEl.value.style.left = unResizedLeft;
@ -163,6 +165,7 @@ function unMaximize() {
}
function minimize() {
if (rootEl.value == null) return;
minimized.value = true;
unResizedWidth = rootEl.value.style.width;
unResizedHeight = rootEl.value.style.height;
@ -171,8 +174,8 @@ function minimize() {
}
function unMinimize() {
if (rootEl.value == null) return;
const main = rootEl.value;
if (main == null) return;
minimized.value = false;
rootEl.value.style.width = unResizedWidth;

View File

@ -16,7 +16,7 @@ import * as Misskey from 'misskey-js';
import { NoteBlock } from './block.type.js';
import MkNote from '@/components/MkNote.vue';
import MkNoteDetailed from '@/components/MkNoteDetailed.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
const props = defineProps<{
block: NoteBlock,
@ -26,7 +26,7 @@ const props = defineProps<{
const note = ref<Misskey.entities.Note | null>(null);
onMounted(() => {
os.api('notes/show', { noteId: props.block.note })
misskeyApi('notes/show', { noteId: props.block.note })
.then(result => {
note.value = result;
});

View File

@ -5,7 +5,7 @@
import { shallowRef, computed, markRaw, triggerRef, watch } from 'vue';
import * as Misskey from 'misskey-js';
import { api, apiGet } from '@/os.js';
import { misskeyApi, misskeyApiGet } from '@/scripts/misskey-api.js';
import { useStream } from '@/stream.js';
import { get, set } from '@/scripts/idb-proxy.js';
@ -56,11 +56,11 @@ export async function fetchCustomEmojis(force = false) {
let res;
if (force) {
res = await api('emojis', {});
res = await misskeyApi('emojis', {});
} else {
const lastFetchedAt = await get('lastEmojisFetchedAt');
if (lastFetchedAt && (now - lastFetchedAt) < 1000 * 60 * 60) return;
res = await apiGet('emojis', {});
res = await misskeyApiGet('emojis', {});
}
customEmojis.value = res.emojis;

View File

@ -5,7 +5,7 @@
import { computed, reactive } from 'vue';
import * as Misskey from 'misskey-js';
import { api } from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { miLocalStorage } from '@/local-storage.js';
import { DEFAULT_INFO_IMAGE_URL, DEFAULT_NOT_FOUND_IMAGE_URL, DEFAULT_SERVER_ERROR_IMAGE_URL } from '@/const.js';
@ -26,7 +26,7 @@ export const infoImageUrl = computed(() => instance.infoImageUrl ?? DEFAULT_INFO
export const notFoundImageUrl = computed(() => instance.notFoundImageUrl ?? DEFAULT_NOT_FOUND_IMAGE_URL);
export async function fetchInstance() {
const meta = await api('meta', {
const meta = await misskeyApi('meta', {
detail: false,
});

View File

@ -5,12 +5,11 @@
// TODO: なんでもかんでもos.tsに突っ込むのやめたいのでよしなに分割する
import { pendingApiRequestsCount, api, apiGet } from '@/scripts/api.js';
export { pendingApiRequestsCount, api, apiGet };
import { Component, markRaw, Ref, ref, defineAsyncComponent } from 'vue';
import { EventEmitter } from 'eventemitter3';
import insertTextAtCursor from 'insert-text-at-cursor';
import * as Misskey from 'misskey-js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
import MkPostFormDialog from '@/components/MkPostFormDialog.vue';
import MkWaitingDialog from '@/components/MkWaitingDialog.vue';
@ -34,7 +33,7 @@ export const apiWithDialog = ((
data: Record<string, any> = {},
token?: string | null | undefined,
) => {
const promise = api(endpoint, data, token);
const promise = misskeyApi(endpoint, data, token);
promiseDialog(promise, null, async (err) => {
let title = null;
let text = err.message + '\n' + (err as any).id;
@ -84,7 +83,7 @@ export const apiWithDialog = ((
});
return promise;
}) as typeof api;
}) as typeof misskeyApi;
export function promiseDialog<T extends Promise<any>>(
promise: T,
@ -645,7 +644,7 @@ export function checkExistence(fileData: ArrayBuffer): Promise<any> {
const data = new FormData();
data.append('md5', getMD5(fileData));
os.api('drive/files/find-by-hash', {
api('drive/files/find-by-hash', {
md5: getMD5(fileData)
}).then(resp => {
resolve(resp.length > 0 ? resp[0] : null);

View File

@ -29,7 +29,7 @@ import { ref, computed } from 'vue';
import * as Misskey from 'misskey-js';
import MkButton from '@/components/MkButton.vue';
import { version } from '@/config.js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { unisonReload } from '@/scripts/unison-reload.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -46,7 +46,7 @@ const loaded = ref(false);
const serverIsDead = ref(false);
const meta = ref<Misskey.entities.MetaResponse | null>(null);
os.api('meta', {
misskeyApi('meta', {
detail: false,
}).then(res => {
loaded.value = true;

View File

@ -112,7 +112,7 @@ import FormSplit from '@/components/form/split.vue';
import MkFolder from '@/components/MkFolder.vue';
import MkKeyValue from '@/components/MkKeyValue.vue';
import MkInstanceStats from '@/components/MkInstanceStats.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import number from '@/filters/number.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -153,7 +153,7 @@ watch(darkMode, () => {
iconUrl.value = iconLight;
}
})
const initStats = () => os.api('stats', {
const initStats = () => misskeyApi('stats', {
}).then((res) => {
stats.value = res;
});

View File

@ -79,6 +79,7 @@ import MkUserCardMini from '@/components/MkUserCardMini.vue';
import MkInfo from '@/components/MkInfo.vue';
import bytes from '@/filters/bytes.js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
import { iAmAdmin, iAmModerator } from '@/account.js';
@ -93,8 +94,8 @@ const props = defineProps<{
}>();
async function fetch() {
file.value = await os.api('drive/files/show', { fileId: props.fileId });
info.value = await os.api('admin/drive/show-file', { fileId: props.fileId });
file.value = await misskeyApi('drive/files/show', { fileId: props.fileId });
info.value = await misskeyApi('admin/drive/show-file', { fileId: props.fileId });
isSensitive.value = file.value.isSensitive;
}
@ -113,7 +114,7 @@ async function del() {
}
async function toggleIsSensitive(v) {
await os.api('drive/files/update', { fileId: props.fileId, isSensitive: v });
await misskeyApi('drive/files/update', { fileId: props.fileId, isSensitive: v });
isSensitive.value = v;
}

View File

@ -219,6 +219,7 @@ import FormSuspense from '@/components/form/suspense.vue';
import MkFileListForAdmin from '@/components/MkFileListForAdmin.vue';
import MkInfo from '@/components/MkInfo.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { url } from '@/config.js';
import { acct } from '@/filters/user.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -262,11 +263,11 @@ const announcementsPagination = {
const expandedRoles = ref([]);
function createFetcher() {
return () => Promise.all([os.api('users/show', {
return () => Promise.all([misskeyApi('users/show', {
userId: props.userId,
}), os.api('admin/show-user', {
}), misskeyApi('admin/show-user', {
userId: props.userId,
}), iAmAdmin ? os.api('admin/get-user-ips', {
}), iAmAdmin ? misskeyApi('admin/get-user-ips', {
userId: props.userId,
}) : Promise.resolve(null)]).then(([_user, _info, _ips]) => {
user.value = _user;
@ -278,7 +279,7 @@ function createFetcher() {
moderationNote.value = info.value.moderationNote;
watch(moderationNote, async () => {
await os.api('admin/update-user-note', { userId: user.value.id, text: moderationNote.value });
await misskeyApi('admin/update-user-note', { userId: user.value.id, text: moderationNote.value });
await refreshUser();
});
});
@ -301,7 +302,7 @@ async function resetPassword() {
if (confirm.canceled) {
return;
} else {
const { password } = await os.api('admin/reset-password', {
const { password } = await misskeyApi('admin/reset-password', {
userId: user.value.id,
});
os.alert({
@ -319,7 +320,7 @@ async function toggleSuspend(v) {
if (confirm.canceled) {
suspended.value = !v;
} else {
await os.api(v ? 'admin/suspend-user' : 'admin/unsuspend-user', { userId: user.value.id });
await misskeyApi(v ? 'admin/suspend-user' : 'admin/unsuspend-user', { userId: user.value.id });
await refreshUser();
}
}
@ -331,7 +332,7 @@ async function unsetUserAvatar() {
});
if (confirm.canceled) return;
const process = async () => {
await os.api('admin/unset-user-avatar', { userId: user.value.id });
await misskeyApi('admin/unset-user-avatar', { userId: user.value.id });
os.success();
};
await process().catch(err => {
@ -350,7 +351,7 @@ async function unsetUserBanner() {
});
if (confirm.canceled) return;
const process = async () => {
await os.api('admin/unset-user-banner', { userId: user.value.id });
await misskeyApi('admin/unset-user-banner', { userId: user.value.id });
os.success();
};
await process().catch(err => {
@ -369,7 +370,7 @@ async function deleteAllFiles() {
});
if (confirm.canceled) return;
const process = async () => {
await os.api('admin/delete-all-files-of-a-user', { userId: user.value.id });
await misskeyApi('admin/delete-all-files-of-a-user', { userId: user.value.id });
os.success();
};
await process().catch(err => {
@ -406,7 +407,7 @@ async function deleteAccount() {
}
async function assignRole() {
const roles = await os.api('admin/roles/list');
const roles = await misskeyApi('admin/roles/list');
const { canceled, result: roleId } = await os.select({
title: i18n.ts._role.chooseRoleToAssign,
@ -482,7 +483,7 @@ watch(() => props.userId, () => {
});
watch(user, () => {
os.api('ap/get', {
misskeyApi('ap/get', {
uri: user.value.uri ?? `${url}/users/${user.value.id}`,
}).then(res => {
ap.value = res;

View File

@ -96,6 +96,7 @@ import MkFolder from '@/components/MkFolder.vue';
import MkSelect from '@/components/MkSelect.vue';
import FormSplit from '@/components/form/split.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -108,7 +109,7 @@ const daysOfWeek: string[] = [i18n.ts._weekday.sunday, i18n.ts._weekday.monday,
const filterType = ref('all');
let publishing: boolean | null = null;
os.api('admin/ad/list', { publishing: publishing }).then(adsResponse => {
misskeyApi('admin/ad/list', { publishing: publishing }).then(adsResponse => {
if (adsResponse != null) {
ads.value = adsResponse.map(r => {
const exdate = new Date(r.expiresAt);
@ -174,7 +175,7 @@ function remove(ad) {
function save(ad) {
if (ad.id == null) {
os.api('admin/ad/create', {
misskeyApi('admin/ad/create', {
...ad,
expiresAt: new Date(ad.expiresAt).getTime(),
startsAt: new Date(ad.startsAt).getTime(),
@ -191,7 +192,7 @@ function save(ad) {
});
});
} else {
os.api('admin/ad/update', {
misskeyApi('admin/ad/update', {
...ad,
expiresAt: new Date(ad.expiresAt).getTime(),
startsAt: new Date(ad.startsAt).getTime(),
@ -210,7 +211,7 @@ function save(ad) {
}
function more() {
os.api('admin/ad/list', { untilId: ads.value.reduce((acc, ad) => ad.id != null ? ad : acc).id, publishing: publishing }).then(adsResponse => {
misskeyApi('admin/ad/list', { untilId: ads.value.reduce((acc, ad) => ad.id != null ? ad : acc).id, publishing: publishing }).then(adsResponse => {
if (adsResponse == null) return;
ads.value = ads.value.concat(adsResponse.map(r => {
const exdate = new Date(r.expiresAt);
@ -227,7 +228,7 @@ function more() {
}
function refresh() {
os.api('admin/ad/list', { publishing: publishing }).then(adsResponse => {
misskeyApi('admin/ad/list', { publishing: publishing }).then(adsResponse => {
if (adsResponse == null) return;
ads.value = adsResponse.map(r => {
const exdate = new Date(r.expiresAt);

View File

@ -79,6 +79,7 @@ import MkSwitch from '@/components/MkSwitch.vue';
import MkRadios from '@/components/MkRadios.vue';
import MkInfo from '@/components/MkInfo.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
import MkFolder from '@/components/MkFolder.vue';
@ -86,7 +87,7 @@ import MkTextarea from '@/components/MkTextarea.vue';
const announcements = ref<any[]>([]);
os.api('admin/announcements/list').then(announcementResponse => {
misskeyApi('admin/announcements/list').then(announcementResponse => {
announcements.value = announcementResponse;
});
@ -112,7 +113,7 @@ function del(announcement) {
}).then(({ canceled }) => {
if (canceled) return;
announcements.value = announcements.value.filter(x => x !== announcement);
os.api('admin/announcements/delete', announcement);
misskeyApi('admin/announcements/delete', announcement);
});
}
@ -134,13 +135,13 @@ async function save(announcement) {
}
function more() {
os.api('admin/announcements/list', { untilId: announcements.value.reduce((acc, announcement) => announcement.id != null ? announcement : acc).id }).then(announcementResponse => {
misskeyApi('admin/announcements/list', { untilId: announcements.value.reduce((acc, announcement) => announcement.id != null ? announcement : acc).id }).then(announcementResponse => {
announcements.value = announcements.value.concat(announcementResponse);
});
}
function refresh() {
os.api('admin/announcements/list').then(announcementResponse => {
misskeyApi('admin/announcements/list').then(announcementResponse => {
announcements.value = announcementResponse;
});
}

View File

@ -72,6 +72,7 @@ import MkButton from '@/components/MkButton.vue';
import FormSuspense from '@/components/form/suspense.vue';
import FormSlot from '@/components/form/slot.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { fetchInstance } from '@/instance.js';
import { i18n } from '@/i18n.js';
@ -86,7 +87,7 @@ const turnstileSiteKey = ref<string | null>(null);
const turnstileSecretKey = ref<string | null>(null);
async function init() {
const meta = await os.api('admin/meta');
const meta = await misskeyApi('admin/meta');
hcaptchaSiteKey.value = meta.hcaptchaSiteKey;
hcaptchaSecretKey.value = meta.hcaptchaSecretKey;
recaptchaSiteKey.value = meta.recaptchaSiteKey;

View File

@ -101,6 +101,7 @@ import MkInput from '@/components/MkInput.vue';
import MkTextarea from '@/components/MkTextarea.vue';
import FormSuspense from '@/components/form/suspense.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { instance, fetchInstance } from '@/instance.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -122,7 +123,7 @@ const notFoundImageUrl = ref<string | null>(null);
const manifestJsonOverride = ref<string>('{}');
async function init() {
const meta = await os.api('admin/meta');
const meta = await misskeyApi('admin/meta');
iconUrl.value = meta.iconUrl;
app192IconUrl.value = meta.app192IconUrl;
app512IconUrl.value = meta.app512IconUrl;

View File

@ -21,13 +21,13 @@ SPDX-License-Identifier: AGPL-3.0-only
import { computed } from 'vue';
import FormSuspense from '@/components/form/suspense.vue';
import MkKeyValue from '@/components/MkKeyValue.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import bytes from '@/filters/bytes.js';
import number from '@/filters/number.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
const databasePromiseFactory = () => os.api('admin/get-table-stats').then(res => Object.entries(res).sort((a, b) => b[1].size - a[1].size));
const databasePromiseFactory = () => misskeyApi('admin/get-table-stats').then(res => Object.entries(res).sort((a, b) => b[1].size - a[1].size));
const headerActions = computed(() => []);

View File

@ -73,6 +73,7 @@ import FormSuspense from '@/components/form/suspense.vue';
import FormSplit from '@/components/form/split.vue';
import FormSection from '@/components/form/section.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { fetchInstance, instance } from '@/instance.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -87,7 +88,7 @@ const smtpUser = ref<string>('');
const smtpPass = ref<string>('');
async function init() {
const meta = await os.api('admin/meta');
const meta = await misskeyApi('admin/meta');
enableEmail.value = meta.enableEmail;
email.value = meta.email;
smtpSecure.value = meta.smtpSecure;

View File

@ -42,6 +42,7 @@ import MkSwitch from '@/components/MkSwitch.vue';
import FormSuspense from '@/components/form/suspense.vue';
import FormSection from '@/components/form/section.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { fetchInstance } from '@/instance.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -50,7 +51,7 @@ const deeplAuthKey = ref<string>('');
const deeplIsPro = ref<boolean>(false);
async function init() {
const meta = await os.api('admin/meta');
const meta = await misskeyApi('admin/meta');
deeplAuthKey.value = meta.deeplAuthKey;
deeplIsPro.value = meta.deeplIsPro;
}

View File

@ -42,6 +42,7 @@ import MkInput from '@/components/MkInput.vue';
import MkSelect from '@/components/MkSelect.vue';
import MkFileListForAdmin from '@/components/MkFileListForAdmin.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -83,7 +84,7 @@ async function find() {
});
if (canceled) return;
os.api('admin/drive/show-file', q.startsWith('http://') || q.startsWith('https://') ? { url: q.trim() } : { fileId: q.trim() }).then(file => {
misskeyApi('admin/drive/show-file', q.startsWith('http://') || q.startsWith('https://') ? { url: q.trim() } : { fileId: q.trim() }).then(file => {
show(file);
}).catch(err => {
if (err.code === 'NO_SUCH_FILE') {

View File

@ -34,6 +34,7 @@ import MkSuperMenu from '@/components/MkSuperMenu.vue';
import MkInfo from '@/components/MkInfo.vue';
import { instance } from '@/instance.js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { lookupUser, lookupUserByEmail } from '@/scripts/lookup-user.js';
import { useRouter } from '@/router.js';
import { PageMetadata, definePageMetadata, provideMetadataReceiver } from '@/scripts/page-metadata.js';
@ -76,7 +77,7 @@ watch(darkMode, () => {
iconUrl.value = iconLight;
}
})
os.api('admin/abuse-user-reports', {
misskeyApi('admin/abuse-user-reports', {
state: 'unresolved',
limit: 1,
}).then(reports => {
@ -280,7 +281,7 @@ provideMetadataReceiver((info) => {
});
function invite() {
os.api('admin/invite/create').then(x => {
misskeyApi('admin/invite/create').then(x => {
os.alert({
type: 'info',
text: x[0].code,

View File

@ -31,6 +31,7 @@ import MkButton from '@/components/MkButton.vue';
import MkTextarea from '@/components/MkTextarea.vue';
import FormSuspense from '@/components/form/suspense.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { fetchInstance } from '@/instance.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -42,7 +43,7 @@ const silencedHosts = ref<string>('');
const tab = ref('block');
async function init() {
const meta = await os.api('admin/meta');
const meta = await misskeyApi('admin/meta');
blockedHosts.value = meta.blockedHosts ? meta.blockedHosts.join('\n') : '';
silencedHosts.value = meta.silencedHosts ? meta.silencedHosts.join('\n') : '';
}

View File

@ -59,6 +59,7 @@ import { computed, ref, shallowRef } from 'vue';
import XHeader from './_header_.vue';
import { i18n } from '@/i18n.js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import MkButton from '@/components/MkButton.vue';
import MkFolder from '@/components/MkFolder.vue';
import MkSelect from '@/components/MkSelect.vue';
@ -93,14 +94,14 @@ async function createWithOptions() {
count: createCount.value,
};
const tickets = await os.api('admin/invite/create', options);
const tickets = await misskeyApi('admin/invite/create', options);
os.alert({
type: 'success',
title: i18n.ts.inviteCodeCreated,
text: tickets?.map(x => x.code).join('\n'),
text: tickets.map(x => x.code).join('\n'),
});
tickets?.forEach(ticket => pagingComponent.value?.prepend(ticket));
tickets.forEach(ticket => pagingComponent.value?.prepend(ticket));
}
function deleted(id: string) {

View File

@ -66,6 +66,7 @@ import MkInput from '@/components/MkInput.vue';
import MkTextarea from '@/components/MkTextarea.vue';
import FormSuspense from '@/components/form/suspense.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { fetchInstance } from '@/instance.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -81,7 +82,7 @@ const tosUrl = ref<string | null>(null);
const privacyPolicyUrl = ref<string | null>(null);
async function init() {
const meta = await os.api('admin/meta');
const meta = await misskeyApi('admin/meta');
enableRegistration.value = !meta.disableRegistration;
emailRequiredForSignup.value = meta.emailRequiredForSignup;
sensitiveWords.value = meta.sensitiveWords.join('\n');

View File

@ -90,6 +90,7 @@ import MkInput from '@/components/MkInput.vue';
import FormSuspense from '@/components/form/suspense.vue';
import FormSplit from '@/components/form/split.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { fetchInstance } from '@/instance.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -110,7 +111,7 @@ const objectStorageSetPublicRead = ref<boolean>(false);
const objectStorageS3ForcePathStyle = ref<boolean>(true);
async function init() {
const meta = await os.api('admin/meta');
const meta = await misskeyApi('admin/meta');
useObjectStorage.value = meta.useObjectStorage;
objectStorageBaseUrl.value = meta.objectStorageBaseUrl;
objectStorageBucket.value = meta.objectStorageBucket;

View File

@ -62,6 +62,7 @@ import { ref, computed } from 'vue';
import XHeader from './_header_.vue';
import FormSuspense from '@/components/form/suspense.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { fetchInstance } from '@/instance.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -77,7 +78,7 @@ let DiscordWebhookUrl = ref(null);
let EmojiBotToken= ref(null);
let ApiBase= ref(null)
async function init() {
const meta = await os.api('admin/meta');
const meta = await misskeyApi('admin/meta');
enableServerMachineStats.value = meta.enableServerMachineStats;
enableIdenticonGeneration.value = meta.enableIdenticonGeneration;
enableChartsForRemoteUser.value = meta.enableChartsForRemoteUser;

View File

@ -16,7 +16,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { onMounted, shallowRef, ref } from 'vue';
import { Chart } from 'chart.js';
import gradient from 'chartjs-plugin-gradient';
import * as os from '@/os.js';
import { misskeyApi } 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';
@ -52,7 +52,7 @@ async function renderChart() {
}));
};
const raw = await os.api('charts/active-users', { limit: chartLimit, span: 'day' });
const raw = await misskeyApi('charts/active-users', { limit: chartLimit, span: 'day' });
const vLineColor = defaultStore.state.darkMode ? 'rgba(255, 255, 255, 0.2)' : 'rgba(0, 0, 0, 0.2)';

View File

@ -23,7 +23,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { onMounted, shallowRef, ref } from 'vue';
import { Chart } from 'chart.js';
import gradient from 'chartjs-plugin-gradient';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { useChartTooltip } from '@/scripts/use-chart-tooltip.js';
import { chartVLine } from '@/scripts/chart-vline.js';
import { defaultStore } from '@/store.js';
@ -65,7 +65,7 @@ onMounted(async () => {
}));
};
const raw = await os.api('charts/ap-request', { limit: chartLimit, span: 'day' });
const raw = await misskeyApi('charts/ap-request', { limit: chartLimit, span: 'day' });
const vLineColor = defaultStore.state.darkMode ? 'rgba(255, 255, 255, 0.2)' : 'rgba(0, 0, 0, 0.2)';
const succColor = '#87e000';

View File

@ -49,6 +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 number from '@/filters/number.js';
import MkNumberDiff from '@/components/MkNumberDiff.vue';
import { i18n } from '@/i18n.js';
@ -65,13 +66,13 @@ const fetching = ref(true);
const { handler: externalTooltipHandler } = useChartTooltip();
onMounted(async () => {
const chart = await os.apiGet('charts/federation', { limit: 2, span: 'day' });
const chart = await misskeyApiGet('charts/federation', { limit: 2, span: 'day' });
federationPubActive.value = chart.pubActive[0];
federationPubActiveDiff.value = chart.pubActive[0] - chart.pubActive[1];
federationSubActive.value = chart.subActive[0];
federationSubActiveDiff.value = chart.subActive[0] - chart.subActive[1];
os.apiGet('federation/stats', { limit: 10 }).then(res => {
misskeyApiGet('federation/stats', { limit: 10 }).then(res => {
topSubInstancesForPie.value = [
...res.topSubInstances.map(x => ({
name: x.host,

View File

@ -18,8 +18,8 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import { ref } from 'vue';
import { misskeyApi } from '@/scripts/misskey-api.js';
import * as Misskey from 'misskey-js';
import * as os from '@/os.js';
import { useInterval } from '@/scripts/use-interval.js';
import MkInstanceCardMini from '@/components/MkInstanceCardMini.vue';
import { defaultStore } from '@/store.js';
@ -28,7 +28,7 @@ const instances = ref<Misskey.entities.FederationInstance[]>([]);
const fetching = ref(true);
const fetch = async () => {
const fetchedInstances = await os.api('federation/instances', {
const fetchedInstances = await misskeyApi('federation/instances', {
sort: '+latestRequestReceivedAt',
limit: 6,
});

View File

@ -18,15 +18,15 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import { onMounted, ref } from 'vue';
import { misskeyApi } from '@/scripts/misskey-api.js';
import * as Misskey from 'misskey-js';
import * as os from '@/os.js';
import { defaultStore } from '@/store.js';
const moderators = ref<Misskey.entities.UserDetailed[] | null>(null);
const fetching = ref(true);
onMounted(async () => {
moderators.value = await os.api('admin/show-users', {
moderators.value = await misskeyApi('admin/show-users', {
sort: '+lastActiveDate',
state: 'adminOrModerator',
limit: 30,

View File

@ -63,7 +63,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import { onMounted, ref } from 'vue';
import * as Misskey from 'misskey-js';
import * as os from '@/os.js';
import { misskeyApi, misskeyApiGet } from '@/scripts/misskey-api.js';
import MkNumberDiff from '@/components/MkNumberDiff.vue';
import MkNumber from '@/components/MkNumber.vue';
import { i18n } from '@/i18n.js';
@ -78,17 +78,17 @@ const fetching = ref(true);
onMounted(async () => {
const [_stats, _onlineUsersCount] = await Promise.all([
os.api('stats', {}),
os.apiGet('get-online-users-count').then(res => res.count),
misskeyApi('stats', {}),
misskeyApiGet('get-online-users-count').then(res => res.count),
]);
stats.value = _stats;
onlineUsersCount.value = _onlineUsersCount;
os.apiGet('charts/users', { limit: 2, span: 'day' }).then(chart => {
misskeyApiGet('charts/users', { limit: 2, span: 'day' }).then(chart => {
usersComparedToThePrevDay.value = stats.value.originalUsersCount - chart.local.total[1];
});
os.apiGet('charts/notes', { limit: 2, span: 'day' }).then(chart => {
misskeyApiGet('charts/notes', { limit: 2, span: 'day' }).then(chart => {
notesComparedToThePrevDay.value = stats.value.originalNotesCount - chart.local.total[1];
});

View File

@ -18,8 +18,8 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import { ref } from 'vue';
import { misskeyApi } from '@/scripts/misskey-api.js';
import * as Misskey from 'misskey-js';
import * as os from '@/os.js';
import { useInterval } from '@/scripts/use-interval.js';
import MkUserCardMini from '@/components/MkUserCardMini.vue';
import { defaultStore } from '@/store.js';
@ -28,7 +28,7 @@ const newUsers = ref<Misskey.entities.UserDetailed[] | null>(null);
const fetching = ref(true);
const fetch = async () => {
const _newUsers = await os.api('admin/show-users', {
const _newUsers = await misskeyApi('admin/show-users', {
limit: 5,
sort: '+createdAt',
origin: 'local',

View File

@ -79,6 +79,7 @@ import XModerators from './overview.moderators.vue';
import XHeatmap from './overview.heatmap.vue';
import type { InstanceForPie } from './overview.pie.vue';
import * as os from '@/os.js';
import { misskeyApi, misskeyApiGet } from '@/scripts/misskey-api.js';
import { useStream } from '@/stream.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -117,14 +118,14 @@ onMounted(async () => {
magicGrid.listen();
*/
os.apiGet('charts/federation', { limit: 2, span: 'day' }).then(chart => {
misskeyApiGet('charts/federation', { limit: 2, span: 'day' }).then(chart => {
federationPubActive.value = chart.pubActive[0];
federationPubActiveDiff.value = chart.pubActive[0] - chart.pubActive[1];
federationSubActive.value = chart.subActive[0];
federationSubActiveDiff.value = chart.subActive[0] - chart.subActive[1];
});
os.apiGet('federation/stats', { limit: 10 }).then(res => {
misskeyApiGet('federation/stats', { limit: 10 }).then(res => {
topSubInstancesForPie.value = [
...res.topSubInstances.map(x => ({
name: x.host,
@ -149,18 +150,18 @@ onMounted(async () => {
];
});
os.api('admin/server-info').then(serverInfoResponse => {
misskeyApi('admin/server-info').then(serverInfoResponse => {
serverInfo.value = serverInfoResponse;
});
os.api('admin/show-users', {
misskeyApi('admin/show-users', {
limit: 5,
sort: '+createdAt',
}).then(res => {
newUsers.value = res;
});
os.api('federation/instances', {
misskeyApi('federation/instances', {
sort: '+latestRequestReceivedAt',
limit: 25,
}).then(res => {

View File

@ -28,6 +28,7 @@ import MkButton from '@/components/MkButton.vue';
import MkInfo from '@/components/MkInfo.vue';
import FormSuspense from '@/components/form/suspense.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { fetchInstance } from '@/instance.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -36,10 +37,10 @@ const proxyAccount = ref<Misskey.entities.UserDetailed | null>(null);
const proxyAccountId = ref<string | null>(null);
async function init() {
const meta = await os.api('admin/meta');
const meta = await misskeyApi('admin/meta');
proxyAccountId.value = meta.proxyAccountId;
if (proxyAccountId.value) {
proxyAccount.value = await os.api('users/show', { userId: proxyAccountId.value });
proxyAccount.value = await misskeyApi('users/show', { userId: proxyAccountId.value });
}
}

View File

@ -51,7 +51,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { markRaw, onMounted, onUnmounted, ref, shallowRef } from 'vue';
import XChart from './queue.chart.chart.vue';
import number from '@/filters/number.js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { useStream } from '@/stream.js';
import { i18n } from '@/i18n.js';
import MkFolder from '@/components/MkFolder.vue';
@ -105,7 +105,7 @@ const onStatsLog = (statsLog) => {
onMounted(() => {
if (props.domain === 'inbox' || props.domain === 'deliver') {
os.api(`admin/queue/${props.domain}-delayed`).then(result => {
misskeyApi(`admin/queue/${props.domain}-delayed`).then(result => {
jobs.value = result;
});
}

View File

@ -29,6 +29,7 @@ import * as Misskey from 'misskey-js';
import XHeader from './_header_.vue';
import MkButton from '@/components/MkButton.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -41,7 +42,7 @@ async function addRelay() {
placeholder: i18n.ts.inboxUrl,
});
if (canceled) return;
os.api('admin/relays/add', {
misskeyApi('admin/relays/add', {
inbox,
}).then((relay: any) => {
refresh();
@ -54,7 +55,7 @@ async function addRelay() {
}
function remove(inbox: string) {
os.api('admin/relays/remove', {
misskeyApi('admin/relays/remove', {
inbox,
}).then(() => {
refresh();
@ -67,7 +68,7 @@ function remove(inbox: string) {
}
function refresh() {
os.api('admin/relays/list').then(relayList => {
misskeyApi('admin/relays/list').then(relayList => {
relays.value = relayList;
});
}

View File

@ -28,6 +28,7 @@ import { v4 as uuid } from 'uuid';
import XHeader from './_header_.vue';
import XEditor from './roles.editor.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
import { useRouter } from '@/router.js';
@ -44,7 +45,7 @@ const role = ref<Misskey.entities.Role | null>(null);
const data = ref<any>(null);
if (props.id) {
role.value = await os.api('admin/roles/show', {
role.value = await misskeyApi('admin/roles/show', {
roleId: props.id,
});

View File

@ -67,6 +67,7 @@ import XHeader from './_header_.vue';
import XEditor from './roles.editor.vue';
import MkFolder from '@/components/MkFolder.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
import { useRouter } from '@/router.js';
@ -92,7 +93,7 @@ const usersPagination = {
const expandedItems = ref([]);
const role = reactive(await os.api('admin/roles/show', {
const role = reactive(await misskeyApi('admin/roles/show', {
roleId: props.id,
}));

View File

@ -257,6 +257,7 @@ import MkButton from '@/components/MkButton.vue';
import MkRange from '@/components/MkRange.vue';
import MkRolePreview from '@/components/MkRolePreview.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
import { instance } from '@/instance.js';
@ -267,7 +268,7 @@ import { ROLE_POLICIES } from '@/const.js';
const router = useRouter();
const baseRoleQ = ref('');
const roles = await os.api('admin/roles/list');
const roles = await misskeyApi('admin/roles/list');
const policies = reactive<Record<typeof ROLE_POLICIES[number], any>>({});
for (const ROLE_POLICY of ROLE_POLICIES) {

View File

@ -148,6 +148,7 @@ import MkInput from '@/components/MkInput.vue';
import MkButton from '@/components/MkButton.vue';
import MkTextarea from '@/components/MkTextarea.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { fetchInstance } from '@/instance.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -170,7 +171,7 @@ const truemailAuthKey = ref<string | null>(null);
const bannedEmailDomains = ref<string>('');
async function init() {
const meta = await os.api('admin/meta');
const meta = await misskeyApi('admin/meta');
summalyProxy.value = meta.summalyProxy;
enableHcaptcha.value = meta.enableHcaptcha;
enableRecaptcha.value = meta.enableRecaptcha;

View File

@ -158,6 +158,7 @@ import FormSection from '@/components/form/section.vue';
import FormSplit from '@/components/form/split.vue';
import FormSuspense from '@/components/form/suspense.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { fetchInstance } from '@/instance.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
@ -184,7 +185,7 @@ const perUserListTimelineCacheMax = ref<number>(0);
const notesPerOneAd = ref<number>(0);
async function init(): Promise<void> {
const meta = await os.api('admin/meta');
const meta = await misskeyApi('admin/meta');
name.value = meta.name;
shortName.value = meta.shortName;
description.value = meta.description;

View File

@ -45,6 +45,7 @@ import MkPagination from '@/components/MkPagination.vue';
import MkButton from '@/components/MkButton.vue';
import MkInfo from '@/components/MkInfo.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
import { $i, updateAccount } from '@/account.js';
@ -84,7 +85,7 @@ async function read(announcement) {
a.isRead = true;
return a;
});
os.api('i/read-announcement', { announcementId: announcement.id });
misskeyApi('i/read-announcement', { announcementId: announcement.id });
updateAccount({
unreadAnnouncements: $i!.unreadAnnouncements.filter(a => a.id !== announcement.id),
});

View File

@ -29,6 +29,7 @@ import * as Misskey from 'misskey-js';
import MkTimeline from '@/components/MkTimeline.vue';
import { scroll } from '@/scripts/scroll.js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { useRouter } from '@/router.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
import { i18n } from '@/i18n.js';
@ -73,7 +74,7 @@ function focus() {
}
watch(() => props.antennaId, async () => {
antenna.value = await os.api('antennas/show', {
antenna.value = await misskeyApi('antennas/show', {
antennaId: props.antennaId,
});
}, { immediate: true });

View File

@ -41,7 +41,7 @@ import MkButton from '@/components/MkButton.vue';
import MkInput from '@/components/MkInput.vue';
import MkTextarea from '@/components/MkTextarea.vue';
import MkSwitch from '@/components/MkSwitch.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
const body = ref('{}');
@ -51,14 +51,14 @@ const sending = ref(false);
const res = ref('');
const withCredential = ref(true);
os.api('endpoints').then(endpointResponse => {
misskeyApi('endpoints').then(endpointResponse => {
endpoints.value = endpointResponse;
});
function send() {
sending.value = true;
const requestBody = JSON5.parse(body.value);
os.api(endpoint.value as keyof Endpoints, requestBody, requestBody.i || (withCredential.value ? undefined : null)).then(resp => {
misskeyApi(endpoint.value as keyof Endpoints, requestBody, requestBody.i || (withCredential.value ? undefined : null)).then(resp => {
sending.value = false;
res.value = JSON5.stringify(resp, null, 2);
}, err => {
@ -68,7 +68,7 @@ function send() {
}
function onEndpointChange() {
os.api('endpoint', { endpoint: endpoint.value }, withCredential.value ? undefined : null).then(resp => {
misskeyApi('endpoint', { endpoint: endpoint.value }, withCredential.value ? undefined : null).then(resp => {
const endpointBody = {};
for (const p of resp.params) {
endpointBody[p.name] =

View File

@ -23,7 +23,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { computed } from 'vue';
import * as Misskey from 'misskey-js';
import MkButton from '@/components/MkButton.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
const props = defineProps<{
@ -44,7 +44,7 @@ const name = computed(() => {
});
function cancel() {
os.api('auth/deny', {
misskeyApi('auth/deny', {
token: props.session.token,
}).then(() => {
emit('denied');
@ -52,7 +52,7 @@ function cancel() {
}
function accept() {
os.api('auth/accept', {
misskeyApi('auth/accept', {
token: props.session.token,
}).then(() => {
emit('accepted');

View File

@ -46,7 +46,7 @@ import { onMounted, ref, computed } from 'vue';
import * as Misskey from 'misskey-js';
import XForm from './auth.form.vue';
import MkSignin from '@/components/MkSignin.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { $i, login } from '@/account.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
import { i18n } from '@/i18n.js';
@ -75,13 +75,13 @@ onMounted(async () => {
if (!$i) return;
try {
session.value = await os.api('auth/session/show', {
session.value = await misskeyApi('auth/session/show', {
token: props.token,
});
//
if (session.value.app.isAuthorized) {
await os.api('auth/accept', {
await misskeyApi('auth/accept', {
token: session.value.token,
});
accepted();

Some files were not shown because too many files have changed in this diff Show More