Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement MAB's UserActivityTracker and blocking the bridge upon exceeding the user limit #1472

Merged
merged 10 commits into from
Oct 8, 2021
7 changes: 7 additions & 0 deletions config.schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ properties:
type: "string"
RMAUlimit:
type: "integer"
userActivity:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also the sample config?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In in c0e3c2e

type: "object"
properties:
minUserActiveDays:
type: "number"
inactiveAfterDays:
type: "number"
matrixHandler:
type: "object"
properties:
Expand Down
11 changes: 10 additions & 1 deletion src/bridge/IrcBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,17 @@ export class IrcBridge {
throw Error("No IRC servers specified.");
}

const uatConfig = {
...UserActivityTrackerConfig.DEFAULT,
};
if (this.config.ircService.userActivity?.minUserActiveDays !== undefined) {
uatConfig.minUserActiveDays = this.config.ircService.userActivity.minUserActiveDays;
}
if (this.config.ircService.userActivity?.inactiveAfterDays !== undefined) {
uatConfig.inactiveAfterDays = this.config.ircService.userActivity.inactiveAfterDays;
}
this.bridge.opts.controller.userActivityTracker = new UserActivityTracker(
UserActivityTrackerConfig.DEFAULT,
uatConfig,
await this.getStore().getUserActivity(),
(changes) => this.onUserActivityChanged(changes),
);
Expand Down
4 changes: 4 additions & 0 deletions src/config/BridgeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ export interface BridgeConfig {
};
perRoomConfig?: RoomConfigConfig;
RMAUlimit?: number;
userActivity?: {
minUserActiveDays?: number;
inactiveAfterDays?: number;
};
};
sentry?: {
enabled: boolean;
Expand Down