summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/stream/channels/local-timeline.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/local-timeline.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/local-timeline.ts')
-rw-r--r--packages/backend/src/server/api/stream/channels/local-timeline.ts47
1 files changed, 38 insertions, 9 deletions
diff --git a/packages/backend/src/server/api/stream/channels/local-timeline.ts b/packages/backend/src/server/api/stream/channels/local-timeline.ts
index f01f477238..5a5a43f845 100644
--- a/packages/backend/src/server/api/stream/channels/local-timeline.ts
+++ b/packages/backend/src/server/api/stream/channels/local-timeline.ts
@@ -1,22 +1,30 @@
-import Channel from '../channel.js';
-import { fetchMeta } from '@/misc/fetch-meta.js';
-import { Notes } from '@/models/index.js';
+import { Inject, Injectable } from '@nestjs/common';
+import type { NotesRepository } from '@/models/index.js';
import { checkWordMute } from '@/misc/check-word-mute.js';
import { isUserRelated } from '@/misc/is-user-related.js';
-import { Packed } from '@/misc/schema.js';
+import type { Packed } from '@/misc/schema.js';
+import { MetaService } from '@/core/MetaService.js';
+import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
+import Channel from '../channel.js';
-export default class extends Channel {
+class LocalTimelineChannel extends Channel {
public readonly chName = 'localTimeline';
public static shouldShare = true;
public static requireCredential = false;
- constructor(id: string, connection: Channel['connection']) {
+ constructor(
+ private metaService: MetaService,
+ private noteEntityService: NoteEntityService,
+
+ id: string,
+ connection: Channel['connection'],
+ ) {
super(id, connection);
this.onNote = this.onNote.bind(this);
}
public async init(params: any) {
- const meta = await fetchMeta();
+ const meta = await this.metaService.fetch();
if (meta.disableLocalTimeline) {
if (this.user == null || (!this.user.isAdmin && !this.user.isModerator)) return;
}
@@ -32,13 +40,13 @@ export default class extends Channel {
// リプライなら再pack
if (note.replyId != null) {
- note.reply = await Notes.pack(note.replyId, this.user, {
+ note.reply = await this.noteEntityService.pack(note.replyId, this.user, {
detail: true,
});
}
// Renoteなら再pack
if (note.renoteId != null) {
- note.renote = await Notes.pack(note.renoteId, this.user, {
+ note.renote = await this.noteEntityService.pack(note.renoteId, this.user, {
detail: true,
});
}
@@ -72,3 +80,24 @@ export default class extends Channel {
this.subscriber.off('notesStream', this.onNote);
}
}
+
+@Injectable()
+export class LocalTimelineChannelService {
+ public readonly shouldShare = LocalTimelineChannel.shouldShare;
+ public readonly requireCredential = LocalTimelineChannel.requireCredential;
+
+ constructor(
+ private metaService: MetaService,
+ private noteEntityService: NoteEntityService,
+ ) {
+ }
+
+ public create(id: string, connection: Channel['connection']): LocalTimelineChannel {
+ return new LocalTimelineChannel(
+ this.metaService,
+ this.noteEntityService,
+ id,
+ connection,
+ );
+ }
+}