blob: 5abe10878907483d46cb9af418cb5326b43caf07 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
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 (mute.map(m => m.muteeId).includes(body.userId)) return;
if (body.isHidden) return;
break;
}
}
this.send(type, body);
});
}
}
|