2018-04-04 13:29:06 +03:00
|
|
|
import Post from '../../../models/post';
|
2018-04-07 11:05:14 +03:00
|
|
|
import { IRemoteUser } from '../../../models/user';
|
|
|
|
import { ILike } from '../type';
|
|
|
|
import create from '../../../services/post/reaction/create';
|
2018-04-04 13:29:06 +03:00
|
|
|
|
2018-04-07 11:05:14 +03:00
|
|
|
export default async (actor: IRemoteUser, activity: ILike) => {
|
|
|
|
const id = typeof activity.object == 'string' ? activity.object : activity.object.id;
|
2018-04-04 13:29:06 +03:00
|
|
|
|
|
|
|
// Transform:
|
|
|
|
// https://misskey.ex/@syuilo/xxxx to
|
|
|
|
// xxxx
|
|
|
|
const postId = id.split('/').pop();
|
|
|
|
|
|
|
|
const post = await Post.findOne({ _id: postId });
|
|
|
|
if (post === null) {
|
|
|
|
throw new Error();
|
|
|
|
}
|
|
|
|
|
2018-04-07 11:05:14 +03:00
|
|
|
await create(actor, post, 'pudding');
|
2018-04-04 13:29:06 +03:00
|
|
|
};
|