thp / urlwatch

Watch (parts of) webpages and get notified when something changes via e-mail, on your phone or via other means. Highly configurable.
https://thp.io/2008/urlwatch/
Other
2.79k stars 350 forks source link

add support to specify multiple recipients per URL #781

Open monperrus opened 7 months ago

monperrus commented 7 months ago

Thanks for the great tool!

It would be super useful to specify different and possibly multiple recipients per URL.

for example:

url: http://example.com
to: me@foo.com,you@bar.com

url: http://easter.com
to: me@foo.com,friend@42.com

WDYT?

thp commented 6 months ago

Right now, reporter-related configuration per job isn't possible. You have to rely on having multiple configurations and/or set up mailing lists or something. Because reports are grouped (so there's only one notification sent out if both are changed) it wouldn't even be possible without some additional logic to split reports in those cases (e.g. in your example, would me@foo.com get an e-mail with two changes, and you@bar.com and friend@42.com each get separate e-mails with their respective change?). Also, there are some reporters that don't have the concept of a "recipient".

Possibly related to #507.

monperrus commented 6 months ago

Thanks for the feedback.

Because reports are grouped (so there's only one notification sent out if both are changed) it wouldn't even be possible without some additional logic to split reports in those cases

FYI, I have a working implementation to split reports in separate emails.

monperrus commented 5 months ago

Because reports are grouped

Trying to rebase before PRing, I discover the existence of new option "separate", https://github.com/thp/urlwatch/blob/e342af925930114b4194f1bdb660dec6348f653a/lib/urlwatch/reporters.py#L130

Can this be used to send one email per report?

thp commented 5 months ago

Because reports are grouped

Trying to rebase before PRing, I discover the existence of new option "separate",

https://github.com/thp/urlwatch/blob/e342af925930114b4194f1bdb660dec6348f653a/lib/urlwatch/reporters.py#L130

Can this be used to send one email per report?

This just sends multiple e-mails to the single recipient instead of a single mail with all update notifications combined. Yes, in this case it would be possible to have multiple recipients, but it means that having multiple recipients would enable separate, at least for that list of recipients, and then it can get tricky.

It's still tricky, as the way recipients are specified is specific to the reporter (e.g. e-mail reporter takes e-mail adresses, the Slack reporter takes a URL, the Telegram reporter takes something else, etc...).

monperrus commented 5 months ago

I'm trying to use the separate option.

Neither top-level separate: true.

nor under report works.

report:
  email:
    enabled: true
    separate: true

any suggestion? Thanks!

monperrus commented 4 months ago

Have a working version with adding the optional field to to a job:

job_defaults:
  all:
    to: 'martin.monperrus@gnieh.org'
---
kind: url
url: https://www.monperrus.net/martin/random.php
to: x@example.org,y@example.org
--- a/lib/urlwatch/jobs.py
+++ b/lib/urlwatch/jobs.py
 class Job(JobBase):
     __required__ = ()
-    __optional__ = ('name', 'filter', 'max_tries', 'diff_tool', 'compared_versions', 'diff_filter', 'treat_new_as_changed', 'user_visible_url')
+    __optional__ = ('name', 'filter', 'max_tries', 'diff_tool', 'compared_versions', 'diff_filter', 'treat_new_as_changed', 'user_visible_url','to')

and

--- a/lib/urlwatch/reporters.py
+++ b/lib/urlwatch/reporters.py
-                msg = mailer.msg_html(self.config['from'], self.config['to'], subject, body_text, body_html)
+                msg = mailer.msg_html(self.config['from'], job_state.job.to, subject, body_text, body_html)
             else:
-                msg = mailer.msg_plain(self.config['from'], self.config['to'], subject, body_text)
+                msg = mailer.msg_plain(self.config['from'], job_state.job.to, subject, body_text)
Jamstah commented 4 months ago

I've got an alternative approach to this that enables multiple reporters of each type: https://github.com/thp/urlwatch/issues/790

You would tag jobs and use them to select the right jobs for each reporter.