Skip to content

Commit

Permalink
shorten a few more
Browse files Browse the repository at this point in the history
  • Loading branch information
davidnewhall committed Aug 3, 2024
1 parent d52a948 commit 2da683d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
22 changes: 11 additions & 11 deletions pkg/triggers/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type triggerOutput struct {
// @Router /api/triggers [get]
// @Security ApiKeyAuth
func (a *Actions) HandleGetTriggers(_ *http.Request) (int, interface{}) {
triggers, timers := a.Config.GatherTriggerInfo()
triggers, timers := a.GatherTriggerInfo()
temp := make(map[string]*trigger) // used to dedup.

for name, dur := range triggers {
Expand Down Expand Up @@ -93,7 +93,7 @@ func (a *Actions) HandleGetTriggers(_ *http.Request) (int, interface{}) {
Name: action.Name,
Dur: action.Interval.String(),
Idx: idx,
Path: path.Join(a.Config.Apps.URLBase, fmt.Sprint("api/trigger/custom/", idx)),
Path: path.Join(a.Apps.URLBase, fmt.Sprint("api/trigger/custom/", idx)),
}
}

Expand All @@ -107,9 +107,9 @@ func (a *Actions) handleTrigger(req *http.Request, event website.EventType) (int
content := mux.Vars(req)["content"]

if content != "" {
a.Config.Debugf("[%s requested] Incoming Trigger: %s (%s)", event, trigger, content)
a.Debugf("[%s requested] Incoming Trigger: %s (%s)", event, trigger, content)
} else {
a.Config.Debugf("[%s requested] Incoming Trigger: %s", event, trigger)
a.Debugf("[%s requested] Incoming Trigger: %s", event, trigger)
}

_ = req.ParseForm()
Expand Down Expand Up @@ -196,7 +196,7 @@ func (a *Actions) customTimer(input *common.ActionInput, content string) (int, s
// @Security ApiKeyAuth
func (a *Actions) clientLogs(content string) (int, string) {
if content == "true" || content == "on" || content == "enable" {
share.Setup(a.Config.Server)
share.Setup(a.Server)
return http.StatusOK, "Client log notifications enabled."
}

Expand Down Expand Up @@ -297,7 +297,7 @@ func (a *Actions) rpsync(input *common.ActionInput, content string) (int, string
// @Router /api/trigger/services [get]
// @Security ApiKeyAuth
func (a *Actions) services(input *common.ActionInput) (int, string) {
a.Config.RunChecks(input.Type)
a.RunChecks(input.Type)
return http.StatusOK, "All service checks rescheduled for immediate execution."
}

Expand All @@ -311,7 +311,7 @@ func (a *Actions) services(input *common.ActionInput) (int, string) {
// @Router /api/trigger/sessions [get]
// @Security ApiKeyAuth
func (a *Actions) sessions(input *common.ActionInput) (int, string) {
if !a.Config.Apps.Plex.Enabled() {
if !a.Apps.Plex.Enabled() {
return http.StatusNotImplemented, "Plex Sessions are not enabled."
}

Expand Down Expand Up @@ -428,7 +428,7 @@ func (a *Actions) handleConfigReload() (int, string) {
go func() {
// Until we have a way to reliably finish the tunnel requests, this is the best I got.
time.Sleep(200 * time.Millisecond) //nolint:mnd
a.Config.ReloadApp("HTTP Triggered Reload")
a.ReloadApp("HTTP Triggered Reload")
}()

return http.StatusOK, "Application reload initiated."
Expand All @@ -447,7 +447,7 @@ func (a *Actions) handleConfigReload() (int, string) {
func (a *Actions) notification(content string) (int, string) {
if content != "" {
ui.Toast("Notification: %s", content) //nolint:errcheck
a.Config.Printf("NOTIFICATION: %s", content)
a.Printf("NOTIFICATION: %s", content)

return http.StatusOK, "Local Nntification sent."
}
Expand All @@ -466,7 +466,7 @@ func (a *Actions) notification(content string) (int, string) {
// @Router /api/trigger/emptyplextrash/{libraryKeys} [get]
// @Security ApiKeyAuth
func (a *Actions) emptyplextrash(input *common.ActionInput, content string) (int, string) {
if !a.Config.Apps.Plex.Enabled() {
if !a.Apps.Plex.Enabled() {
return http.StatusNotImplemented, "Plex is not enabled."
}

Expand Down Expand Up @@ -500,7 +500,7 @@ func (a *Actions) mdblist(input *common.ActionInput) (int, string) {
// @Router /api/trigger/uploadlog/{file} [get]
// @Security ApiKeyAuth
func (a *Actions) uploadlog(input *common.ActionInput, file string) (int, string) {
if a.Config.LogConfig.NoUploads {
if a.LogConfig.NoUploads {
return http.StatusFailedDependency, "Uploads Administratively Disabled"
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/triggers/triggers.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ func New(config *Config) *Actions {

// Start creates all the triggers and runs the timers.
func (a *Actions) Start(ctx context.Context, reloadCh, stopCh chan os.Signal) {
a.Config.SetReloadCh(reloadCh)
a.Config.SetStopCh(stopCh)
a.SetReloadCh(reloadCh)
a.SetStopCh(stopCh)

defer a.Config.Run(ctx)
defer a.Run(ctx)

actions := reflect.ValueOf(a).Elem()
for idx := range actions.NumField() {
Expand Down

0 comments on commit 2da683d

Please sign in to comment.