* Nedmail patch - no reply to self
@ 2020-09-13 8:44 Alex Musolino
0 siblings, 0 replies; only message in thread
From: Alex Musolino @ 2020-09-13 8:44 UTC (permalink / raw)
To: 9front
Hi all,
The following patch allows users to specify a list of addresses
they do not wish to include when "replying to all" from nedmail(1).
Of course, in the event that people are happy with this change, I
would update the relevant man pages also.
diff -r 969b9a225c4a sys/src/cmd/upas/ned/nedmail.c
--- a/sys/src/cmd/upas/ned/nedmail.c Tue Sep 01 22:25:06 2020 +0930
+++ b/sys/src/cmd/upas/ned/nedmail.c Sun Sep 13 18:06:54 2020 +0930
@@ -2358,11 +2358,37 @@
return m;
}
+static int
+noreplyto(char *addr)
+{
+ char path[Pathlen], *line;
+ Biobuf *b;
+ int r;
+
+ r = 0;
+ seprint(path, path+sizeof(path), "/mail/box/%s/noreplyto", user);
+ b = Bopen(path, OREAD);
+ if(b != nil){
+ for(;;){
+ line = Brdline(b, '\n');
+ if(line == nil)
+ break;
+ line[Blinelen(b)-1] = 0;
+ if(strcmp(addr, line) == 0){
+ r = 1;
+ break;
+ }
+ }
+ Bterm(b);
+ }
+ return r;
+}
+
Message*
acmd(Cmd *c, Message *m)
{
- char *av[128], *rpath, *subject, *from, *to, *cc;
- int i, ai;
+ char *av[128], *addrv[128], *rpath, *subject, *from, *to, *cc;
+ int i, ai, addri;
if(m->from == nil || m->to == nil || m->cc == nil){
eprint("!bad message\n");
@@ -2390,9 +2416,17 @@
for(i = 1; i < c->an && ai < nelem(av)-1; i++)
av[ai++] = c->av[i];
- ai += tokenize822(from = strdup(m->from), &av[ai], nelem(av) - ai);
- ai += tokenize822(to = strdup(m->to), &av[ai], nelem(av) - ai);
- ai += tokenize822(cc = strdup(m->cc), &av[ai], nelem(av) - ai);
+ from = strdup(m->from);
+ to = strdup(m->to);
+ cc = strdup(m->cc);
+ addri = 0;
+ addri += tokenize822(from, &addrv[addri], nelem(addrv) - addri);
+ addri += tokenize822(to, &addrv[addri], nelem(addrv) - addri);
+ addri += tokenize822(cc, &addrv[addri], nelem(addrv) - addri);
+ for(i = 0; i < addri && ai < nelem(av)-1; i++){
+ if(!noreplyto(addrv[i]))
+ av[ai++] = addrv[i];
+ }
av[ai] = 0;
if(tomailer(av) == -1)
m = nil;
--
Cheers,
Alex Musolino
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-09-13 8:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-13 8:44 Nedmail patch - no reply to self Alex Musolino
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).