From 1181fcdcebad0f3a8538ae6d10d70e6f7ea9468b Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 13 Apr 2019 18:58:29 +0900 Subject: [PATCH] Fix bug --- src/misc/reaction-lib.ts | 2 +- src/remote/activitypub/models/note.ts | 2 +- src/remote/activitypub/type.ts | 16 ++++++++-------- src/services/note/reaction/create.ts | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/misc/reaction-lib.ts b/src/misc/reaction-lib.ts index 20051f0280..008991454b 100644 --- a/src/misc/reaction-lib.ts +++ b/src/misc/reaction-lib.ts @@ -20,7 +20,7 @@ export async function getFallbackReaction(): Promise { return meta.useStarForReactionFallback ? 'star' : 'like'; } -export async function toDbReaction(reaction: string, enableEmoji = true): Promise { +export async function toDbReaction(reaction?: string | null, enableEmoji = true): Promise { if (reaction == null) return await getFallbackReaction(); // 既存の文字列リアクションはそのまま diff --git a/src/remote/activitypub/models/note.ts b/src/remote/activitypub/models/note.ts index 9ed2fd641c..c11a77b0fe 100644 --- a/src/remote/activitypub/models/note.ts +++ b/src/remote/activitypub/models/note.ts @@ -152,7 +152,7 @@ export async function createNote(value: any, resolver?: Resolver, silent = false const cw = note.summary === '' ? null : note.summary; // テキストのパース - const text = note._misskey_content || fromHtml(note.content); + const text = note._misskey_content || (note.content ? fromHtml(note.content) : null); // vote if (reply && reply.hasPoll) { diff --git a/src/remote/activitypub/type.ts b/src/remote/activitypub/type.ts index 7e81a7cc4c..95c69fb8ac 100644 --- a/src/remote/activitypub/type.ts +++ b/src/remote/activitypub/type.ts @@ -12,7 +12,7 @@ export interface IObject { attachment?: any[]; inReplyTo?: any; replies?: ICollection; - content: string; + content?: string; name?: string; startTime?: Date; endTime?: Date; @@ -44,16 +44,16 @@ export interface IOrderedCollection extends IObject { export interface INote extends IObject { type: 'Note' | 'Question'; - _misskey_content: string; - _misskey_quote: string; - _misskey_question: string; + _misskey_content?: string; + _misskey_quote?: string; + _misskey_question?: string; } export interface IQuestion extends IObject { type: 'Note' | 'Question'; - _misskey_content: string; - _misskey_quote: string; - _misskey_question: string; + _misskey_content?: string; + _misskey_quote?: string; + _misskey_question?: string; oneOf?: IQuestionChoice[]; anyOf?: IQuestionChoice[]; endTime?: Date; @@ -129,7 +129,7 @@ export interface IRemove extends IActivity { export interface ILike extends IActivity { type: 'Like'; - _misskey_reaction: string; + _misskey_reaction?: string; } export interface IAnnounce extends IActivity { diff --git a/src/services/note/reaction/create.ts b/src/services/note/reaction/create.ts index ea2108430a..6db210ea6d 100644 --- a/src/services/note/reaction/create.ts +++ b/src/services/note/reaction/create.ts @@ -16,7 +16,7 @@ import { NoteReaction } from '../../../models/entities/note-reaction'; import { createNotification } from '../../create-notification'; import { isDuplicateKeyValueError } from '../../../misc/is-duplicate-key-value-error'; -export default async (user: User, note: Note, reaction: string) => { +export default async (user: User, note: Note, reaction?: string) => { // Myself if (note.userId === user.id) { throw new IdentifiableError('2d8e7297-1873-4c00-8404-792c68d7bef0', 'cannot react to my note');