mirror of
https://github.com/kokonect-link/cherrypick
synced 2024-11-27 22:38:34 +09:00
Refactor
This commit is contained in:
parent
e2a79abbe0
commit
e9a8090d7e
@ -7,7 +7,7 @@ import renderFollow from '../../remote/activitypub/renderer/follow';
|
||||
import renderAccept from '../../remote/activitypub/renderer/accept';
|
||||
import { deliver } from '../../queue';
|
||||
import createFollowRequest from './requests/create';
|
||||
import { followingStats } from '../stats';
|
||||
import { perUserFollowingStats } from '../stats';
|
||||
|
||||
export default async function(follower: IUser, followee: IUser, requestId?: string) {
|
||||
// フォロー対象が鍵アカウントである or
|
||||
@ -53,7 +53,7 @@ export default async function(follower: IUser, followee: IUser, requestId?: stri
|
||||
});
|
||||
//#endregion
|
||||
|
||||
followingStats.update(follower, followee, true);
|
||||
perUserFollowingStats.update(follower, followee, true);
|
||||
|
||||
// Publish follow event
|
||||
if (isLocalUser(follower)) {
|
||||
|
@ -5,7 +5,7 @@ import pack from '../../remote/activitypub/renderer';
|
||||
import renderFollow from '../../remote/activitypub/renderer/follow';
|
||||
import renderUndo from '../../remote/activitypub/renderer/undo';
|
||||
import { deliver } from '../../queue';
|
||||
import { followingStats } from '../stats';
|
||||
import { perUserFollowingStats } from '../stats';
|
||||
|
||||
export default async function(follower: IUser, followee: IUser) {
|
||||
const following = await Following.findOne({
|
||||
@ -38,7 +38,7 @@ export default async function(follower: IUser, followee: IUser) {
|
||||
});
|
||||
//#endregion
|
||||
|
||||
followingStats.update(follower, followee, false);
|
||||
perUserFollowingStats.update(follower, followee, false);
|
||||
|
||||
// Publish unfollow event
|
||||
if (isLocalUser(follower)) {
|
||||
|
@ -6,7 +6,7 @@ import renderAccept from '../../../remote/activitypub/renderer/accept';
|
||||
import { deliver } from '../../../queue';
|
||||
import Following from '../../../models/following';
|
||||
import { publishMainStream } from '../../../stream';
|
||||
import { followingStats } from '../../stats';
|
||||
import { perUserFollowingStats } from '../../stats';
|
||||
|
||||
export default async function(followee: IUser, follower: IUser) {
|
||||
await Following.insert({
|
||||
@ -58,7 +58,7 @@ export default async function(followee: IUser, follower: IUser) {
|
||||
});
|
||||
//#endregion
|
||||
|
||||
followingStats.update(follower, followee, true);
|
||||
perUserFollowingStats.update(follower, followee, true);
|
||||
|
||||
await User.update({ _id: followee._id }, {
|
||||
$inc: {
|
||||
|
@ -694,11 +694,11 @@ class HashtagStats extends Stats<HashtagLog> {
|
||||
export const hashtagStats = new HashtagStats();
|
||||
//#endregion
|
||||
|
||||
//#region Following stats
|
||||
//#region Per user following stats
|
||||
/**
|
||||
* ユーザーごとのフォローに関する統計
|
||||
*/
|
||||
type FollowingLog = {
|
||||
type PerUserFollowingLog = {
|
||||
local: {
|
||||
/**
|
||||
* フォローしている
|
||||
@ -741,16 +741,16 @@ type FollowingLog = {
|
||||
};
|
||||
};
|
||||
|
||||
remote: FollowingLog['local'];
|
||||
remote: PerUserFollowingLog['local'];
|
||||
};
|
||||
|
||||
class FollowingStats extends Stats<FollowingLog> {
|
||||
class PerUserFollowingStats extends Stats<PerUserFollowingLog> {
|
||||
constructor() {
|
||||
super('following', true);
|
||||
super('perUserFollowing', true);
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async getTemplate(init: boolean, latest?: FollowingLog, group?: any): Promise<FollowingLog> {
|
||||
protected async getTemplate(init: boolean, latest?: PerUserFollowingLog, group?: any): Promise<PerUserFollowingLog> {
|
||||
const [
|
||||
localFollowingsCount,
|
||||
localFollowersCount,
|
||||
@ -817,7 +817,7 @@ class FollowingStats extends Stats<FollowingLog> {
|
||||
}
|
||||
}
|
||||
|
||||
export const followingStats = new FollowingStats();
|
||||
export const perUserFollowingStats = new PerUserFollowingStats();
|
||||
//#endregion
|
||||
|
||||
//#region Per user notes stats
|
||||
|
Loading…
Reference in New Issue
Block a user