isso
isso copied to clipboard
Feature: add webhook notification capability
I propose here to add the possibility to send a notification to a web hook for each new comment.
Notable changes
- creation of a new WebHook class in the notifications module
- by default, it sends a POST request with the same metadata as the mail notification (name, mail and site of the author as well as the moderation links)
- add requests as dependency
- possibility for the end user to pass a JSON template to the webhook (useful for tools allowing formatting, like Slack/Teams/Matrix...). An example of template for Slack is provided (into contrib subfolder) with this render:
Questions
- Maybe it is possible with Werkzeug, Flask or the stdlib directly for the POST request? I'm not expert on this side so, don't hesitate on review my code.
- I wanted to use f-strings but apparently the project is still tested on Python 3.5 (which has reached EOL), but not 3.9. Is it a voluntary choice?
- I had to fix dependencies consistency between setup.py and tox.ini, in order to get CI fixed. Requirements are not well documented and the development workflow is quite unclear. Would you accept a PR to switch to requirements.txt files and/or pyproject.tom (recomended by tox anyway)?
Misc
- add cache to Travis to make it faster
- Close my question #722
ping @posativ @ix5 @blatinier : any chance to see it merged or reviewed?
Can't say much, but here are my thoughts:
- f-strings are pretty dangerous, see Armin Ronacher: Be Careful with Python's New-Style String Format
- Avoid adding new dependencies. POST requests can be done with
urllib
- Squash your commits
Thanks for your feedback.
f-strings are pretty dangerous, see Armin Ronacher: Be Careful with Python's New-Style String Format
I did not know that but it's quite old (not sure it's still applicable) and it's a concern only when we format some secret no? If you prefer, we can switch to f"{var}"
or "%s" % var
.
Avoid adding new dependencies. POST requests can be done with urllib
Sure but it would be quite harder to handle different cases (HTTP warnings, redirections, etc...).
Squash your commits
I will.
It would be great if this had some unit tests.
Sure!
I did not write them because I can't find which tests framework is recommended.
Can you tell me which one please? (pypi package name)
We're using nosetests; you can invoke them with nose or by running "make test"
We're using nosetests; you can invoke them with nose or by running "make test"
Ok. What I need is the PyPi package to install it as testing dependency in a virtual env (I don't want to install something widely on my system). I can't find noestests on pypi.org but I've found 2 nose* packages: this one https://pypi.org/project/nose/ or this one https://pypi.org/project/nose2/?
I think the pypi name is just "nose", but you should also be able to just use python's standard unittest framework to run the tests - we don't use anything nose-specific.
I think the pypi name is just "nose", but you should also be able to just use python's standard unittest framework to run the tests - we don't use anything nose-specific.
Good news because running make test returns an error (Ubuntu 20.04, after make init with node 14):
:~/Git/External/isso$ make test
python3 setup.py nosetests
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: invalid command 'nosetests'
make: *** [Makefile:71 : test] Erreur 1
Thanks for your help. I'll try to write some unit tests with the standard lib.
nose
is only a runner. You can also run them with python3 -m unittest discover isso/tests
or by using pytest which also includes a runner.
I & @mskian ended up creating this - https://github.com/mskian/isso-telegram-notifier
I & @mskian ended up creating this - https://github.com/mskian/isso-telegram-notifier
Nice work! Why not develop it right into Isso?
I & @mskian ended up creating this - https://github.com/mskian/isso-telegram-notifier
Nice work! Why not develop it right into Isso?
If this was added to mainline isso, it would be hard to make sure that it kept working - the maintainers can't test with lots of different configurations.
Nice work! I have not verified the functionality myself, but the code looks neat.
Please add (unit) tests as requested by @jelmer
@Guts this is a great feature, would you mind rebasing and addressing the points raised by jelmer and myself?
It'll be great to have this feature. It'll enable me to trigger a build of my static website in which I render the Isso comments at build time.