diff --git a/changelog.d/623.feature b/changelog.d/623.feature new file mode 100644 index 00000000..f6a5846f --- /dev/null +++ b/changelog.d/623.feature @@ -0,0 +1 @@ +Make UserActivityTracker configurable diff --git a/config/slack-config-schema.yaml b/config/slack-config-schema.yaml index 234130bc..5c73957b 100644 --- a/config/slack-config-schema.yaml +++ b/config/slack-config-schema.yaml @@ -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"] @@ -182,4 +189,4 @@ properties: type: boolean pantalaimon_url: type: string - required: ["enabled"] \ No newline at end of file + required: ["enabled"] diff --git a/src/IConfig.ts b/src/IConfig.ts index e9c60500..107e2dbb 100644 --- a/src/IConfig.ts +++ b/src/IConfig.ts @@ -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; diff --git a/src/Main.ts b/src/Main.ts index fe68ca26..b73506b4 100644 --- a/src/Main.ts +++ b/src/Main.ts @@ -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), );