blob: 8cd4fcac99bdbed707065d39ad4452cfdda838b0 (
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
35
36
37
38
39
40
41
42
|
import autobind from 'autobind-decorator';
import Channel from '../channel';
import { Mutings, Notes } 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 => {
let { type, body } = data;
switch (type) {
case 'notification': {
if (mute.map(m => m.muteeId).includes(body.userId)) return;
if (body.note && body.note.isHidden) {
body.note = await Notes.pack(body.note.id, this.user, {
detail: true
});
}
break;
}
case 'mention': {
if (mute.map(m => m.muteeId).includes(body.userId)) return;
if (body.isHidden) {
body = await Notes.pack(body.id, this.user, {
detail: true
});
}
break;
}
}
this.send(type, body);
});
}
}
|