Fix #626: Bot timer was buggy, using seconds as delay instead of minutes.

There was a regression some months ago in the "bot timer" functionnality.
In the channels settings, the delay between two quotes is supposed to be in minutes, but in fact we applied seconds.
We don't have any way to detect if the user meant seconds or minutes when they configured their channels (it depends if it was before or after the regression).
So we encourage all streamers to go through their channel settings, check the frequency of their bot timers (if enabled), set them to the correct value, and save the form.
Users must save the form to be sure to apply the correct value.
This commit is contained in:
John Livingston 2025-05-21 17:51:54 +02:00
parent 078515572e
commit 60ea2b4ed0
No known key found for this signature in database
GPG Key ID: B17B5640CE66CDBC
2 changed files with 37 additions and 3 deletions

View File

@ -1,6 +1,14 @@
# Changelog
## ??? (Not Released Yet)
## 13.0.0 (Not Released Yet)
### Breaking changes
There was a regression some months ago in the "bot timer" functionnality.
In the channels settings, the delay between two quotes is supposed to be in minutes, but in fact we applied seconds.
We don't have any way to detect if the user meant seconds or minutes when they configured their channels (it depends if it was before or after the regression).
So we encourage all streamers to go through their channel settings, check the frequency of their bot timers (if enabled), set them to the correct value, and save the form.
Users must save the form to be sure to apply the correct value.
### Minor changes and fixes
@ -16,6 +24,7 @@
* Fix moderation notes: fix filter button wrongly displayed on notes without associated occupant.
* Fix tasks: checkbox state does not change when clicked.
* Fix: bot timer can't be negative or null.
* Fix #626: Bot timer was buggy, using seconds as delay instead of minutes.
## 12.0.4

View File

@ -151,6 +151,29 @@ export class ChannelDetailsService {
return true
}
frontToBack = (channelConfigurationOptions: ChannelConfigurationOptions): ChannelConfigurationOptions => {
// // This is a dirty hack, because backend wants seconds for botConf.quotes.delay, and front wants minutes.
const c = JSON.parse(JSON.stringify(channelConfigurationOptions)) as ChannelConfigurationOptions // clone
c.bot?.quotes.forEach(q => {
if (typeof q.delay === 'number') {
q.delay = Math.round(q.delay * 60)
}
})
return c
}
backToFront = (channelConfiguration: any): ChannelConfiguration => {
// This is a dirty hack, because backend wants seconds for botConf.quotes.delay, and front wants minutes.
const c = JSON.parse(JSON.stringify(channelConfiguration)) as ChannelConfiguration // clone
c.configuration.bot?.quotes.forEach(q => {
if (typeof q.delay === 'number') {
q.delay = Math.round(q.delay / 60)
if (q.delay < 1) { q.delay = 1 }
}
})
return c
}
saveOptions = async (channelId: number,
channelConfigurationOptions: ChannelConfigurationOptions): Promise<Response> => {
if (!await this.validateOptions(channelConfigurationOptions)) {
@ -162,7 +185,9 @@ export class ChannelDetailsService {
{
method: 'POST',
headers: this._headers,
body: JSON.stringify(channelConfigurationOptions)
body: JSON.stringify(
this.frontToBack(channelConfigurationOptions)
)
}
)
@ -218,7 +243,7 @@ export class ChannelDetailsService {
throw new Error('Can\'t get channel configuration options.')
}
return response.json()
return this.backToFront(await response.json())
}
public async fetchEmojisConfiguration (channelId: number): Promise<ChannelEmojisConfiguration> {