Fix: mainStreamのミュート情報が再接続まで反映されない (#6072)

This commit is contained in:
MeiMei 2020-02-26 08:03:23 +09:00 committed by GitHub
parent 1528935008
commit 06ddc8ec50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 5 deletions

View File

@ -1,6 +1,6 @@
import autobind from 'autobind-decorator'; import autobind from 'autobind-decorator';
import Channel from '../channel'; import Channel from '../channel';
import { Mutings, Notes } from '../../../../models'; import { Notes } from '../../../../models';
export default class extends Channel { export default class extends Channel {
public readonly chName = 'main'; public readonly chName = 'main';
@ -9,15 +9,13 @@ export default class extends Channel {
@autobind @autobind
public async init(params: any) { public async init(params: any) {
const mute = await Mutings.find({ muterId: this.user!.id });
// Subscribe main stream channel // Subscribe main stream channel
this.subscriber.on(`mainStream:${this.user!.id}`, async data => { this.subscriber.on(`mainStream:${this.user!.id}`, async data => {
let { type, body } = data; let { type, body } = data;
switch (type) { switch (type) {
case 'notification': { case 'notification': {
if (mute.map(m => m.muteeId).includes(body.userId)) return; if (this.muting.includes(body.userId)) return;
if (body.note && body.note.isHidden) { if (body.note && body.note.isHidden) {
body.note = await Notes.pack(body.note.id, this.user, { body.note = await Notes.pack(body.note.id, this.user, {
detail: true detail: true
@ -26,7 +24,7 @@ export default class extends Channel {
break; break;
} }
case 'mention': { case 'mention': {
if (mute.map(m => m.muteeId).includes(body.userId)) return; if (this.muting.includes(body.userId)) return;
if (body.isHidden) { if (body.isHidden) {
body = await Notes.pack(body.id, this.user, { body = await Notes.pack(body.id, this.user, {
detail: true detail: true