From b023e3850004a08ed3d70a1c82fc2588cacf6b1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tadeusz=20So=C5=9Bnierz?= Date: Fri, 8 Oct 2021 13:35:26 +0200 Subject: [PATCH 1/4] Make UserActivityTracker configurable --- config/slack-config-schema.yaml | 9 ++++++++- src/IConfig.ts | 4 ++++ src/Main.ts | 12 +++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) 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..0909468c 100644 --- a/src/Main.ts +++ b/src/Main.ts @@ -1153,8 +1153,18 @@ export class Main { await teamSyncPromise; if (!(this.datastore instanceof NedbDatastore)) { + const uatConfig = { + ...UserActivityTrackerConfig.DEFAULT, + }; + log.warn('user_activity settings:', this.config.user_activity); + 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), ); From 9448a81059bc304ab7c92f70b837d29e80d33c46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tadeusz=20So=C5=9Bnierz?= Date: Fri, 8 Oct 2021 14:10:52 +0200 Subject: [PATCH 2/4] Remove debugging leftovers --- src/Main.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Main.ts b/src/Main.ts index 0909468c..e8b3f193 100644 --- a/src/Main.ts +++ b/src/Main.ts @@ -1156,7 +1156,6 @@ export class Main { const uatConfig = { ...UserActivityTrackerConfig.DEFAULT, }; - log.warn('user_activity settings:', this.config.user_activity); if (this.config.user_activity?.min_user_active_days !== undefined) { uatConfig.minUserActiveDays = this.config.user_activity!.min_user_active_days!; } From f51f946985756e0f4f827b2f3ccfe30e9037af13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tadeusz=20So=C5=9Bnierz?= Date: Fri, 8 Oct 2021 14:11:06 +0200 Subject: [PATCH 3/4] Remove unnecessary definedness checks --- src/Main.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Main.ts b/src/Main.ts index e8b3f193..b73506b4 100644 --- a/src/Main.ts +++ b/src/Main.ts @@ -1157,10 +1157,10 @@ export class Main { ...UserActivityTrackerConfig.DEFAULT, }; if (this.config.user_activity?.min_user_active_days !== undefined) { - uatConfig.minUserActiveDays = this.config.user_activity!.min_user_active_days!; + 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!; + uatConfig.inactiveAfterDays = this.config.user_activity.inactive_after_days; } this.bridge.opts.controller.userActivityTracker = new UserActivityTracker( uatConfig, From 66b903124015b68aaf83c0734b0fc6d1c7882597 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tadeusz=20So=C5=9Bnierz?= Date: Fri, 8 Oct 2021 14:12:08 +0200 Subject: [PATCH 4/4] Add changelog entry for #623 --- changelog.d/623.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/623.feature 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