Skip to content
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 support to specify multiple recipients per URL #781

Open
monperrus opened this issue Dec 17, 2023 · 7 comments
Open

add support to specify multiple recipients per URL #781

monperrus opened this issue Dec 17, 2023 · 7 comments

Comments

@monperrus
Copy link
Contributor

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?

@monperrus monperrus changed the title add support for specify multiple recipients per URL add support to specify multiple recipients per URL Dec 17, 2023
@thp thp added the enhancement label Jan 2, 2024
@thp
Copy link
Owner

thp commented Jan 2, 2024

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
Copy link
Contributor Author

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
Copy link
Contributor Author

Because reports are grouped

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

if base_config.get('separate', False):

Can this be used to send one email per report?

@thp
Copy link
Owner

thp commented Jan 23, 2024

Because reports are grouped

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

if base_config.get('separate', False):

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
Copy link
Contributor Author

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
Copy link
Contributor Author

monperrus commented Feb 22, 2024

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
Copy link
Contributor

Jamstah commented Feb 22, 2024

I've got an alternative approach to this that enables multiple reporters of each type: #790

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants