ワードミュート (#6594)

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip
This commit is contained in:
syuilo 2020-07-27 13:34:20 +09:00 committed by GitHub
parent b5a1fdd4c7
commit cf43dd6ec5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 485 additions and 12 deletions

View file

@ -7,15 +7,17 @@ import Channel from './channel';
import channels from './channels';
import { EventEmitter } from 'events';
import { User } from '../../../models/entities/user';
import { Users, Followings, Mutings } from '../../../models';
import { Users, Followings, Mutings, UserProfiles } from '../../../models';
import { ApiError } from '../error';
import { AccessToken } from '../../../models/entities/access-token';
import { UserProfile } from '../../../models/entities/user-profile';
/**
* Main stream connection
*/
export default class Connection {
public user?: User;
public userProfile?: UserProfile;
public following: User['id'][] = [];
public muting: User['id'][] = [];
public token?: AccessToken;
@ -25,6 +27,7 @@ export default class Connection {
private subscribingNotes: any = {};
private followingClock: NodeJS.Timer;
private mutingClock: NodeJS.Timer;
private userProfileClock: NodeJS.Timer;
constructor(
wsConnection: websocket.connection,
@ -49,6 +52,9 @@ export default class Connection {
this.updateMuting();
this.mutingClock = setInterval(this.updateMuting, 5000);
this.updateUserProfile();
this.userProfileClock = setInterval(this.updateUserProfile, 5000);
}
}
@ -262,6 +268,13 @@ export default class Connection {
this.muting = mutings.map(x => x.muteeId);
}
@autobind
private async updateUserProfile() {
this.userProfile = await UserProfiles.findOne({
userId: this.user!.id
});
}
/**
*
*/
@ -273,5 +286,6 @@ export default class Connection {
if (this.followingClock) clearInterval(this.followingClock);
if (this.mutingClock) clearInterval(this.mutingClock);
if (this.userProfileClock) clearInterval(this.userProfileClock);
}
}