diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-12-06 12:20:08 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-12-06 12:20:08 +0200 |
commit | a1d560a878d1dfe4ed751cb3f99b1ee67755f489 (patch) | |
tree | 0c7e45d5ba14c309fe67929245d8a75df6d3692a /src | |
parent | 565650272f219fd372347f0ff3375b09caa18952 (diff) | |
download | wydawca-a1d560a878d1dfe4ed751cb3f99b1ee67755f489.tar.gz wydawca-a1d560a878d1dfe4ed751cb3f99b1ee67755f489.tar.bz2 |
Allow to specify arbitrary notification recipients.
* src/wydawca.h (enum notification_target): New value notify_read,
meaning "read recipient addresses from the message headers".
* src/config.c (target_args): New values: "read" and "message".
(target_types): New value 'notify_read'.
* src/mail.c (mail_send_message): Handle NULL rcpt.
(do_notify): Handle notify_read.
Diffstat (limited to 'src')
-rw-r--r-- | src/config.c | 4 | ||||
-rw-r--r-- | src/mail.c | 57 | ||||
-rw-r--r-- | src/vtab.c | 2 | ||||
-rw-r--r-- | src/wydawca.h | 1 |
4 files changed, 41 insertions, 23 deletions
diff --git a/src/config.c b/src/config.c index c877c26..559f766 100644 --- a/src/config.c +++ b/src/config.c @@ -184,2 +184,4 @@ string_to_notification_event (grecs_locus_t *locus, const char *val, static const char *target_args[] = { + "read", + "message", "admin", @@ -191,2 +193,4 @@ static const char *target_args[] = { static int target_types[] = { + notify_read, /* Read recipients from the message headers */ + notify_read, notify_admin, /* System administrator */ @@ -66,18 +66,21 @@ mail_send_message (mu_address_t rcpt, const char *text) - mu_address_to_string (rcpt, NULL, 0, &size); - buf = xmalloc (size + 1); - mu_address_to_string (rcpt, buf, size + 1, NULL); - - mu_header_set_value (hdr, "To", buf, 1); - free (buf); - - if (from_address && mu_header_sget_value (hdr, "From", &sval)) + if (rcpt) { - mu_address_to_string (from_address, NULL, 0, &size); + mu_address_to_string (rcpt, NULL, 0, &size); buf = xmalloc (size + 1); - mu_address_to_string (from_address, buf, size + 1, NULL); - mu_header_set_value (hdr, "From", buf, 1); + mu_address_to_string (rcpt, buf, size + 1, NULL); + + mu_header_set_value (hdr, "To", buf, 1); free (buf); - } + if (from_address && mu_header_sget_value (hdr, "From", &sval)) + { + mu_address_to_string (from_address, NULL, 0, &size); + buf = xmalloc (size + 1); + mu_address_to_string (from_address, buf, size + 1, NULL); + mu_header_set_value (hdr, "From", buf, 1); + free (buf); + } + } + if (debug_level > 1) @@ -367,2 +370,6 @@ do_notify (struct file_triplet *trp, enum notification_event ev, { + case notify_read: + rcpt = NULL; + break; + case notify_admin: @@ -380,3 +387,3 @@ do_notify (struct file_triplet *trp, enum notification_event ev, - if (!rcpt) + if (!rcpt && ntf->tgt != notify_read) { @@ -391,12 +398,18 @@ do_notify (struct file_triplet *trp, enum notification_event ev, { - size_t size; - char *buf; - mu_address_to_string (rcpt, NULL, 0, &size); - buf = xmalloc (size + 1); - mu_address_to_string (rcpt, buf, size + 1, NULL); - logmsg (LOG_DEBUG, _("notifying %s (project %s) about %s"), - buf, trp->project, notification_event_str (ev)); - free (buf); + if (rcpt) + { + size_t size; + char *buf; + mu_address_to_string (rcpt, NULL, 0, &size); + buf = xmalloc (size + 1); + mu_address_to_string (rcpt, buf, size + 1, NULL); + logmsg (LOG_DEBUG, _("notifying %s (project %s) about %s"), + buf, trp->project, notification_event_str (ev)); + free (buf); + } + else + logmsg (LOG_DEBUG, _("notifying message recipients (project %s) about %s"), + trp->project, notification_event_str (ev)); } - + if (!dry_run_mode) @@ -56,3 +56,3 @@ url_to_vtab (mu_url_t url, struct virt_tab *vtab) int -move_file (struct file_triplet *trp, const const struct spool *spool, +move_file (struct file_triplet *trp, const struct spool *spool, enum file_type file_id, const char *reldir) diff --git a/src/wydawca.h b/src/wydawca.h index bd81b88..805b72b 100644 --- a/src/wydawca.h +++ b/src/wydawca.h @@ -272,2 +272,3 @@ enum notification_target { + notify_read, /* Read recipients from the message headers */ notify_admin, /* System administrator */ |