apiFetch => cli
This commit is contained in:
parent
06207e56cd
commit
5696781a8c
2 changed files with 4 additions and 4 deletions
|
@ -8,7 +8,7 @@ import getUserName from '@/misc/get-user-name';
|
||||||
import { swLang } from '@client/sw/lang';
|
import { swLang } from '@client/sw/lang';
|
||||||
import { I18n } from '@/misc/i18n';
|
import { I18n } from '@/misc/i18n';
|
||||||
import { pushNotificationDataMap } from '@client/sw/types';
|
import { pushNotificationDataMap } from '@client/sw/types';
|
||||||
import { apiFetch } from './operations';
|
import { cli } from './operations';
|
||||||
import { getAccountFromId } from '@client/scripts/get-account-from-id';
|
import { getAccountFromId } from '@client/scripts/get-account-from-id';
|
||||||
|
|
||||||
export async function createNotification<K extends keyof pushNotificationDataMap>(data: pushNotificationDataMap[K]) {
|
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を直接使用
|
// users/showの型定義をswos.apiへ当てはめるのが困難なのでapiFetch.requestを直接使用
|
||||||
const account = await getAccountFromId(data.userId);
|
const account = await getAccountFromId(data.userId);
|
||||||
if (!account) return null;
|
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'), {
|
return [t('_notification.youWereFollowed'), {
|
||||||
body: getUserName(data.body.user),
|
body: getUserName(data.body.user),
|
||||||
icon: data.body.user.avatarUrl,
|
icon: data.body.user.avatarUrl,
|
||||||
|
|
|
@ -10,13 +10,13 @@ import { getAcct } from '@/misc/acct';
|
||||||
import { getAccountFromId } from '@client/scripts/get-account-from-id';
|
import { getAccountFromId } from '@client/scripts/get-account-from-id';
|
||||||
import { appendLoginId } from '@client/scripts/login-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']) {
|
export async function api<E extends keyof Misskey.Endpoints>(endpoint: E, userId: string, options?: Misskey.Endpoints[E]['req']) {
|
||||||
const account = await getAccountFromId(userId);
|
const account = await getAccountFromId(userId);
|
||||||
if (!account) return;
|
if (!account) return;
|
||||||
|
|
||||||
return apiFetch.request(endpoint, options, account.token);
|
return cli.request(endpoint, options, account.token);
|
||||||
}
|
}
|
||||||
|
|
||||||
// rendered acctからユーザーを開く
|
// rendered acctからユーザーを開く
|
||||||
|
|
Loading…
Reference in a new issue