summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/stream/channels/channel.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-02-15 13:06:06 +0900
committerGitHub <noreply@github.com>2023-02-15 13:06:06 +0900
commit8f2049bcd261c3fb10afdc8c15cf4edffe1baa71 (patch)
treedc5aa1cefc24d3f6eb36bb1723d7433f8a19e5a2 /packages/backend/src/server/api/stream/channels/channel.ts
parentMerge branch 'develop' of https://github.com/misskey-dev/misskey into develop (diff)
downloadmisskey-8f2049bcd261c3fb10afdc8c15cf4edffe1baa71.tar.gz
misskey-8f2049bcd261c3fb10afdc8c15cf4edffe1baa71.tar.bz2
misskey-8f2049bcd261c3fb10afdc8c15cf4edffe1baa71.zip
drop messaging (#9919)
* drop messaging (from backend) * wip
Diffstat (limited to 'packages/backend/src/server/api/stream/channels/channel.ts')
-rw-r--r--packages/backend/src/server/api/stream/channels/channel.ts43
1 files changed, 0 insertions, 43 deletions
diff --git a/packages/backend/src/server/api/stream/channels/channel.ts b/packages/backend/src/server/api/stream/channels/channel.ts
index 5ba84e43c4..589c294372 100644
--- a/packages/backend/src/server/api/stream/channels/channel.ts
+++ b/packages/backend/src/server/api/stream/channels/channel.ts
@@ -1,32 +1,25 @@
import { Inject, Injectable } from '@nestjs/common';
-import type { NotesRepository, UsersRepository } from '@/models/index.js';
import { isUserRelated } from '@/misc/is-user-related.js';
-import type { User } from '@/models/entities/User.js';
import type { Packed } from '@/misc/schema.js';
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
import { UserEntityService } from '@/core/entities/UserEntityService.js';
import { bindThis } from '@/decorators.js';
import Channel from '../channel.js';
-import type { StreamMessages } from '../types.js';
class ChannelChannel extends Channel {
public readonly chName = 'channel';
public static shouldShare = false;
public static requireCredential = false;
private channelId: string;
- private typers: Record<User['id'], Date> = {};
- private emitTypersIntervalId: ReturnType<typeof setInterval>;
constructor(
private noteEntityService: NoteEntityService,
- private userEntityService: UserEntityService,
id: string,
connection: Channel['connection'],
) {
super(id, connection);
//this.onNote = this.onNote.bind(this);
- //this.emitTypers = this.emitTypers.bind(this);
}
@bindThis
@@ -35,8 +28,6 @@ class ChannelChannel extends Channel {
// Subscribe stream
this.subscriber.on('notesStream', this.onNote);
- this.subscriber.on(`channelStream:${this.channelId}`, this.onEvent);
- this.emitTypersIntervalId = setInterval(this.emitTypers, 5000);
}
@bindThis
@@ -67,41 +58,9 @@ class ChannelChannel extends Channel {
}
@bindThis
- private onEvent(data: StreamMessages['channel']['payload']) {
- if (data.type === 'typing') {
- const id = data.body;
- const begin = this.typers[id] == null;
- this.typers[id] = new Date();
- if (begin) {
- this.emitTypers();
- }
- }
- }
-
- @bindThis
- private async emitTypers() {
- const now = new Date();
-
- // Remove not typing users
- for (const [userId, date] of Object.entries(this.typers)) {
- if (now.getTime() - date.getTime() > 5000) delete this.typers[userId];
- }
-
- const users = await this.userEntityService.packMany(Object.keys(this.typers), null, { detail: false });
-
- this.send({
- type: 'typers',
- body: users,
- });
- }
-
- @bindThis
public dispose() {
// Unsubscribe events
this.subscriber.off('notesStream', this.onNote);
- this.subscriber.off(`channelStream:${this.channelId}`, this.onEvent);
-
- clearInterval(this.emitTypersIntervalId);
}
}
@@ -112,7 +71,6 @@ export class ChannelChannelService {
constructor(
private noteEntityService: NoteEntityService,
- private userEntityService: UserEntityService,
) {
}
@@ -120,7 +78,6 @@ export class ChannelChannelService {
public create(id: string, connection: Channel['connection']): ChannelChannel {
return new ChannelChannel(
this.noteEntityService,
- this.userEntityService,
id,
connection,
);