iceshrimp/src/server/api/stream/channels/main.ts

42 lines
980 B
TypeScript
Raw Normal View History

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