refactor: Use ESM (#8358)
* wip * wip * fix * clean up * Update tsconfig.json * Update activitypub.ts * wip
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Channel from '../channel';
|
||||
import Channel from '../channel.js';
|
||||
|
||||
export default class extends Channel {
|
||||
public readonly chName = 'admin';
|
||||
public static shouldShare = true;
|
||||
public static requireCredential = true;
|
||||
|
||||
@autobind
|
||||
public async init(params: any) {
|
||||
// Subscribe admin stream
|
||||
this.subscriber.on(`adminStream:${this.user!.id}`, data => {
|
||||
|
@@ -1,9 +1,8 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Channel from '../channel';
|
||||
import { Notes } from '@/models/index';
|
||||
import { isMutedUserRelated } from '@/misc/is-muted-user-related';
|
||||
import { isBlockerUserRelated } from '@/misc/is-blocker-user-related';
|
||||
import { StreamMessages } from '../types';
|
||||
import Channel from '../channel.js';
|
||||
import { Notes } from '@/models/index.js';
|
||||
import { isMutedUserRelated } from '@/misc/is-muted-user-related.js';
|
||||
import { isBlockerUserRelated } from '@/misc/is-blocker-user-related.js';
|
||||
import { StreamMessages } from '../types.js';
|
||||
|
||||
export default class extends Channel {
|
||||
public readonly chName = 'antenna';
|
||||
@@ -11,7 +10,11 @@ export default class extends Channel {
|
||||
public static requireCredential = false;
|
||||
private antennaId: string;
|
||||
|
||||
@autobind
|
||||
constructor(id: string, connection: Channel['connection']) {
|
||||
super(id, connection);
|
||||
this.onEvent = this.onEvent.bind(this);
|
||||
}
|
||||
|
||||
public async init(params: any) {
|
||||
this.antennaId = params.antennaId as string;
|
||||
|
||||
@@ -19,7 +22,6 @@ export default class extends Channel {
|
||||
this.subscriber.on(`antennaStream:${this.antennaId}`, this.onEvent);
|
||||
}
|
||||
|
||||
@autobind
|
||||
private async onEvent(data: StreamMessages['antenna']['payload']) {
|
||||
if (data.type === 'note') {
|
||||
const note = await Notes.pack(data.body.id, this.user, { detail: true });
|
||||
@@ -37,7 +39,6 @@ export default class extends Channel {
|
||||
}
|
||||
}
|
||||
|
||||
@autobind
|
||||
public dispose() {
|
||||
// Unsubscribe events
|
||||
this.subscriber.off(`antennaStream:${this.antennaId}`, this.onEvent);
|
||||
|
@@ -1,11 +1,10 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Channel from '../channel';
|
||||
import { Notes, Users } from '@/models/index';
|
||||
import { isMutedUserRelated } from '@/misc/is-muted-user-related';
|
||||
import { isBlockerUserRelated } from '@/misc/is-blocker-user-related';
|
||||
import { User } from '@/models/entities/user';
|
||||
import { StreamMessages } from '../types';
|
||||
import { Packed } from '@/misc/schema';
|
||||
import Channel from '../channel.js';
|
||||
import { Notes, Users } from '@/models/index.js';
|
||||
import { isMutedUserRelated } from '@/misc/is-muted-user-related.js';
|
||||
import { isBlockerUserRelated } from '@/misc/is-blocker-user-related.js';
|
||||
import { User } from '@/models/entities/user.js';
|
||||
import { StreamMessages } from '../types.js';
|
||||
import { Packed } from '@/misc/schema.js';
|
||||
|
||||
export default class extends Channel {
|
||||
public readonly chName = 'channel';
|
||||
@@ -15,7 +14,11 @@ export default class extends Channel {
|
||||
private typers: Record<User['id'], Date> = {};
|
||||
private emitTypersIntervalId: ReturnType<typeof setInterval>;
|
||||
|
||||
@autobind
|
||||
constructor(id: string, connection: Channel['connection']) {
|
||||
super(id, connection);
|
||||
this.onNote = this.onNote.bind(this);
|
||||
}
|
||||
|
||||
public async init(params: any) {
|
||||
this.channelId = params.channelId as string;
|
||||
|
||||
@@ -25,7 +28,6 @@ export default class extends Channel {
|
||||
this.emitTypersIntervalId = setInterval(this.emitTypers, 5000);
|
||||
}
|
||||
|
||||
@autobind
|
||||
private async onNote(note: Packed<'Note'>) {
|
||||
if (note.channelId !== this.channelId) return;
|
||||
|
||||
@@ -52,7 +54,6 @@ export default class extends Channel {
|
||||
this.send('note', note);
|
||||
}
|
||||
|
||||
@autobind
|
||||
private onEvent(data: StreamMessages['channel']['payload']) {
|
||||
if (data.type === 'typing') {
|
||||
const id = data.body;
|
||||
@@ -64,7 +65,6 @@ export default class extends Channel {
|
||||
}
|
||||
}
|
||||
|
||||
@autobind
|
||||
private async emitTypers() {
|
||||
const now = new Date();
|
||||
|
||||
@@ -81,7 +81,6 @@ export default class extends Channel {
|
||||
});
|
||||
}
|
||||
|
||||
@autobind
|
||||
public dispose() {
|
||||
// Unsubscribe events
|
||||
this.subscriber.off('notesStream', this.onNote);
|
||||
|
@@ -1,12 +1,10 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Channel from '../channel';
|
||||
import Channel from '../channel.js';
|
||||
|
||||
export default class extends Channel {
|
||||
public readonly chName = 'drive';
|
||||
public static shouldShare = true;
|
||||
public static requireCredential = true;
|
||||
|
||||
@autobind
|
||||
public async init(params: any) {
|
||||
// Subscribe drive stream
|
||||
this.subscriber.on(`driveStream:${this.user!.id}`, data => {
|
||||
|
@@ -1,19 +1,22 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import { isMutedUserRelated } from '@/misc/is-muted-user-related';
|
||||
import Channel from '../channel';
|
||||
import { fetchMeta } from '@/misc/fetch-meta';
|
||||
import { Notes } from '@/models/index';
|
||||
import { checkWordMute } from '@/misc/check-word-mute';
|
||||
import { isBlockerUserRelated } from '@/misc/is-blocker-user-related';
|
||||
import { isInstanceMuted } from '@/misc/is-instance-muted';
|
||||
import { Packed } from '@/misc/schema';
|
||||
import { isMutedUserRelated } from '@/misc/is-muted-user-related.js';
|
||||
import Channel from '../channel.js';
|
||||
import { fetchMeta } from '@/misc/fetch-meta.js';
|
||||
import { Notes } from '@/models/index.js';
|
||||
import { checkWordMute } from '@/misc/check-word-mute.js';
|
||||
import { isBlockerUserRelated } from '@/misc/is-blocker-user-related.js';
|
||||
import { isInstanceMuted } from '@/misc/is-instance-muted.js';
|
||||
import { Packed } from '@/misc/schema.js';
|
||||
|
||||
export default class extends Channel {
|
||||
public readonly chName = 'globalTimeline';
|
||||
public static shouldShare = true;
|
||||
public static requireCredential = false;
|
||||
|
||||
@autobind
|
||||
constructor(id: string, connection: Channel['connection']) {
|
||||
super(id, connection);
|
||||
this.onNote = this.onNote.bind(this);
|
||||
}
|
||||
|
||||
public async init(params: any) {
|
||||
const meta = await fetchMeta();
|
||||
if (meta.disableGlobalTimeline) {
|
||||
@@ -24,7 +27,6 @@ export default class extends Channel {
|
||||
this.subscriber.on('notesStream', this.onNote);
|
||||
}
|
||||
|
||||
@autobind
|
||||
private async onNote(note: Packed<'Note'>) {
|
||||
if (note.visibility !== 'public') return;
|
||||
if (note.channelId != null) return;
|
||||
@@ -69,7 +71,6 @@ export default class extends Channel {
|
||||
this.send('note', note);
|
||||
}
|
||||
|
||||
@autobind
|
||||
public dispose() {
|
||||
// Unsubscribe events
|
||||
this.subscriber.off('notesStream', this.onNote);
|
||||
|
@@ -1,10 +1,9 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import { isMutedUserRelated } from '@/misc/is-muted-user-related';
|
||||
import Channel from '../channel';
|
||||
import { Notes } from '@/models/index';
|
||||
import { normalizeForSearch } from '@/misc/normalize-for-search';
|
||||
import { isBlockerUserRelated } from '@/misc/is-blocker-user-related';
|
||||
import { Packed } from '@/misc/schema';
|
||||
import { isMutedUserRelated } from '@/misc/is-muted-user-related.js';
|
||||
import Channel from '../channel.js';
|
||||
import { Notes } from '@/models/index.js';
|
||||
import { normalizeForSearch } from '@/misc/normalize-for-search.js';
|
||||
import { isBlockerUserRelated } from '@/misc/is-blocker-user-related.js';
|
||||
import { Packed } from '@/misc/schema.js';
|
||||
|
||||
export default class extends Channel {
|
||||
public readonly chName = 'hashtag';
|
||||
@@ -12,7 +11,11 @@ export default class extends Channel {
|
||||
public static requireCredential = false;
|
||||
private q: string[][];
|
||||
|
||||
@autobind
|
||||
constructor(id: string, connection: Channel['connection']) {
|
||||
super(id, connection);
|
||||
this.onNote = this.onNote.bind(this);
|
||||
}
|
||||
|
||||
public async init(params: any) {
|
||||
this.q = params.q;
|
||||
|
||||
@@ -22,7 +25,6 @@ export default class extends Channel {
|
||||
this.subscriber.on('notesStream', this.onNote);
|
||||
}
|
||||
|
||||
@autobind
|
||||
private async onNote(note: Packed<'Note'>) {
|
||||
const noteTags = note.tags ? note.tags.map((t: string) => t.toLowerCase()) : [];
|
||||
const matched = this.q.some(tags => tags.every(tag => noteTags.includes(normalizeForSearch(tag))));
|
||||
@@ -45,7 +47,6 @@ export default class extends Channel {
|
||||
this.send('note', note);
|
||||
}
|
||||
|
||||
@autobind
|
||||
public dispose() {
|
||||
// Unsubscribe events
|
||||
this.subscriber.off('notesStream', this.onNote);
|
||||
|
@@ -1,24 +1,26 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import { isMutedUserRelated } from '@/misc/is-muted-user-related';
|
||||
import Channel from '../channel';
|
||||
import { Notes } from '@/models/index';
|
||||
import { checkWordMute } from '@/misc/check-word-mute';
|
||||
import { isBlockerUserRelated } from '@/misc/is-blocker-user-related';
|
||||
import { isInstanceMuted } from '@/misc/is-instance-muted';
|
||||
import { Packed } from '@/misc/schema';
|
||||
import { isMutedUserRelated } from '@/misc/is-muted-user-related.js';
|
||||
import Channel from '../channel.js';
|
||||
import { Notes } from '@/models/index.js';
|
||||
import { checkWordMute } from '@/misc/check-word-mute.js';
|
||||
import { isBlockerUserRelated } from '@/misc/is-blocker-user-related.js';
|
||||
import { isInstanceMuted } from '@/misc/is-instance-muted.js';
|
||||
import { Packed } from '@/misc/schema.js';
|
||||
|
||||
export default class extends Channel {
|
||||
public readonly chName = 'homeTimeline';
|
||||
public static shouldShare = true;
|
||||
public static requireCredential = true;
|
||||
|
||||
@autobind
|
||||
constructor(id: string, connection: Channel['connection']) {
|
||||
super(id, connection);
|
||||
this.onNote = this.onNote.bind(this);
|
||||
}
|
||||
|
||||
public async init(params: any) {
|
||||
// Subscribe events
|
||||
this.subscriber.on('notesStream', this.onNote);
|
||||
}
|
||||
|
||||
@autobind
|
||||
private async onNote(note: Packed<'Note'>) {
|
||||
if (note.channelId) {
|
||||
if (!this.followingChannels.has(note.channelId)) return;
|
||||
@@ -77,7 +79,6 @@ export default class extends Channel {
|
||||
this.send('note', note);
|
||||
}
|
||||
|
||||
@autobind
|
||||
public dispose() {
|
||||
// Unsubscribe events
|
||||
this.subscriber.off('notesStream', this.onNote);
|
||||
|
@@ -1,19 +1,22 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import { isMutedUserRelated } from '@/misc/is-muted-user-related';
|
||||
import Channel from '../channel';
|
||||
import { fetchMeta } from '@/misc/fetch-meta';
|
||||
import { Notes } from '@/models/index';
|
||||
import { checkWordMute } from '@/misc/check-word-mute';
|
||||
import { isBlockerUserRelated } from '@/misc/is-blocker-user-related';
|
||||
import { isInstanceMuted } from '@/misc/is-instance-muted';
|
||||
import { Packed } from '@/misc/schema';
|
||||
import { isMutedUserRelated } from '@/misc/is-muted-user-related.js';
|
||||
import Channel from '../channel.js';
|
||||
import { fetchMeta } from '@/misc/fetch-meta.js';
|
||||
import { Notes } from '@/models/index.js';
|
||||
import { checkWordMute } from '@/misc/check-word-mute.js';
|
||||
import { isBlockerUserRelated } from '@/misc/is-blocker-user-related.js';
|
||||
import { isInstanceMuted } from '@/misc/is-instance-muted.js';
|
||||
import { Packed } from '@/misc/schema.js';
|
||||
|
||||
export default class extends Channel {
|
||||
public readonly chName = 'hybridTimeline';
|
||||
public static shouldShare = true;
|
||||
public static requireCredential = true;
|
||||
|
||||
@autobind
|
||||
constructor(id: string, connection: Channel['connection']) {
|
||||
super(id, connection);
|
||||
this.onNote = this.onNote.bind(this);
|
||||
}
|
||||
|
||||
public async init(params: any) {
|
||||
const meta = await fetchMeta();
|
||||
if (meta.disableLocalTimeline && !this.user!.isAdmin && !this.user!.isModerator) return;
|
||||
@@ -22,7 +25,6 @@ export default class extends Channel {
|
||||
this.subscriber.on('notesStream', this.onNote);
|
||||
}
|
||||
|
||||
@autobind
|
||||
private async onNote(note: Packed<'Note'>) {
|
||||
// チャンネルの投稿ではなく、自分自身の投稿 または
|
||||
// チャンネルの投稿ではなく、その投稿のユーザーをフォローしている または
|
||||
@@ -85,7 +87,6 @@ export default class extends Channel {
|
||||
this.send('note', note);
|
||||
}
|
||||
|
||||
@autobind
|
||||
public dispose() {
|
||||
// Unsubscribe events
|
||||
this.subscriber.off('notesStream', this.onNote);
|
||||
|
@@ -1,18 +1,18 @@
|
||||
import main from './main';
|
||||
import homeTimeline from './home-timeline';
|
||||
import localTimeline from './local-timeline';
|
||||
import hybridTimeline from './hybrid-timeline';
|
||||
import globalTimeline from './global-timeline';
|
||||
import serverStats from './server-stats';
|
||||
import queueStats from './queue-stats';
|
||||
import userList from './user-list';
|
||||
import antenna from './antenna';
|
||||
import messaging from './messaging';
|
||||
import messagingIndex from './messaging-index';
|
||||
import drive from './drive';
|
||||
import hashtag from './hashtag';
|
||||
import channel from './channel';
|
||||
import admin from './admin';
|
||||
import main from './main.js';
|
||||
import homeTimeline from './home-timeline.js';
|
||||
import localTimeline from './local-timeline.js';
|
||||
import hybridTimeline from './hybrid-timeline.js';
|
||||
import globalTimeline from './global-timeline.js';
|
||||
import serverStats from './server-stats.js';
|
||||
import queueStats from './queue-stats.js';
|
||||
import userList from './user-list.js';
|
||||
import antenna from './antenna.js';
|
||||
import messaging from './messaging.js';
|
||||
import messagingIndex from './messaging-index.js';
|
||||
import drive from './drive.js';
|
||||
import hashtag from './hashtag.js';
|
||||
import channel from './channel.js';
|
||||
import admin from './admin.js';
|
||||
|
||||
export default {
|
||||
main,
|
||||
|
@@ -1,18 +1,21 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import { isMutedUserRelated } from '@/misc/is-muted-user-related';
|
||||
import Channel from '../channel';
|
||||
import { fetchMeta } from '@/misc/fetch-meta';
|
||||
import { Notes } from '@/models/index';
|
||||
import { checkWordMute } from '@/misc/check-word-mute';
|
||||
import { isBlockerUserRelated } from '@/misc/is-blocker-user-related';
|
||||
import { Packed } from '@/misc/schema';
|
||||
import { isMutedUserRelated } from '@/misc/is-muted-user-related.js';
|
||||
import Channel from '../channel.js';
|
||||
import { fetchMeta } from '@/misc/fetch-meta.js';
|
||||
import { Notes } from '@/models/index.js';
|
||||
import { checkWordMute } from '@/misc/check-word-mute.js';
|
||||
import { isBlockerUserRelated } from '@/misc/is-blocker-user-related.js';
|
||||
import { Packed } from '@/misc/schema.js';
|
||||
|
||||
export default class extends Channel {
|
||||
public readonly chName = 'localTimeline';
|
||||
public static shouldShare = true;
|
||||
public static requireCredential = false;
|
||||
|
||||
@autobind
|
||||
constructor(id: string, connection: Channel['connection']) {
|
||||
super(id, connection);
|
||||
this.onNote = this.onNote.bind(this);
|
||||
}
|
||||
|
||||
public async init(params: any) {
|
||||
const meta = await fetchMeta();
|
||||
if (meta.disableLocalTimeline) {
|
||||
@@ -23,7 +26,6 @@ export default class extends Channel {
|
||||
this.subscriber.on('notesStream', this.onNote);
|
||||
}
|
||||
|
||||
@autobind
|
||||
private async onNote(note: Packed<'Note'>) {
|
||||
if (note.user.host !== null) return;
|
||||
if (note.visibility !== 'public') return;
|
||||
@@ -66,7 +68,6 @@ export default class extends Channel {
|
||||
this.send('note', note);
|
||||
}
|
||||
|
||||
@autobind
|
||||
public dispose() {
|
||||
// Unsubscribe events
|
||||
this.subscriber.off('notesStream', this.onNote);
|
||||
|
@@ -1,14 +1,12 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Channel from '../channel';
|
||||
import { Notes } from '@/models/index';
|
||||
import { isInstanceMuted, isUserFromMutedInstance } from '@/misc/is-instance-muted';
|
||||
import Channel from '../channel.js';
|
||||
import { Notes } from '@/models/index.js';
|
||||
import { isInstanceMuted, isUserFromMutedInstance } from '@/misc/is-instance-muted.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 => {
|
||||
|
@@ -1,12 +1,10 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Channel from '../channel';
|
||||
import Channel from '../channel.js';
|
||||
|
||||
export default class extends Channel {
|
||||
public readonly chName = 'messagingIndex';
|
||||
public static shouldShare = true;
|
||||
public static requireCredential = true;
|
||||
|
||||
@autobind
|
||||
public async init(params: any) {
|
||||
// Subscribe messaging index stream
|
||||
this.subscriber.on(`messagingIndexStream:${this.user!.id}`, data => {
|
||||
|
@@ -1,10 +1,9 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import { readUserMessagingMessage, readGroupMessagingMessage, deliverReadActivity } from '../../common/read-messaging-message';
|
||||
import Channel from '../channel';
|
||||
import { UserGroupJoinings, Users, MessagingMessages } from '@/models/index';
|
||||
import { User, ILocalUser, IRemoteUser } from '@/models/entities/user';
|
||||
import { UserGroup } from '@/models/entities/user-group';
|
||||
import { StreamMessages } from '../types';
|
||||
import { readUserMessagingMessage, readGroupMessagingMessage, deliverReadActivity } from '../../common/read-messaging-message.js';
|
||||
import Channel from '../channel.js';
|
||||
import { UserGroupJoinings, Users, MessagingMessages } from '@/models/index.js';
|
||||
import { User, ILocalUser, IRemoteUser } from '@/models/entities/user.js';
|
||||
import { UserGroup } from '@/models/entities/user-group.js';
|
||||
import { StreamMessages } from '../types.js';
|
||||
|
||||
export default class extends Channel {
|
||||
public readonly chName = 'messaging';
|
||||
@@ -18,7 +17,13 @@ export default class extends Channel {
|
||||
private typers: Record<User['id'], Date> = {};
|
||||
private emitTypersIntervalId: ReturnType<typeof setInterval>;
|
||||
|
||||
@autobind
|
||||
constructor(id: string, connection: Channel['connection']) {
|
||||
super(id, connection);
|
||||
this.onEvent = this.onEvent.bind(this);
|
||||
this.onMessage = this.onMessage.bind(this);
|
||||
this.emitTypers = this.emitTypers.bind(this);
|
||||
}
|
||||
|
||||
public async init(params: any) {
|
||||
this.otherpartyId = params.otherparty;
|
||||
this.otherparty = this.otherpartyId ? await Users.findOneOrFail({ id: this.otherpartyId }) : null;
|
||||
@@ -46,7 +51,6 @@ export default class extends Channel {
|
||||
this.subscriber.on(this.subCh, this.onEvent);
|
||||
}
|
||||
|
||||
@autobind
|
||||
private onEvent(data: StreamMessages['messaging']['payload'] | StreamMessages['groupMessaging']['payload']) {
|
||||
if (data.type === 'typing') {
|
||||
const id = data.body;
|
||||
@@ -60,7 +64,6 @@ export default class extends Channel {
|
||||
}
|
||||
}
|
||||
|
||||
@autobind
|
||||
public onMessage(type: string, body: any) {
|
||||
switch (type) {
|
||||
case 'read':
|
||||
@@ -80,7 +83,6 @@ export default class extends Channel {
|
||||
}
|
||||
}
|
||||
|
||||
@autobind
|
||||
private async emitTypers() {
|
||||
const now = new Date();
|
||||
|
||||
@@ -97,7 +99,6 @@ export default class extends Channel {
|
||||
});
|
||||
}
|
||||
|
||||
@autobind
|
||||
public dispose() {
|
||||
this.subscriber.off(this.subCh, this.onEvent);
|
||||
|
||||
|
@@ -1,25 +1,27 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Xev from 'xev';
|
||||
import Channel from '../channel';
|
||||
import { default as Xev } from 'xev';
|
||||
import Channel from '../channel.js';
|
||||
|
||||
const ev = new Xev();
|
||||
const ev = new Xev.default();
|
||||
|
||||
export default class extends Channel {
|
||||
public readonly chName = 'queueStats';
|
||||
public static shouldShare = true;
|
||||
public static requireCredential = false;
|
||||
|
||||
@autobind
|
||||
constructor(id: string, connection: Channel['connection']) {
|
||||
super(id, connection);
|
||||
this.onStats = this.onStats.bind(this);
|
||||
this.onMessage = this.onMessage.bind(this);
|
||||
}
|
||||
|
||||
public async init(params: any) {
|
||||
ev.addListener('queueStats', this.onStats);
|
||||
}
|
||||
|
||||
@autobind
|
||||
private onStats(stats: any) {
|
||||
this.send('stats', stats);
|
||||
}
|
||||
|
||||
@autobind
|
||||
public onMessage(type: string, body: any) {
|
||||
switch (type) {
|
||||
case 'requestLog':
|
||||
@@ -34,7 +36,6 @@ export default class extends Channel {
|
||||
}
|
||||
}
|
||||
|
||||
@autobind
|
||||
public dispose() {
|
||||
ev.removeListener('queueStats', this.onStats);
|
||||
}
|
||||
|
@@ -1,25 +1,27 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Xev from 'xev';
|
||||
import Channel from '../channel';
|
||||
import { default as Xev } from 'xev';
|
||||
import Channel from '../channel.js';
|
||||
|
||||
const ev = new Xev();
|
||||
const ev = new Xev.default();
|
||||
|
||||
export default class extends Channel {
|
||||
public readonly chName = 'serverStats';
|
||||
public static shouldShare = true;
|
||||
public static requireCredential = false;
|
||||
|
||||
@autobind
|
||||
constructor(id: string, connection: Channel['connection']) {
|
||||
super(id, connection);
|
||||
this.onStats = this.onStats.bind(this);
|
||||
this.onMessage = this.onMessage.bind(this);
|
||||
}
|
||||
|
||||
public async init(params: any) {
|
||||
ev.addListener('serverStats', this.onStats);
|
||||
}
|
||||
|
||||
@autobind
|
||||
private onStats(stats: any) {
|
||||
this.send('stats', stats);
|
||||
}
|
||||
|
||||
@autobind
|
||||
public onMessage(type: string, body: any) {
|
||||
switch (type) {
|
||||
case 'requestLog':
|
||||
@@ -34,7 +36,6 @@ export default class extends Channel {
|
||||
}
|
||||
}
|
||||
|
||||
@autobind
|
||||
public dispose() {
|
||||
ev.removeListener('serverStats', this.onStats);
|
||||
}
|
||||
|
@@ -1,10 +1,9 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Channel from '../channel';
|
||||
import { Notes, UserListJoinings, UserLists } from '@/models/index';
|
||||
import { isMutedUserRelated } from '@/misc/is-muted-user-related';
|
||||
import { User } from '@/models/entities/user';
|
||||
import { isBlockerUserRelated } from '@/misc/is-blocker-user-related';
|
||||
import { Packed } from '@/misc/schema';
|
||||
import Channel from '../channel.js';
|
||||
import { Notes, UserListJoinings, UserLists } from '@/models/index.js';
|
||||
import { isMutedUserRelated } from '@/misc/is-muted-user-related.js';
|
||||
import { User } from '@/models/entities/user.js';
|
||||
import { isBlockerUserRelated } from '@/misc/is-blocker-user-related.js';
|
||||
import { Packed } from '@/misc/schema.js';
|
||||
|
||||
export default class extends Channel {
|
||||
public readonly chName = 'userList';
|
||||
@@ -14,7 +13,12 @@ export default class extends Channel {
|
||||
public listUsers: User['id'][] = [];
|
||||
private listUsersClock: NodeJS.Timer;
|
||||
|
||||
@autobind
|
||||
constructor(id: string, connection: Channel['connection']) {
|
||||
super(id, connection);
|
||||
this.updateListUsers = this.updateListUsers.bind(this);
|
||||
this.onNote = this.onNote.bind(this);
|
||||
}
|
||||
|
||||
public async init(params: any) {
|
||||
this.listId = params.listId as string;
|
||||
|
||||
@@ -34,7 +38,6 @@ export default class extends Channel {
|
||||
this.listUsersClock = setInterval(this.updateListUsers, 5000);
|
||||
}
|
||||
|
||||
@autobind
|
||||
private async updateListUsers() {
|
||||
const users = await UserListJoinings.find({
|
||||
where: {
|
||||
@@ -46,7 +49,6 @@ export default class extends Channel {
|
||||
this.listUsers = users.map(x => x.userId);
|
||||
}
|
||||
|
||||
@autobind
|
||||
private async onNote(note: Packed<'Note'>) {
|
||||
if (!this.listUsers.includes(note.userId)) return;
|
||||
|
||||
@@ -81,7 +83,6 @@ export default class extends Channel {
|
||||
this.send('note', note);
|
||||
}
|
||||
|
||||
@autobind
|
||||
public dispose() {
|
||||
// Unsubscribe events
|
||||
this.subscriber.off(`userListStream:${this.listId}`, this.send);
|
||||
|
Reference in New Issue
Block a user