Fix: AP object / actor type (#5086)

* attributedToがArrayの場合などに対応

* attachment以外で来るDocument系のObjectに対応

* Renote, Reply 対応

* 表示をいい感じに

* fix type

* revert as const

* Fix Note / Question type

* attributedToのtypeで複合配列を想定する
This commit is contained in:
MeiMei
2019-06-28 18:54:10 +09:00
committed by syuilo
parent a8379e3bc9
commit 0141affe05
10 changed files with 86 additions and 87 deletions

View File

@@ -1,9 +1,8 @@
import Resolver from '../../resolver';
import deleteNote from './note';
import { IRemoteUser } from '../../../../models/entities/user';
import { IDelete } from '../../type';
import { IDelete, getApId, validPost } from '../../type';
import { apLogger } from '../../logger';
import { Notes } from '../../../../models';
/**
* 削除アクティビティを捌きます
@@ -17,24 +16,11 @@ export default async (actor: IRemoteUser, activity: IDelete): Promise<void> => {
const object = await resolver.resolve(activity.object);
const uri = (object as any).id;
const uri = getApId(object);
switch (object.type) {
case 'Note':
case 'Question':
case 'Article':
deleteNote(actor, uri);
break;
case 'Tombstone':
const note = await Notes.findOne({ uri });
if (note != null) {
deleteNote(actor, uri);
}
break;
default:
apLogger.warn(`Unknown type: ${object.type}`);
break;
if (validPost.includes(object.type) || object.type === 'Tombstone') {
deleteNote(actor, uri);
} else {
apLogger.warn(`Unknown type: ${object.type}`);
}
};