2018-10-07 04:06:17 +02:00
|
|
|
import autobind from 'autobind-decorator';
|
|
|
|
import Channel from '../channel';
|
2020-02-26 00:03:23 +01:00
|
|
|
import { Notes } from '../../../../models';
|
2018-10-07 04:06:17 +02:00
|
|
|
|
|
|
|
export default class extends Channel {
|
2018-10-11 16:01:57 +02:00
|
|
|
public readonly chName = 'main';
|
2018-10-11 16:07:20 +02:00
|
|
|
public static shouldShare = true;
|
2018-11-10 18:22:34 +01:00
|
|
|
public static requireCredential = true;
|
2018-10-11 16:01:57 +02:00
|
|
|
|
2018-10-07 04:06:17 +02:00
|
|
|
@autobind
|
|
|
|
public async init(params: any) {
|
|
|
|
// Subscribe main stream channel
|
2019-04-12 18:43:22 +02:00
|
|
|
this.subscriber.on(`mainStream:${this.user!.id}`, async data => {
|
2020-03-04 03:45:33 +01:00
|
|
|
const { type } = data;
|
|
|
|
let { body } = data;
|
2018-10-07 04:06:17 +02:00
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case 'notification': {
|
2021-01-30 03:09:46 +01:00
|
|
|
if (this.muting.has(body.userId)) return;
|
2019-09-23 20:58:00 +02:00
|
|
|
if (body.note && body.note.isHidden) {
|
|
|
|
body.note = await Notes.pack(body.note.id, this.user, {
|
|
|
|
detail: true
|
|
|
|
});
|
|
|
|
}
|
2019-01-24 16:06:20 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'mention': {
|
2021-01-30 03:09:46 +01:00
|
|
|
if (this.muting.has(body.userId)) return;
|
2019-09-23 20:58:00 +02:00
|
|
|
if (body.isHidden) {
|
|
|
|
body = await Notes.pack(body.id, this.user, {
|
|
|
|
detail: true
|
|
|
|
});
|
|
|
|
}
|
2018-10-07 04:06:17 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-10-07 18:56:36 +02:00
|
|
|
|
|
|
|
this.send(type, body);
|
2018-10-07 04:06:17 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|