2023-07-27 00:31:52 -05:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2022-12-04 00:03:09 -06:00
|
|
|
import { bindThis } from '@/decorators.js';
|
2023-06-25 07:13:15 -05:00
|
|
|
import type Connection from './index.js';
|
2018-10-06 21:06:17 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Stream channel
|
|
|
|
*/
|
2023-08-17 07:20:58 -05:00
|
|
|
// eslint-disable-next-line import/no-default-export
|
2018-10-06 21:06:17 -05:00
|
|
|
export default abstract class Channel {
|
|
|
|
protected connection: Connection;
|
|
|
|
public id: string;
|
2018-10-11 09:01:57 -05:00
|
|
|
public abstract readonly chName: string;
|
2018-10-11 09:07:20 -05:00
|
|
|
public static readonly shouldShare: boolean;
|
2018-11-10 11:22:34 -06:00
|
|
|
public static readonly requireCredential: boolean;
|
2018-10-06 21:06:17 -05:00
|
|
|
|
|
|
|
protected get user() {
|
|
|
|
return this.connection.user;
|
|
|
|
}
|
|
|
|
|
2020-07-26 23:34:20 -05:00
|
|
|
protected get userProfile() {
|
|
|
|
return this.connection.userProfile;
|
|
|
|
}
|
|
|
|
|
2019-04-07 07:50:36 -05:00
|
|
|
protected get following() {
|
|
|
|
return this.connection.following;
|
|
|
|
}
|
|
|
|
|
2023-04-04 20:21:10 -05:00
|
|
|
protected get userIdsWhoMeMuting() {
|
|
|
|
return this.connection.userIdsWhoMeMuting;
|
2019-04-07 07:50:36 -05:00
|
|
|
}
|
|
|
|
|
2023-04-04 20:21:10 -05:00
|
|
|
protected get userIdsWhoMeMutingRenotes() {
|
|
|
|
return this.connection.userIdsWhoMeMutingRenotes;
|
2023-03-07 17:56:09 -06:00
|
|
|
}
|
|
|
|
|
2023-04-04 20:21:10 -05:00
|
|
|
protected get userIdsWhoBlockingMe() {
|
|
|
|
return this.connection.userIdsWhoBlockingMe;
|
2021-08-17 07:48:59 -05:00
|
|
|
}
|
|
|
|
|
2020-08-18 08:44:21 -05:00
|
|
|
protected get followingChannels() {
|
|
|
|
return this.connection.followingChannels;
|
|
|
|
}
|
|
|
|
|
2018-10-06 21:06:17 -05:00
|
|
|
protected get subscriber() {
|
|
|
|
return this.connection.subscriber;
|
|
|
|
}
|
|
|
|
|
|
|
|
constructor(id: string, connection: Connection) {
|
|
|
|
this.id = id;
|
|
|
|
this.connection = connection;
|
|
|
|
}
|
|
|
|
|
2022-12-04 00:03:09 -06:00
|
|
|
@bindThis
|
2018-10-06 21:06:17 -05:00
|
|
|
public send(typeOrPayload: any, payload?: any) {
|
|
|
|
const type = payload === undefined ? typeOrPayload.type : typeOrPayload;
|
|
|
|
const body = payload === undefined ? typeOrPayload.body : payload;
|
|
|
|
|
|
|
|
this.connection.sendMessageToWs('channel', {
|
|
|
|
id: this.id,
|
|
|
|
type: type,
|
2021-12-09 08:58:30 -06:00
|
|
|
body: body,
|
2018-10-06 21:06:17 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public abstract init(params: any): void;
|
|
|
|
public dispose?(): void;
|
|
|
|
public onMessage?(type: string, body: any): void;
|
|
|
|
}
|