mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-02-05 14:17:49 +01:00
Change other state when the other is updated
This commit is contained in:
@@ -19,6 +19,7 @@ export default class StatesController {
|
|||||||
public async setSleeping ({ request, response }: HttpContextContract) {
|
public async setSleeping ({ request, response }: HttpContextContract) {
|
||||||
const { value } = await request.validate(StateSleepingValidator)
|
const { value } = await request.validate(StateSleepingValidator)
|
||||||
await Redis.set('states:sleeping', String(value))
|
await Redis.set('states:sleeping', String(value))
|
||||||
|
await Redis.set('states:developing', String(!value))
|
||||||
return response.status(200).send({
|
return response.status(200).send({
|
||||||
message: 'State was successfully set!',
|
message: 'State was successfully set!',
|
||||||
value: this.formatValue(String(value))
|
value: this.formatValue(String(value))
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ async function getCurrentTime(): Promise<void> {
|
|||||||
|
|
||||||
if (redis_state !== active) {
|
if (redis_state !== active) {
|
||||||
await Redis.set('states:developing', String(active))
|
await Redis.set('states:developing', String(active))
|
||||||
|
await Redis.set('states:sleeping', String(!active))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user