Supports Array ActivityStreams type (#7536)

* Supports Array type

* Fix

* Fix Service to Note

* Update type.ts

Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
This commit is contained in:
MeiMei
2021-05-31 13:04:13 +09:00
committed by GitHub
parent b608f63a1a
commit caf40e40fb
10 changed files with 76 additions and 82 deletions

View File

@@ -1,5 +1,5 @@
import { IRemoteUser } from '../../../../models/entities/user';
import { IUndo, IFollow, IBlock, ILike, IAnnounce } from '../../type';
import { IUndo, isFollow, isBlock, isLike, isAnnounce, getApType } from '../../type';
import unfollow from './follow';
import unblock from './block';
import undoLike from './like';
@@ -9,7 +9,7 @@ import { apLogger } from '../../logger';
const logger = apLogger;
export default async (actor: IRemoteUser, activity: IUndo): Promise<void> => {
export default async (actor: IRemoteUser, activity: IUndo): Promise<string> => {
if ('actor' in activity && actor.uri !== activity.actor) {
throw new Error('invalid actor');
}
@@ -25,20 +25,10 @@ export default async (actor: IRemoteUser, activity: IUndo): Promise<void> => {
throw e;
});
switch (object.type) {
case 'Follow':
unfollow(actor, object as IFollow);
break;
case 'Block':
unblock(actor, object as IBlock);
break;
case 'Like':
case 'EmojiReaction':
case 'EmojiReact':
undoLike(actor, object as ILike);
break;
case 'Announce':
undoAnnounce(actor, object as IAnnounce);
break;
}
if (isFollow(object)) return await unfollow(actor, object);
if (isBlock(object)) return await unblock(actor, object);
if (isLike(object)) return await undoLike(actor, object);
if (isAnnounce(object)) return await undoAnnounce(actor, object);
return `skip: unknown object type ${getApType(object)}`;
};