also save last execution time for trigger

should fix #462
This commit is contained in:
Radu Ioan Fericean
2016-06-17 17:14:38 +03:00
parent 590929b9cb
commit 0a29617002

View File

@@ -43,15 +43,15 @@ type ActionTrigger struct {
ActionsID string
MinQueuedItems int // Trigger actions only if this number is hit (stats only)
Executed bool
lastExecutionTime time.Time
LastExecutionTime time.Time
}
func (at *ActionTrigger) Execute(ub *Account, sq *StatsQueueTriggered) (err error) {
// check for min sleep time
if at.Recurrent && !at.lastExecutionTime.IsZero() && time.Since(at.lastExecutionTime) < at.MinSleep {
if at.Recurrent && !at.LastExecutionTime.IsZero() && time.Since(at.LastExecutionTime) < at.MinSleep {
return
}
at.lastExecutionTime = time.Now()
at.LastExecutionTime = time.Now()
if ub != nil && ub.Disabled {
return fmt.Errorf("User %s is disabled and there are triggers in action!", ub.ID)
}