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