Skip to content

Commit

Permalink
Merge pull request #623 from matrix-org/tadzik/configurable-activity-…
Browse files Browse the repository at this point in the history
…tracker

Make UserActivityTracker configurable
  • Loading branch information
tadzik authored Oct 8, 2021
2 parents 674f815 + 66b9031 commit 25a4209
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.d/623.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make UserActivityTracker configurable
9 changes: 8 additions & 1 deletion config/slack-config-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ properties:
type: string
crt_file:
type: string
user_activity:
type: object
properties:
min_user_active_days:
type: number
inactive_after_days:
type: number
rtm:
type: object
required: ["enable"]
Expand Down Expand Up @@ -182,4 +189,4 @@ properties:
type: boolean
pantalaimon_url:
type: string
required: ["enabled"]
required: ["enabled"]
4 changes: 4 additions & 0 deletions src/IConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export interface IConfig {
matrix_admin_room?: string;

rmau_limit?: number;
user_activity?: {
min_user_active_days?: number;
inactive_after_days?: number;
};

homeserver: {
url: string;
Expand Down
11 changes: 10 additions & 1 deletion src/Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1153,8 +1153,17 @@ export class Main {
await teamSyncPromise;

if (!(this.datastore instanceof NedbDatastore)) {
const uatConfig = {
...UserActivityTrackerConfig.DEFAULT,
};
if (this.config.user_activity?.min_user_active_days !== undefined) {
uatConfig.minUserActiveDays = this.config.user_activity.min_user_active_days;
}
if (this.config.user_activity?.inactive_after_days !== undefined) {
uatConfig.inactiveAfterDays = this.config.user_activity.inactive_after_days;
}
this.bridge.opts.controller.userActivityTracker = new UserActivityTracker(
UserActivityTrackerConfig.DEFAULT,
uatConfig,
await this.datastore.getUserActivity(),
async (changes) => this.onUserActivityChanged(changes),
);
Expand Down

0 comments on commit 25a4209

Please sign in to comment.