MCPcopy Create free account
hub / github.com/Unpackerr/unpackerr / runAllHooks

Method runAllHooks

pkg/unpackerr/webhook.go:92–151  ·  view source on GitHub ↗

runAllHooks sends webhooks and executes command hooks.

(item *Extract)

Source from the content-addressed store, hash-verified

90
91// runAllHooks sends webhooks and executes command hooks.
92func (u *Unpackerr) runAllHooks(item *Extract) {
93 if item.Status == IMPORTED && item.App == FolderString {
94 return // This is an internal state change we don't need to fire on.
95 }
96
97 payload := &WebhookPayload{
98 Path: item.Path,
99 App: item.App,
100 IDs: item.IDs,
101 Time: item.Updated,
102 Data: nil,
103 Event: item.Status,
104 // Application Metadata.
105 Go: runtime.Version(),
106 OS: runtime.GOOS,
107 Arch: runtime.GOARCH,
108 Version: version.Version,
109 Revision: version.Revision,
110 Branch: version.Branch,
111 Started: version.Started,
112 }
113
114 if item.Status <= EXTRACTED && item.Resp != nil {
115 payload.Data = &XtractPayload{
116 Files: item.Resp.NewFiles,
117 File: item.Resp.NewFiles,
118 Start: item.Resp.Started,
119 Output: item.Resp.Output,
120 Bytes: item.Resp.Size,
121 Queue: item.Resp.Queued,
122 Elapsed: cnfg.Duration{Duration: item.Resp.Elapsed},
123 }
124
125 for _, v := range item.Resp.Archives {
126 payload.Data.Archives = append(payload.Data.Archives, v...)
127 payload.Data.Archive = append(payload.Data.Archive, v...)
128 }
129
130 for _, v := range item.Resp.Extras {
131 payload.Data.Archives = append(payload.Data.Archives, v...)
132 payload.Data.Archive = append(payload.Data.Archive, v...)
133 }
134
135 if item.Resp.Error != nil {
136 payload.Data.Error = item.Resp.Error.Error()
137 }
138 }
139
140 for _, hook := range u.Webhook {
141 if hook.HasEvent(item.Status) && !hook.Excluded(item.App) {
142 u.hookChan <- &hookQueueItem{WebhookConfig: hook, WebhookPayload: payload}
143 }
144 }
145
146 for _, hook := range u.Cmdhook {
147 if hook.HasEvent(item.Status) && !hook.Excluded(item.App) {
148 u.hookChan <- &hookQueueItem{WebhookConfig: hook, WebhookPayload: payload}
149 }

Callers 1

updateQueueStatusMethod · 0.95

Calls 2

HasEventMethod · 0.80
ExcludedMethod · 0.80

Tested by

no test coverage detected