mirror of
https://github.com/paricafe/misskey.git
synced 2025-01-17 19:10:49 -06:00
fix ap type.ts
This commit is contained in:
parent
5c86549456
commit
e19373ea90
4 changed files with 25 additions and 4 deletions
|
@ -3,6 +3,8 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { fromTuple } from '@/misc/from-tuple.js';
|
||||
|
||||
export type Obj = { [x: string]: any };
|
||||
export type ApObject = IObject | string | (IObject | string)[];
|
||||
|
||||
|
@ -11,7 +13,7 @@ export interface IObject {
|
|||
type: string | string[];
|
||||
id?: string;
|
||||
name?: string | null;
|
||||
summary?: string;
|
||||
summary?: string | null;
|
||||
_misskey_summary?: string;
|
||||
_misskey_followedMessage?: string | null;
|
||||
_misskey_requireSigninToViewContents?: boolean;
|
||||
|
@ -57,10 +59,13 @@ export function getOneApId(value: ApObject): string {
|
|||
/**
|
||||
* Get ActivityStreams Object id
|
||||
*/
|
||||
export function getApId(value: string | IObject): string {
|
||||
export function getApId(value: string | IObject | [string | IObject]): string {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
value = fromTuple(value);
|
||||
|
||||
if (typeof value === 'string') return value;
|
||||
if (typeof value.id === 'string') return value.id;
|
||||
throw new Error('cannot detemine id');
|
||||
throw new Error('cannot determine id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,7 +94,9 @@ export function getApHrefNullable(value: string | IObject | undefined): string |
|
|||
export interface IActivity extends IObject {
|
||||
//type: 'Activity';
|
||||
actor: IObject | string;
|
||||
object: IObject | string;
|
||||
// ActivityPub spec allows for arrays: https://www.w3.org/TR/activitystreams-vocabulary/#properties
|
||||
// Misskey can only handle one value, so we use a tuple for that case.
|
||||
object: IObject | string | [IObject | string] ;
|
||||
target?: IObject | string;
|
||||
/** LD-Signature */
|
||||
signature?: {
|
||||
|
@ -132,6 +139,8 @@ export interface IPost extends IObject {
|
|||
_misskey_quote?: string;
|
||||
_misskey_content?: string;
|
||||
quoteUrl?: string;
|
||||
quoteUri?: string;
|
||||
updated?: string;
|
||||
}
|
||||
|
||||
export interface IQuestion extends IObject {
|
||||
|
@ -143,6 +152,7 @@ export interface IQuestion extends IObject {
|
|||
};
|
||||
_misskey_quote?: string;
|
||||
quoteUrl?: string;
|
||||
quoteUri?: string;
|
||||
oneOf?: IQuestionChoice[];
|
||||
anyOf?: IQuestionChoice[];
|
||||
endTime?: Date;
|
||||
|
|
7
packages/backend/src/misc/from-tuple.ts
Normal file
7
packages/backend/src/misc/from-tuple.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
export function fromTuple<T>(value: T | [T]): T {
|
||||
if (Array.isArray(value)) {
|
||||
return value[0];
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
|
@ -336,6 +336,7 @@ import type {
|
|||
IGalleryPostsResponse,
|
||||
IImportBlockingRequest,
|
||||
IImportFollowingRequest,
|
||||
IImportNotesRequest,
|
||||
IImportMutingRequest,
|
||||
IImportUserListsRequest,
|
||||
IImportAntennasRequest,
|
||||
|
@ -796,6 +797,7 @@ export type Endpoints = {
|
|||
'i/claim-achievement': { req: IClaimAchievementRequest; res: EmptyResponse };
|
||||
'i/change-password': { req: IChangePasswordRequest; res: EmptyResponse };
|
||||
'i/delete-account': { req: IDeleteAccountRequest; res: EmptyResponse };
|
||||
'i/export-data': { req: EmptyRequest; res: EmptyResponse };
|
||||
'i/export-blocking': { req: EmptyRequest; res: EmptyResponse };
|
||||
'i/export-following': { req: IExportFollowingRequest; res: EmptyResponse };
|
||||
'i/export-mute': { req: EmptyRequest; res: EmptyResponse };
|
||||
|
@ -809,6 +811,7 @@ export type Endpoints = {
|
|||
'i/gallery/posts': { req: IGalleryPostsRequest; res: IGalleryPostsResponse };
|
||||
'i/import-blocking': { req: IImportBlockingRequest; res: EmptyResponse };
|
||||
'i/import-following': { req: IImportFollowingRequest; res: EmptyResponse };
|
||||
'i/import-notes': { req: IImportNotesRequest; res: EmptyResponse };
|
||||
'i/import-muting': { req: IImportMutingRequest; res: EmptyResponse };
|
||||
'i/import-user-lists': { req: IImportUserListsRequest; res: EmptyResponse };
|
||||
'i/import-antennas': { req: IImportAntennasRequest; res: EmptyResponse };
|
||||
|
|
|
@ -339,6 +339,7 @@ export type IGalleryPostsRequest = operations['i___gallery___posts']['requestBod
|
|||
export type IGalleryPostsResponse = operations['i___gallery___posts']['responses']['200']['content']['application/json'];
|
||||
export type IImportBlockingRequest = operations['i___import-blocking']['requestBody']['content']['application/json'];
|
||||
export type IImportFollowingRequest = operations['i___import-following']['requestBody']['content']['application/json'];
|
||||
export type IImportNotesRequest = operations['i___import-notes']['requestBody']['content']['application/json'];
|
||||
export type IImportMutingRequest = operations['i___import-muting']['requestBody']['content']['application/json'];
|
||||
export type IImportUserListsRequest = operations['i___import-user-lists']['requestBody']['content']['application/json'];
|
||||
export type IImportAntennasRequest = operations['i___import-antennas']['requestBody']['content']['application/json'];
|
||||
|
|
Loading…
Reference in a new issue