rudeshark.net/src/services/user/reject-follow-request.ts
2018-06-01 00:42:37 +09:00

19 lines
683 B
TypeScript

import User, { IUser, isRemoteUser, ILocalUser } from "../../models/user";
import FollowRequest from "../../models/follow-request";
import pack from '../../remote/activitypub/renderer';
import renderFollow from '../../remote/activitypub/renderer/follow';
import renderReject from '../../remote/activitypub/renderer/reject';
import { deliver } from '../../queue';
export default async function(followee: IUser, follower: IUser) {
if (isRemoteUser(follower)) {
const content = pack(renderReject(renderFollow(follower, followee)));
deliver(followee as ILocalUser, content, follower.inbox);
}
FollowRequest.remove({
followeeId: followee._id,
followerId: follower._id
});
}