urlwatch icon indicating copy to clipboard operation
urlwatch copied to clipboard

add support to specify multiple recipients per URL

Open monperrus opened this issue 8 months ago • 7 comments

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: [email protected],[email protected]

url: http://easter.com
to: [email protected],[email protected]

WDYT?

monperrus avatar Dec 17 '23 09:12 monperrus

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 [email protected] get an e-mail with two changes, and [email protected] and [email protected] 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.

thp avatar Jan 02 '24 20:01 thp

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 avatar Jan 10 '24 11:01 monperrus

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?

monperrus avatar Jan 23 '24 11:01 monperrus

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...).

thp avatar Jan 23 '24 19:01 thp

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 avatar Jan 31 '24 07:01 monperrus

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

job_defaults:
  all:
    to: '[email protected]'
---
kind: url
url: https://www.monperrus.net/martin/random.php
to: [email protected],[email protected]
--- 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)

monperrus avatar Feb 22 '24 09:02 monperrus

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.

Jamstah avatar Feb 22 '24 11:02 Jamstah