Skip to content

Commit

Permalink
hideServerInfoでもadminなどは許可するように Resolve #4913
Browse files Browse the repository at this point in the history
  • Loading branch information
mei23 committed Apr 2, 2024
1 parent 9ba938d commit 14d70fb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 0 additions & 2 deletions src/daemons/server-stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ export default function() {
if (log.length > 200) log.pop();
}

if (config.hideServerInfo) return;

tick();

setInterval(tick, interval);
Expand Down
11 changes: 6 additions & 5 deletions src/server/api/stream/channels/server-stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,23 @@ const ev = new Xev();

export default class extends Channel {
public readonly chName = 'serverStats';
public static requireCredential = false;
public static requireCredential = true;
private active = false;

@autobind
public async init(params: any) {
ev.addListener('serverStats', this.onStats);
this.active = !config.hideServerInfo || !!(this.user?.isAdmin || this.user?.isModerator);
if (this.active) ev.addListener('serverStats', this.onStats);
}

@autobind
private onStats(stats: any) {
if (config.hideServerInfo) return;
this.send('stats', stats);
}

@autobind
public onMessage(type: string, body: any) {
if (config.hideServerInfo) return;
if (!this.active) return;
switch (type) {
case 'requestLog':
ev.once(`serverStatsLog:${body.id}`, statsLog => {
Expand All @@ -38,6 +39,6 @@ export default class extends Channel {

@autobind
public dispose() {
ev.removeListener('serverStats', this.onStats);
if (this.active) ev.removeListener('serverStats', this.onStats);
}
}

0 comments on commit 14d70fb

Please sign in to comment.