apiFetch => cli

This commit is contained in:
tamaina 2021-09-21 03:35:44 +09:00
parent 06207e56cd
commit 5696781a8c
2 changed files with 4 additions and 4 deletions

View file

@ -8,7 +8,7 @@ import getUserName from '@/misc/get-user-name';
import { swLang } from '@client/sw/lang';
import { I18n } from '@/misc/i18n';
import { pushNotificationDataMap } from '@client/sw/types';
import { apiFetch } from './operations';
import { cli } from './operations';
import { getAccountFromId } from '@client/scripts/get-account-from-id';
export async function createNotification<K extends keyof pushNotificationDataMap>(data: pushNotificationDataMap[K]) {
@ -41,7 +41,7 @@ async function composeNotification<K extends keyof pushNotificationDataMap>(data
// users/showの型定義をswos.apiへ当てはめるのが困難なのでapiFetch.requestを直接使用
const account = await getAccountFromId(data.userId);
if (!account) return null;
const userDetail = apiFetch.request('users/show', { userId: data.body.userId }, account.token);
const userDetail = cli.request('users/show', { userId: data.body.userId }, account.token);
return [t('_notification.youWereFollowed'), {
body: getUserName(data.body.user),
icon: data.body.user.avatarUrl,

View file

@ -10,13 +10,13 @@ import { getAcct } from '@/misc/acct';
import { getAccountFromId } from '@client/scripts/get-account-from-id';
import { appendLoginId } from '@client/scripts/login-id';
export const apiFetch = new Misskey.api.APIClient({ origin });
export const cli = new Misskey.api.APIClient({ origin });
export async function api<E extends keyof Misskey.Endpoints>(endpoint: E, userId: string, options?: Misskey.Endpoints[E]['req']) {
const account = await getAccountFromId(userId);
if (!account) return;
return apiFetch.request(endpoint, options, account.token);
return cli.request(endpoint, options, account.token);
}
// rendered acctからユーザーを開く