From 3348094e5fdddf694004ddec64d2fafec5f1b5e5 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 18 Apr 2018 14:09:55 +0900 Subject: [PATCH] Fix bug --- src/remote/activitypub/kernel/follow.ts | 5 ++++- src/remote/activitypub/kernel/like.ts | 3 ++- src/remote/activitypub/kernel/undo/follow.ts | 5 ++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/remote/activitypub/kernel/follow.ts b/src/remote/activitypub/kernel/follow.ts index 6a8b5a1be..7e31eb32e 100644 --- a/src/remote/activitypub/kernel/follow.ts +++ b/src/remote/activitypub/kernel/follow.ts @@ -1,3 +1,4 @@ +import * as mongo from 'mongodb'; import User, { IRemoteUser } from '../../../models/user'; import config from '../../../config'; import follow from '../../../services/following/create'; @@ -10,7 +11,9 @@ export default async (actor: IRemoteUser, activity: IFollow): Promise => { return null; } - const followee = await User.findOne({ _id: id.split('/').pop() }); + const followee = await User.findOne({ + _id: new mongo.ObjectID(id.split('/').pop()) + }); if (followee === null) { throw new Error('followee not found'); diff --git a/src/remote/activitypub/kernel/like.ts b/src/remote/activitypub/kernel/like.ts index 494160858..fc5d0a2f6 100644 --- a/src/remote/activitypub/kernel/like.ts +++ b/src/remote/activitypub/kernel/like.ts @@ -1,3 +1,4 @@ +import * as mongo from 'mongodb'; import Note from '../../../models/note'; import { IRemoteUser } from '../../../models/user'; import { ILike } from '../type'; @@ -9,7 +10,7 @@ export default async (actor: IRemoteUser, activity: ILike) => { // Transform: // https://misskey.ex/notes/xxxx to // xxxx - const noteId = id.split('/').pop(); + const noteId = new mongo.ObjectID(id.split('/').pop()); const note = await Note.findOne({ _id: noteId }); if (note === null) { diff --git a/src/remote/activitypub/kernel/undo/follow.ts b/src/remote/activitypub/kernel/undo/follow.ts index a85cb0305..c0b10c189 100644 --- a/src/remote/activitypub/kernel/undo/follow.ts +++ b/src/remote/activitypub/kernel/undo/follow.ts @@ -1,3 +1,4 @@ +import * as mongo from 'mongodb'; import User, { IRemoteUser } from '../../../../models/user'; import config from '../../../../config'; import unfollow from '../../../../services/following/delete'; @@ -10,7 +11,9 @@ export default async (actor: IRemoteUser, activity: IFollow): Promise => { return null; } - const followee = await User.findOne({ _id: id.split('/').pop() }); + const followee = await User.findOne({ + _id: new mongo.ObjectID(id.split('/').pop()) + }); if (followee === null) { throw new Error('followee not found');