This commit is contained in:
syuilo 2018-10-21 14:15:02 +09:00
parent f13faf2243
commit 1bf8cbeb29
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
8 changed files with 2 additions and 256 deletions

View file

@ -1,7 +1,5 @@
import User, { isLocalUser, isRemoteUser, pack as packUser, IUser } from '../../models/user';
import Following from '../../models/following';
import FollowingLog from '../../models/following-log';
import FollowedLog from '../../models/followed-log';
import { publishMainStream } from '../../stream';
import notify from '../../notify';
import pack from '../../remote/activitypub/renderer';
@ -20,7 +18,7 @@ export default async function(follower: IUser, followee: IUser, requestId?: stri
return;
}
const following = await Following.insert({
await Following.insert({
createdAt: new Date(),
followerId: follower._id,
followeeId: followee._id,
@ -44,12 +42,6 @@ export default async function(follower: IUser, followee: IUser, requestId?: stri
followingCount: 1
}
});
FollowingLog.insert({
createdAt: following.createdAt,
userId: follower._id,
count: follower.followingCount + 1
});
//#endregion
//#region Increment followers count
@ -58,11 +50,6 @@ export default async function(follower: IUser, followee: IUser, requestId?: stri
followersCount: 1
}
});
FollowedLog.insert({
createdAt: following.createdAt,
userId: followee._id,
count: followee.followersCount + 1
});
//#endregion
// Publish follow event

View file

@ -1,7 +1,5 @@
import User, { isLocalUser, isRemoteUser, pack as packUser, IUser } from '../../models/user';
import Following from '../../models/following';
import FollowingLog from '../../models/following-log';
import FollowedLog from '../../models/followed-log';
import { publishMainStream } from '../../stream';
import pack from '../../remote/activitypub/renderer';
import renderFollow from '../../remote/activitypub/renderer/follow';
@ -29,12 +27,6 @@ export default async function(follower: IUser, followee: IUser) {
followingCount: -1
}
});
FollowingLog.insert({
createdAt: following.createdAt,
userId: follower._id,
count: follower.followingCount - 1
});
//#endregion
//#region Decrement followers count
@ -43,11 +35,6 @@ export default async function(follower: IUser, followee: IUser) {
followersCount: -1
}
});
FollowedLog.insert({
createdAt: following.createdAt,
userId: followee._id,
count: followee.followersCount - 1
});
//#endregion
// Publish unfollow event

View file

@ -5,12 +5,10 @@ import renderFollow from '../../../remote/activitypub/renderer/follow';
import renderAccept from '../../../remote/activitypub/renderer/accept';
import { deliver } from '../../../queue';
import Following from '../../../models/following';
import FollowingLog from '../../../models/following-log';
import FollowedLog from '../../../models/followed-log';
import { publishMainStream } from '../../../stream';
export default async function(followee: IUser, follower: IUser) {
const following = await Following.insert({
await Following.insert({
createdAt: new Date(),
followerId: follower._id,
followeeId: followee._id,
@ -49,12 +47,6 @@ export default async function(followee: IUser, follower: IUser) {
followingCount: 1
}
});
FollowingLog.insert({
createdAt: following.createdAt,
userId: follower._id,
count: follower.followingCount + 1
});
//#endregion
//#region Increment followers count
@ -63,12 +55,6 @@ export default async function(followee: IUser, follower: IUser) {
followersCount: 1
}
});
FollowedLog.insert({
createdAt: following.createdAt,
userId: followee._id,
count: followee.followersCount + 1
});
//#endregion
await User.update({ _id: followee._id }, {