diff options
| author | Akihiko Odaki <nekomanma@pixiv.co.jp> | 2018-04-02 21:57:36 +0900 |
|---|---|---|
| committer | Akihiko Odaki <nekomanma@pixiv.co.jp> | 2018-04-02 22:00:40 +0900 |
| commit | 319e905bf9e5398cb62eaeee7da80ff6e942c094 (patch) | |
| tree | 5d0edf01e29d7904bf4b82d57ff60754741ce100 /src/processor/http/follow.ts | |
| parent | Implement Follow activity (diff) | |
| download | sharkey-319e905bf9e5398cb62eaeee7da80ff6e942c094.tar.gz sharkey-319e905bf9e5398cb62eaeee7da80ff6e942c094.tar.bz2 sharkey-319e905bf9e5398cb62eaeee7da80ff6e942c094.zip | |
Introduce followed log and following log
Diffstat (limited to 'src/processor/http/follow.ts')
| -rw-r--r-- | src/processor/http/follow.ts | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/processor/http/follow.ts b/src/processor/http/follow.ts index 7ec1ee6756..29ac9fa552 100644 --- a/src/processor/http/follow.ts +++ b/src/processor/http/follow.ts @@ -3,6 +3,8 @@ import { sign } from 'http-signature'; import { URL } from 'url'; import User, { isLocalUser, pack as packUser } from '../../models/user'; import Following from '../../models/following'; +import FollowingLog from '../../models/following-log'; +import FollowedLog from '../../models/followed-log'; import event from '../../publishers/stream'; import notify from '../../publishers/notify'; import context from '../../remote/activitypub/renderer/context'; @@ -21,6 +23,11 @@ export default ({ data }, done) => Following.findOne({ _id: data.following }).th } }), + promisedFollower.then(({ followingCount }) => FollowingLog.insert({ + userId: followerId, + count: followingCount + 1 + })), + // Increment followers count User.update({ _id: followeeId }, { $inc: { @@ -28,6 +35,11 @@ export default ({ data }, done) => Following.findOne({ _id: data.following }).th } }), + promisedFollowee.then(({ followersCount }) => FollowedLog.insert({ + userId: followerId, + count: followersCount + 1 + })), + // Notify promisedFollowee.then(followee => followee.host === null ? notify(followeeId, followerId, 'follow') : null), |