diff options
Diffstat (limited to 'src/remote/activitypub/kernel/undo')
| -rw-r--r-- | src/remote/activitypub/kernel/undo/block.ts | 10 | ||||
| -rw-r--r-- | src/remote/activitypub/kernel/undo/follow.ts | 24 | ||||
| -rw-r--r-- | src/remote/activitypub/kernel/undo/index.ts | 2 | ||||
| -rw-r--r-- | src/remote/activitypub/kernel/undo/like.ts | 11 |
4 files changed, 20 insertions, 27 deletions
diff --git a/src/remote/activitypub/kernel/undo/block.ts b/src/remote/activitypub/kernel/undo/block.ts index 4a22ac7924..c916a00737 100644 --- a/src/remote/activitypub/kernel/undo/block.ts +++ b/src/remote/activitypub/kernel/undo/block.ts @@ -1,9 +1,9 @@ -import * as mongo from 'mongodb'; -import User, { IRemoteUser } from '../../../../models/user'; import config from '../../../../config'; import { IBlock } from '../../type'; import unblock from '../../../../services/blocking/delete'; import { apLogger } from '../../logger'; +import { IRemoteUser } from '../../../../models/entities/user'; +import { Users } from '../../../../models'; const logger = apLogger; @@ -18,11 +18,9 @@ export default async (actor: IRemoteUser, activity: IBlock): Promise<void> => { return null; } - const blockee = await User.findOne({ - _id: new mongo.ObjectID(id.split('/').pop()) - }); + const blockee = await Users.findOne(id.split('/').pop()); - if (blockee === null) { + if (blockee == null) { throw new Error('blockee not found'); } diff --git a/src/remote/activitypub/kernel/undo/follow.ts b/src/remote/activitypub/kernel/undo/follow.ts index af06aa5b31..cc63a740b1 100644 --- a/src/remote/activitypub/kernel/undo/follow.ts +++ b/src/remote/activitypub/kernel/undo/follow.ts @@ -1,11 +1,9 @@ -import * as mongo from 'mongodb'; -import User, { IRemoteUser } from '../../../../models/user'; import config from '../../../../config'; import unfollow from '../../../../services/following/delete'; import cancelRequest from '../../../../services/following/requests/cancel'; import { IFollow } from '../../type'; -import FollowRequest from '../../../../models/follow-request'; -import Following from '../../../../models/following'; +import { IRemoteUser } from '../../../../models/entities/user'; +import { Users, FollowRequests, Followings } from '../../../../models'; export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => { const id = typeof activity.object == 'string' ? activity.object : activity.object.id; @@ -14,11 +12,9 @@ export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => { return null; } - const followee = await User.findOne({ - _id: new mongo.ObjectID(id.split('/').pop()) - }); + const followee = await Users.findOne(id.split('/').pop()); - if (followee === null) { + if (followee == null) { throw new Error('followee not found'); } @@ -26,14 +22,14 @@ export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => { throw new Error('フォロー解除しようとしているユーザーはローカルユーザーではありません'); } - const req = await FollowRequest.findOne({ - followerId: actor._id, - followeeId: followee._id + const req = await FollowRequests.findOne({ + followerId: actor.id, + followeeId: followee.id }); - const following = await Following.findOne({ - followerId: actor._id, - followeeId: followee._id + const following = await Followings.findOne({ + followerId: actor.id, + followeeId: followee.id }); if (req) { diff --git a/src/remote/activitypub/kernel/undo/index.ts b/src/remote/activitypub/kernel/undo/index.ts index 80b44fae04..6376ab93a8 100644 --- a/src/remote/activitypub/kernel/undo/index.ts +++ b/src/remote/activitypub/kernel/undo/index.ts @@ -1,4 +1,4 @@ -import { IRemoteUser } from '../../../../models/user'; +import { IRemoteUser } from '../../../../models/entities/user'; import { IUndo, IFollow, IBlock, ILike } from '../../type'; import unfollow from './follow'; import unblock from './block'; diff --git a/src/remote/activitypub/kernel/undo/like.ts b/src/remote/activitypub/kernel/undo/like.ts index b324ec854c..f337a0173e 100644 --- a/src/remote/activitypub/kernel/undo/like.ts +++ b/src/remote/activitypub/kernel/undo/like.ts @@ -1,8 +1,7 @@ -import * as mongo from 'mongodb'; -import { IRemoteUser } from '../../../../models/user'; +import { IRemoteUser } from '../../../../models/entities/user'; import { ILike } from '../../type'; -import Note from '../../../../models/note'; import deleteReaction from '../../../../services/note/reaction/delete'; +import { Notes } from '../../../../models'; /** * Process Undo.Like activity @@ -10,10 +9,10 @@ import deleteReaction from '../../../../services/note/reaction/delete'; 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 noteId = id.split('/').pop(); - const note = await Note.findOne({ _id: noteId }); - if (note === null) { + const note = await Notes.findOne(noteId); + if (note == null) { throw 'note not found'; } |