yumechi-no-kuni/src/server/api/stream/channels/main.ts
syuilo 987168b863
strictNullChecks (#4666)
* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip
2019-04-13 01:43:22 +09:00

33 lines
813 B
TypeScript

import autobind from 'autobind-decorator';
import Channel from '../channel';
import { Mutings } from '../../../../models';
export default class extends Channel {
public readonly chName = 'main';
public static shouldShare = true;
public static requireCredential = true;
@autobind
public async init(params: any) {
const mute = await Mutings.find({ muterId: this.user!.id });
// Subscribe main stream channel
this.subscriber.on(`mainStream:${this.user!.id}`, async data => {
const { type, body } = data;
switch (type) {
case 'notification': {
if (mute.map(m => m.muteeId).includes(body.userId)) return;
if (body.note && body.note.isHidden) return;
break;
}
case 'mention': {
if (body.isHidden) return;
break;
}
}
this.send(type, body);
});
}
}