AP Undo Like (#3933)

* AP Undo Like

* rename
This commit is contained in:
MeiMei
2019-01-20 03:07:12 +09:00
committed by syuilo
parent fa07b3023c
commit 22830965e3
6 changed files with 117 additions and 67 deletions

View File

@ -1,9 +1,10 @@
import * as debug from 'debug';
import { IRemoteUser } from '../../../../models/user';
import { IUndo, IFollow, IBlock } from '../../type';
import { IUndo, IFollow, IBlock, ILike } from '../../type';
import unfollow from './follow';
import unblock from './block';
import undoLike from './like';
import Resolver from '../../resolver';
const log = debug('misskey:activitypub');
@ -35,6 +36,9 @@ export default async (actor: IRemoteUser, activity: IUndo): Promise<void> => {
case 'Block':
unblock(actor, object as IBlock);
break;
case 'Like':
undoLike(actor, object as ILike);
break;
}
return null;

View File

@ -0,0 +1,21 @@
import * as mongo from 'mongodb';
import { IRemoteUser } from '../../../../models/user';
import { ILike } from '../../type';
import Note from '../../../../models/note';
import deleteReaction from '../../../../services/note/reaction/delete';
/**
* Process Undo.Like activity
*/
export default async (actor: IRemoteUser, activity: ILike): Promise<void> => {
const id = typeof activity.object == 'string' ? activity.object : activity.object.id;
const noteId = new mongo.ObjectID(id.split('/').pop());
const note = await Note.findOne({ _id: noteId });
if (note === null) {
throw 'note not found';
}
await deleteReaction(actor, note);
};