apprise-api icon indicating copy to clipboard operation
apprise-api copied to clipboard

Added payload mapper

Open caronc opened this issue 1 year ago • 0 comments

Description:

Related issue (if applicable): refs #183

Added the ability to remap fields during a notification submission by using : (colon) in the GET args of the post.

For example, consider a situation where your server posts the following:

{
    "content": "Message body",
    "subject": "Message title",
}

These fields can be mapped to what the Apprise API expects with the following URL:

curl -X POST   \
   -F "body=Test Message" \
   -F "tags=all"  \
   "http://localhost:8000/notify/apprise-api-key?:content=body&:subject=title"

The above identifies :content=body which tells the Apprise API to map the content entry to body, and :subject tells it to map subject to title. Effectively, your payload looks like this now which is exactly what Apprise needed! :rocket: :

{
    "body": "Message body",
    "title": "Message title",
}

The colon : prefix is the switch that starts the rule engine. You can do 3 possible things with the rule engine:

  1. :existing_key=new_key: Rename an existing key to one apprise wants
  2. :existing_key=: By setting no value, the existing key is simply removed from the payload entirely
  3. :apprise_key=A value to give it: You can also set an expected apprise key to a pre-generated string value.

Checklist

  • [x] The code change is tested and works locally.
  • [x] There is no commented out code in this PR.
  • [x] No lint errors (use flake8)
  • [x] Tests added

caronc avatar May 05 '24 19:05 caronc