-
-
Notifications
You must be signed in to change notification settings - Fork 355
Add ntfy reporter #854
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
Add ntfy reporter #854
Conversation
thp
left a comment
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.
See comments. Also add an entry for this to CHANGELOG.md in the UNRELEASED section (search for "New reporter" there for examples).
lib/urlwatch/reporters.py
Outdated
| if priority := config_priorities.get(job_state.verb): | ||
| job_headers["Priority"] = priority | ||
| if job_state.job.location_is_url(): | ||
| job_headers['Actions'] = f"view, Open URL, {job_state.job.get_location()}, clear=true".encode('utf-8') |
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.
What if job_state.job.get_location() contains , ? Does this value need to be URL-escaped?
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.
Oh, good catch! Values can be quoted with ", so I did that.
Now, I'm not sure if the URL might contain ", of course... If so, the HtmlReporter seems to suffer from this as well, so I'd say this requires a separate fix.
urlwatch/lib/urlwatch/reporters.py
Lines 223 to 233 in 0425631
| if job.location_is_url(): | |
| title = '<a href="{location}">{pretty_name}</a>' | |
| elif job.pretty_name() != job.get_location(): | |
| title = '<span title="{location}">{pretty_name}</span>' | |
| else: | |
| title = '{location}' | |
| title = '<h2><span class="verb">{verb}:</span> ' + title + '</h2>' | |
| yield SafeHtml(title).format(verb=job_state.verb, | |
| location=job.get_location(), | |
| pretty_name=job.pretty_name()) |
bf73471 to
af5d1ee
Compare
|
@thp This should fix the pytest CI :) |
|
Merged, thanks! |
This adds a new reporter for ntfy.
Closes #762 (were it not already closed).
It sends one message per job state since I think this aligns best with ntfy's design: It allows to show an "Open URL" action per notification/job.