-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix!: LDAP sync triggers multiple cron jobs in case an invalid sync i…
…nterval is provided (#32285) * fix: use settings' packageValue as a fallback to LDAP sync intervals * fix: add migration to update the packageValue of LDAP sync interval settings --------- Co-authored-by: Marcos Spessatto Defendi <[email protected]>
- Loading branch information
1 parent
82d1ac2
commit 374979f
Showing
6 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@rocket.chat/meteor": major | ||
--- | ||
|
||
Fixed issue with LDAP sync triggering multiple cron jobs in case an invalid sync interval is provided |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,5 +40,6 @@ import './v304'; | |
import './v305'; | ||
import './v306'; | ||
import './v307'; | ||
import './v308'; | ||
|
||
export * from './xrun'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import type { ISetting } from '@rocket.chat/core-typings'; | ||
import { Settings } from '@rocket.chat/models'; | ||
import { isValidCron } from 'cron-validator'; | ||
|
||
import { addMigration } from '../../lib/migrations'; | ||
|
||
addMigration({ | ||
version: 308, | ||
name: 'Update packageValue from LDAP interval settings', | ||
async up() { | ||
const newAvatarSyncPackageValue = '0 0 * * *'; | ||
const newAutoLogoutPackageValue = '*/5 * * * *'; | ||
const ldapAvatarSyncInterval = await Settings.findOneById<Pick<ISetting, 'value'>>('LDAP_Background_Sync_Avatars_Interval', { | ||
projection: { value: 1 }, | ||
}); | ||
const ldapAutoLogoutInterval = await Settings.findOneById<Pick<ISetting, 'value'>>('LDAP_Sync_AutoLogout_Interval', { | ||
projection: { value: 1 }, | ||
}); | ||
const isValidAvatarSyncInterval = ldapAvatarSyncInterval && isValidCron(ldapAvatarSyncInterval.value as string); | ||
const isValidAutoLogoutInterval = ldapAutoLogoutInterval && isValidCron(ldapAutoLogoutInterval.value as string); | ||
|
||
await Settings.updateOne( | ||
{ _id: 'LDAP_Background_Sync_Avatars_Interval' }, | ||
{ $set: { packageValue: newAvatarSyncPackageValue, ...(!isValidAvatarSyncInterval && { value: newAvatarSyncPackageValue }) } }, | ||
); | ||
await Settings.updateOne( | ||
{ _id: 'LDAP_Sync_AutoLogout_Interval' }, | ||
{ $set: { packageValue: newAutoLogoutPackageValue, ...(!isValidAutoLogoutInterval && { value: newAutoLogoutPackageValue }) } }, | ||
); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters