Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added payload mapper #189

Merged
merged 2 commits into from
May 11, 2024
Merged

Added payload mapper #189

merged 2 commits into from
May 11, 2024

Conversation

caronc
Copy link
Owner

@caronc caronc commented May 5, 2024

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! 🚀 :

{
    "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

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

@caronc caronc merged commit 3a710fb into master May 11, 2024
1 check passed
@caronc caronc deleted the 183-custom-payload-mapping branch May 11, 2024 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant