summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/stream/channels/main.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2022-09-18 03:27:08 +0900
committerGitHub <noreply@github.com>2022-09-18 03:27:08 +0900
commitb75184ec8e3436200bacdcd832e3324702553d20 (patch)
tree8b7e316f29e95df921db57289c8b8da476d18f07 /packages/backend/src/server/api/stream/channels/main.ts
parentUpdate ROADMAP.md (diff)
downloadmisskey-b75184ec8e3436200bacdcd832e3324702553d20.tar.gz
misskey-b75184ec8e3436200bacdcd832e3324702553d20.tar.bz2
misskey-b75184ec8e3436200bacdcd832e3324702553d20.zip
なんかもうめっちゃ変えた
Diffstat (limited to 'packages/backend/src/server/api/stream/channels/main.ts')
-rw-r--r--packages/backend/src/server/api/stream/channels/main.ts40
1 files changed, 35 insertions, 5 deletions
diff --git a/packages/backend/src/server/api/stream/channels/main.ts b/packages/backend/src/server/api/stream/channels/main.ts
index 9cfea0bfc4..12908e07b4 100644
--- a/packages/backend/src/server/api/stream/channels/main.ts
+++ b/packages/backend/src/server/api/stream/channels/main.ts
@@ -1,12 +1,23 @@
-import Channel from '../channel.js';
-import { Notes } from '@/models/index.js';
+import { Inject, Injectable } from '@nestjs/common';
+import type { NotesRepository } from '@/models/index.js';
import { isInstanceMuted, isUserFromMutedInstance } from '@/misc/is-instance-muted.js';
+import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
+import Channel from '../channel.js';
-export default class extends Channel {
+class MainChannel extends Channel {
public readonly chName = 'main';
public static shouldShare = true;
public static requireCredential = true;
+ constructor(
+ private noteEntityService: NoteEntityService,
+
+ id: string,
+ connection: Channel['connection'],
+ ) {
+ super(id, connection);
+ }
+
public async init(params: any) {
// Subscribe main stream channel
this.subscriber.on(`mainStream:${this.user!.id}`, async data => {
@@ -17,7 +28,7 @@ export default class extends Channel {
if (data.body.userId && this.muting.has(data.body.userId)) return;
if (data.body.note && data.body.note.isHidden) {
- const note = await Notes.pack(data.body.note.id, this.user, {
+ const note = await this.noteEntityService.pack(data.body.note.id, this.user, {
detail: true,
});
this.connection.cacheNote(note);
@@ -30,7 +41,7 @@ export default class extends Channel {
if (this.muting.has(data.body.userId)) return;
if (data.body.isHidden) {
- const note = await Notes.pack(data.body.id, this.user, {
+ const note = await this.noteEntityService.pack(data.body.id, this.user, {
detail: true,
});
this.connection.cacheNote(note);
@@ -44,3 +55,22 @@ export default class extends Channel {
});
}
}
+
+@Injectable()
+export class MainChannelService {
+ public readonly shouldShare = MainChannel.shouldShare;
+ public readonly requireCredential = MainChannel.requireCredential;
+
+ constructor(
+ private noteEntityService: NoteEntityService,
+ ) {
+ }
+
+ public create(id: string, connection: Channel['connection']): MainChannel {
+ return new MainChannel(
+ this.noteEntityService,
+ id,
+ connection,
+ );
+ }
+}