feat(actions): Add support for <VAR>STATE</VAR> (#24)
All checks were successful
/ build (push) Successful in 3m5s
All checks were successful
/ build (push) Successful in 3m5s
Reviewed-on: #24 Co-authored-by: Varakh <varakh@varakh.de> Co-committed-by: Varakh <varakh@varakh.de>
This commit is contained in:
parent
915b78d519
commit
53e38158d5
6 changed files with 17 additions and 6 deletions
|
@ -258,6 +258,7 @@ occurrence is replaced before invocation as well.
|
|||
| `<VAR>PROVIDER</VAR>` | The update's provider name invoking the action |
|
||||
| `<VAR>HOST</VAR>` | The update's host invoking the action |
|
||||
| `<VAR>VERSION</VAR>` | The update's version (latest) invoking the action |
|
||||
| `<VAR>STATE</VAR>` | The update's state invoking the action |
|
||||
|
||||
#### shoutrrr
|
||||
|
||||
|
|
|
@ -2403,6 +2403,12 @@ components:
|
|||
type: string
|
||||
version:
|
||||
type: string
|
||||
state:
|
||||
type: string
|
||||
enum:
|
||||
- pending
|
||||
- approved
|
||||
- ignored
|
||||
ActionResponse:
|
||||
type: object
|
||||
properties:
|
||||
|
|
|
@ -339,6 +339,7 @@ type EventPayloadUpdateDeletedDto struct {
|
|||
Provider string `json:"provider,omitempty"`
|
||||
Host string `json:"host,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
State string `json:"state,omitempty"`
|
||||
}
|
||||
|
||||
func NewEventWindowResponse(content []*EventResponse, size int, skip int, orderBy string, order string, hasNext bool) *EventWindowResponse {
|
||||
|
|
|
@ -12,4 +12,5 @@ type eventPayloadInformationDto struct {
|
|||
Application string
|
||||
Provider string
|
||||
Version string
|
||||
State string
|
||||
}
|
||||
|
|
|
@ -256,6 +256,7 @@ func (s *actionInvocationService) replaceVars(str string, eventPayloadInfo *even
|
|||
str = strings.ReplaceAll(str, "<VAR>PROVIDER</VAR>", eventPayloadInfo.Provider)
|
||||
str = strings.ReplaceAll(str, "<VAR>HOST</VAR>", eventPayloadInfo.Host)
|
||||
str = strings.ReplaceAll(str, "<VAR>VERSION</VAR>", eventPayloadInfo.Version)
|
||||
str = strings.ReplaceAll(str, "<VAR>STATE</VAR>", eventPayloadInfo.State)
|
||||
|
||||
return str
|
||||
}
|
||||
|
|
|
@ -82,6 +82,7 @@ func (s *eventService) createUpdateDeleted(e *Update) *Event {
|
|||
Provider: e.Provider,
|
||||
Host: e.Host,
|
||||
Version: e.Version,
|
||||
State: e.State,
|
||||
})
|
||||
|
||||
return nil
|
||||
|
@ -210,37 +211,37 @@ func (s *eventService) extractPayloadInfo(event *Event) (*eventPayloadInformatio
|
|||
if p, err = util.UnmarshalGenericJSON[api.EventPayloadUpdateCreatedDto](bytes); err != nil {
|
||||
return nil, newServiceError(General, err)
|
||||
}
|
||||
return &eventPayloadInformationDto{Host: p.Host, Application: p.Application, Provider: p.Provider, Version: p.Version}, nil
|
||||
return &eventPayloadInformationDto{Host: p.Host, Application: p.Application, Provider: p.Provider, Version: p.Version, State: p.State}, nil
|
||||
case api.EventNameUpdateDeleted.Value():
|
||||
var p api.EventPayloadUpdateDeletedDto
|
||||
if p, err = util.UnmarshalGenericJSON[api.EventPayloadUpdateDeletedDto](bytes); err != nil {
|
||||
return nil, newServiceError(General, err)
|
||||
}
|
||||
return &eventPayloadInformationDto{Host: p.Host, Application: p.Application, Provider: p.Provider, Version: p.Version}, nil
|
||||
return &eventPayloadInformationDto{Host: p.Host, Application: p.Application, Provider: p.Provider, Version: p.Version, State: p.State}, nil
|
||||
case api.EventNameUpdateUpdatedApproved.Value():
|
||||
var p api.EventPayloadUpdateUpdatedDto
|
||||
if p, err = util.UnmarshalGenericJSON[api.EventPayloadUpdateUpdatedDto](bytes); err != nil {
|
||||
return nil, newServiceError(General, err)
|
||||
}
|
||||
return &eventPayloadInformationDto{Host: p.Host, Application: p.Application, Provider: p.Provider, Version: p.Version}, nil
|
||||
return &eventPayloadInformationDto{Host: p.Host, Application: p.Application, Provider: p.Provider, Version: p.Version, State: p.State}, nil
|
||||
case api.EventNameUpdateUpdatedPending.Value():
|
||||
var p api.EventPayloadUpdateUpdatedDto
|
||||
if p, err = util.UnmarshalGenericJSON[api.EventPayloadUpdateUpdatedDto](bytes); err != nil {
|
||||
return nil, newServiceError(General, err)
|
||||
}
|
||||
return &eventPayloadInformationDto{Host: p.Host, Application: p.Application, Provider: p.Provider, Version: p.Version}, nil
|
||||
return &eventPayloadInformationDto{Host: p.Host, Application: p.Application, Provider: p.Provider, Version: p.Version, State: p.State}, nil
|
||||
case api.EventNameUpdateUpdatedIgnored.Value():
|
||||
var p api.EventPayloadUpdateUpdatedDto
|
||||
if p, err = util.UnmarshalGenericJSON[api.EventPayloadUpdateUpdatedDto](bytes); err != nil {
|
||||
return nil, newServiceError(General, err)
|
||||
}
|
||||
return &eventPayloadInformationDto{Host: p.Host, Application: p.Application, Provider: p.Provider, Version: p.Version}, nil
|
||||
return &eventPayloadInformationDto{Host: p.Host, Application: p.Application, Provider: p.Provider, Version: p.Version, State: p.State}, nil
|
||||
case api.EventNameUpdateUpdated.Value():
|
||||
var p api.EventPayloadUpdateUpdatedDto
|
||||
if p, err = util.UnmarshalGenericJSON[api.EventPayloadUpdateUpdatedDto](bytes); err != nil {
|
||||
return nil, newServiceError(General, err)
|
||||
}
|
||||
return &eventPayloadInformationDto{Host: p.Host, Application: p.Application, Provider: p.Provider, Version: p.Version}, nil
|
||||
return &eventPayloadInformationDto{Host: p.Host, Application: p.Application, Provider: p.Provider, Version: p.Version, State: p.State}, nil
|
||||
}
|
||||
|
||||
return nil, newServiceError(General, errors.New("no matching event found"))
|
||||
|
|
Loading…
Reference in a new issue