@ -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;
|
||||
|
21
src/remote/activitypub/kernel/undo/like.ts
Normal file
21
src/remote/activitypub/kernel/undo/like.ts
Normal 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);
|
||||
};
|
Reference in New Issue
Block a user