Do federation wakeup/stop
This commit is contained in:
parent
435d1d8f98
commit
9fa5a378e1
9 changed files with 140 additions and 12 deletions
|
|
@ -40,25 +40,27 @@ func (h *Hour) UnmarshalJSON(src []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func GetNextAlarm(cfg *config.Config, db *LevelDBStorage) (*time.Time, []Identifier, error) {
|
||||
func GetNextAlarm(cfg *config.Config, db *LevelDBStorage) (*time.Time, []Identifier, bool, error) {
|
||||
alarmsRepeated, err := GetAlarmsRepeated(db)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
return nil, nil, false, err
|
||||
}
|
||||
|
||||
var closestAlarm *time.Time
|
||||
var closestAlarmRoutines []Identifier
|
||||
var closestAlarmFederated bool
|
||||
for _, alarm := range alarmsRepeated {
|
||||
next := alarm.GetNextOccurence(cfg, db)
|
||||
if next != nil && (closestAlarm == nil || closestAlarm.After(*next)) {
|
||||
closestAlarm = next
|
||||
closestAlarmRoutines = alarm.FollowingRoutines
|
||||
closestAlarmFederated = alarm.EnableFederation
|
||||
}
|
||||
}
|
||||
|
||||
alarmsSingle, err := GetAlarmsSingle(db)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
return nil, nil, false, err
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
|
|
@ -66,10 +68,11 @@ func GetNextAlarm(cfg *config.Config, db *LevelDBStorage) (*time.Time, []Identif
|
|||
if closestAlarm == nil || (closestAlarm.After(alarm.Time) && alarm.Time.After(now)) {
|
||||
closestAlarm = &alarm.Time
|
||||
closestAlarmRoutines = alarm.FollowingRoutines
|
||||
closestAlarmFederated = alarm.EnableFederation
|
||||
}
|
||||
}
|
||||
|
||||
return closestAlarm, closestAlarmRoutines, nil
|
||||
return closestAlarm, closestAlarmRoutines, closestAlarmFederated, nil
|
||||
}
|
||||
|
||||
func GetNextException(cfg *config.Config, db *LevelDBStorage) (*time.Time, error) {
|
||||
|
|
@ -90,7 +93,7 @@ func GetNextException(cfg *config.Config, db *LevelDBStorage) (*time.Time, error
|
|||
}
|
||||
|
||||
func DropNextAlarm(cfg *config.Config, db *LevelDBStorage) error {
|
||||
timenext, _, err := GetNextAlarm(cfg, db)
|
||||
timenext, _, _, err := GetNextAlarm(cfg, db)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue