disableLocalTimeline機能を強化

* ストリームだけではなくAPIも無効に
* モデレーターは無効の場合でも見れるように
* グローバルタイムラインも無効に(連合数が少ないインスタンスではグローバルタイムラインは実質的にローカルタイムラインと同一なので)
This commit is contained in:
syuilo
2019-01-16 02:30:55 +09:00
parent c8e2b22942
commit c2f6b09969
7 changed files with 38 additions and 18 deletions

View File

@ -3,6 +3,7 @@ import Mute from '../../../../models/mute';
import { pack } from '../../../../models/note';
import shouldMuteThisNote from '../../../../misc/should-mute-this-note';
import Channel from '../channel';
import fetchMeta from '../../../../misc/fetch-meta';
export default class extends Channel {
public readonly chName = 'globalTimeline';
@ -13,6 +14,11 @@ export default class extends Channel {
@autobind
public async init(params: any) {
const meta = await fetchMeta();
if (meta.disableLocalTimeline) {
if (this.user == null || (!this.user.isAdmin && !this.user.isModerator)) return;
}
// Subscribe events
this.subscriber.on('globalTimeline', this.onNote);

View File

@ -3,6 +3,7 @@ import Mute from '../../../../models/mute';
import { pack } from '../../../../models/note';
import shouldMuteThisNote from '../../../../misc/should-mute-this-note';
import Channel from '../channel';
import fetchMeta from '../../../../misc/fetch-meta';
export default class extends Channel {
public readonly chName = 'hybridTimeline';
@ -13,6 +14,9 @@ export default class extends Channel {
@autobind
public async init(params: any) {
const meta = await fetchMeta();
if (meta.disableLocalTimeline && !this.user.isAdmin && !this.user.isModerator) return;
// Subscribe events
this.subscriber.on('hybridTimeline', this.onNewNote);
this.subscriber.on(`hybridTimeline:${this.user._id}`, this.onNewNote);

View File

@ -3,6 +3,7 @@ import Mute from '../../../../models/mute';
import { pack } from '../../../../models/note';
import shouldMuteThisNote from '../../../../misc/should-mute-this-note';
import Channel from '../channel';
import fetchMeta from '../../../../misc/fetch-meta';
export default class extends Channel {
public readonly chName = 'localTimeline';
@ -13,6 +14,11 @@ export default class extends Channel {
@autobind
public async init(params: any) {
const meta = await fetchMeta();
if (meta.disableLocalTimeline) {
if (this.user == null || (!this.user.isAdmin && !this.user.isModerator)) return;
}
// Subscribe events
this.subscriber.on('localTimeline', this.onNote);