Browse Source

Format actions PR, changelog

Philipp Heckel 2 years ago
parent
commit
b4a824aa38
3 changed files with 10 additions and 9 deletions
  1. 1 0
      docs/releases.md
  2. 2 2
      server/actions.go
  3. 7 7
      server/actions_test.go

+ 1 - 0
docs/releases.md

@@ -24,6 +24,7 @@ and the [ntfy Android app](https://github.com/binwiederhier/ntfy-android/release
 * Return HTTP 500 for GET /_matrix/push/v1/notify when base-url is not configured (no ticket)
 * Disallow setting `upstream-base-url` to the same value as `base-url` ([#334](https://github.com/binwiederhier/ntfy/issues/334), thanks to [@oester](https://github.com/oester) for reporting)
 * Fix `since=<id>` implementation for multiple topics ([#336](https://github.com/binwiederhier/ntfy/issues/336), thanks to [@karmanyaahm](https://github.com/karmanyaahm) for reporting)
+* Simple parsing in `Actions` header now supports settings Android `intent=` key ([#341](https://github.com/binwiederhier/ntfy/pull/341), thanks to [@wunter8](https://github.com/wunter8))
 
 
 ## ntfy Android app v1.14.0 (UNRELEASED)

+ 2 - 2
server/actions.go

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

+ 7 - 7
server/actions_test.go

@@ -52,13 +52,13 @@ func TestParseActions(t *testing.T) {
 	require.Equal(t, "some command", actions[0].Extras["command"])
 	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)
+	// 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
 	actions, err = parseActions("action=http, label=Send request, url=http://example.com, method=GET, headers.Content-Type=application/json, headers.Authorization=Basic sdasffsf")