allow custom intent in broadcast action without JSON

pull/341/head
Hunter Kehoe 2022-06-22 15:29:16 -06:00
parent 3334d84861
commit ee38d76bc2
2 changed files with 10 additions and 0 deletions

View File

@ -186,6 +186,8 @@ func populateAction(newAction *action, section int, key, value string) error {
newAction.Method = value newAction.Method = value
case "body": case "body":
newAction.Body = value newAction.Body = value
case "intent":
newAction.Intent = value
default: default:
return fmt.Errorf("key '%s' unknown", key) return fmt.Errorf("key '%s' unknown", key)
} }

View File

@ -52,6 +52,14 @@ func TestParseActions(t *testing.T) {
require.Equal(t, "some command", actions[0].Extras["command"]) require.Equal(t, "some command", actions[0].Extras["command"])
require.Equal(t, "a parameter", actions[0].Extras["some_param"]) require.Equal(t, "a parameter", actions[0].Extras["some_param"])
// Broadcast action with intent
actions, err = parseActions("action=broadcast, label=Do a thing, intent=io.heckel.ntfy.TEST_INTENT")
require.Nil(t, err)
require.Equal(t, 1, len(actions))
require.Equal(t, "broadcast", actions[0].Action)
require.Equal(t, "Do a thing", actions[0].Label)
require.Equal(t, "io.heckel.ntfy.TEST_INTENT", actions[0].Intent)
// Headers with dashes // Headers with dashes
actions, err = parseActions("action=http, label=Send request, url=http://example.com, method=GET, headers.Content-Type=application/json, headers.Authorization=Basic sdasffsf") actions, err = parseActions("action=http, label=Send request, url=http://example.com, method=GET, headers.Content-Type=application/json, headers.Authorization=Basic sdasffsf")
require.Nil(t, err) require.Nil(t, err)