-
Notifications
You must be signed in to change notification settings - Fork 664
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
Allow passing Accept and User-Agent headers in notification webhook #2595
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking purely at the code (and referring to my test configs for memory refresher) left me with a question WRT to existing configs. Otherwise looks ok.
Co-authored-by: MichaIng <micha@dietpi.com>
1111f52
to
5c1c16c
Compare
5c1c16c
to
9c0c227
Compare
Even with changes we just agreed on, this won't be truly backwards compatible if someone does an in-place upgrade and already has an on_event_start webhook configured. That's because this will think their existing config is passing Accept and User-agent. The only way I see around it is if we re-write That said, I'm not really willing/able to put that much effort in right now for such a rewrite. Maybe a stop-gap in the meantime will be to not surround optional Accept and User-agent with single quotes while appending to on_event_start |
flake8 is not happy:
Since we do not want a refactor the function in this PR, I suggest to ignore this particular error for now: def motion_camera_dict_to_ui(data): # noqa: C901
I do not see the issue yet: Event actions (stored as a single line string in the camera config) are split with semicolon, the fields of each action are split with space. So with old configs, the event action will have three fields only, which are parsed correctly. Since the new options are not defined (or empty), the headers won't be added. But best is to simply test it. I'll probably not find time until Thursday since I have an evening event at work tomorrow. |
0f0e15d
to
635ceaa
Compare
I've added a commit with this, and tested that it's now truly backwards compatible. Hopefully the commit sufficiently illustrates what the problem was. Also note the change from 3/5 -> 7/9 is intentional, and UI doesn't parse config file correctly otherwise I've also hopefully now satisfied flake8 with your suggestion |
635ceaa
to
b490526
Compare
As there was another potentially related report #2704, lets have another look at this. Actually, to not clutter the GUI too much, does it make sense to first try to pass a common user agent header by default? @lowlyocean was the Accept header really required in your case? I generally would try to do things like |
Whether or not Accept (or other particular headers) are required may depend on the backend service. In my case, the webhooks are sent to an instance of node-red/node-red and Accept was required for that use case |
Closes #2573