@ -17,13 +17,15 @@ type Config interface {
DoRunAtStart ( ) bool
DoRunAtStart ( ) bool
GetSchedule ( ) string
GetSchedule ( ) string
FormatMessage ( name , status string , doer * models . User , args ... interface { } ) string
FormatMessage ( name , status string , doer * models . User , args ... interface { } ) string
DoNoticeOnSuccess ( ) bool
}
}
// BaseConfig represents the basic config for a Cron task
// BaseConfig represents the basic config for a Cron task
type BaseConfig struct {
type BaseConfig struct {
Enabled bool
Enabled bool
RunAtStart bool
RunAtStart bool
Schedule string
Schedule string
NoSuccessNotice bool
}
}
// OlderThanConfig represents a cron task with OlderThan setting
// OlderThanConfig represents a cron task with OlderThan setting
@ -53,6 +55,11 @@ func (b *BaseConfig) DoRunAtStart() bool {
return b . RunAtStart
return b . RunAtStart
}
}
// DoNoticeOnSuccess returns whether a success notice should be posted
func ( b * BaseConfig ) DoNoticeOnSuccess ( ) bool {
return ! b . NoSuccessNotice
}
// FormatMessage returns a message for the task
// FormatMessage returns a message for the task
func ( b * BaseConfig ) FormatMessage ( name , status string , doer * models . User , args ... interface { } ) string {
func ( b * BaseConfig ) FormatMessage ( name , status string , doer * models . User , args ... interface { } ) string {
realArgs := make ( [ ] interface { } , 0 , len ( args ) + 2 )
realArgs := make ( [ ] interface { } , 0 , len ( args ) + 2 )