mirror of
https://github.com/misskey-dev/misskey.git
synced 2025-01-19 02:11:08 +09:00
b9cb6d1c10
将来ESMに移行しやすいように Related: #7658 なんかmochaが起動しなくなってるけど理由不明 すぐ直したい
46 lines
1.1 KiB
TypeScript
46 lines
1.1 KiB
TypeScript
import autobind from 'autobind-decorator';
|
|
import Channel from '../channel.js';
|
|
import { Notes } from '@/models/index.js';
|
|
|
|
export default class extends Channel {
|
|
public readonly chName = 'main';
|
|
public static shouldShare = true;
|
|
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.has(body.userId)) return;
|
|
if (body.note && body.note.isHidden) {
|
|
const note = await Notes.pack(body.note.id, this.user, {
|
|
detail: true
|
|
});
|
|
this.connection.cacheNote(note);
|
|
body.note = note;
|
|
}
|
|
break;
|
|
}
|
|
case 'mention': {
|
|
if (this.muting.has(body.userId)) return;
|
|
if (body.isHidden) {
|
|
const note = await Notes.pack(body.id, this.user, {
|
|
detail: true
|
|
});
|
|
this.connection.cacheNote(note);
|
|
body = note;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
this.send(type, body);
|
|
});
|
|
}
|
|
}
|