Skip to content
Permalink
Browse files

append: if a user mailbox is called "Outbox" then notify_at an event …

…for it

Protected by the config option "outbox_sendlater".
  • Loading branch information
brong committed Dec 25, 2015
1 parent f4e58e4 commit 3bd7fff60173001ded6e7f8f4c196d15cfaeaebe
Showing with 28 additions and 0 deletions.
  1. +24 −0 imap/append.c
  2. +1 −0 imap/append.h
  3. +3 −0 lib/imapoptions
@@ -58,6 +58,7 @@
#include "acl.h"
#include "assert.h"
#include "mailbox.h"
#include "notify.h"
#include "message.h"
#include "append.h"
#include "global.h"
@@ -225,6 +226,15 @@ EXPORTED int append_setup_mbox(struct appendstate *as, struct mailbox *mailbox,

as->mailbox = mailbox;

if (config_getswitch(IMAPOPT_OUTBOX_SENDLATER)) {
/* XXX - use specialuse for this later */
mbname_t *mbname = mbname_from_intname(mailbox->name);
const strarray_t *boxes = mbname_boxes(mbname);
if (mbname_localpart(mbname) && strarray_size(boxes) == 1 && !strcmp(strarray_nth(boxes, 0), "Outbox"))
as->isoutbox = 1;
mbname_free(&mbname);
}

return 0;
}

@@ -987,6 +997,13 @@ EXPORTED int append_fromstage(struct appendstate *as, struct body **body,
}
}

if (as->isoutbox) {
char num[10];
snprintf(num, 10, "%u", record.uid);
r = notify_at(record.internaldate, "sendemail", "append", "", "", as->mailbox->name, 0, NULL, num);
if (r) goto out;
}

/* Write out index file entry */
r = mailbox_append_index_record(mailbox, &record);
if (r) goto out;
@@ -1353,6 +1370,13 @@ EXPORTED int append_copy(struct mailbox *mailbox, struct appendstate *as,
}
#endif

if (as->isoutbox) {
char num[10];
snprintf(num, 10, "%u", record.uid);
r = notify_at(record.internaldate, "sendemail", "append", "", "", as->mailbox->name, 0, NULL, num);
if (r) goto out;
}

/* Write out index file entry */
r = mailbox_append_index_record(as->mailbox, &record);
if (r) goto out;
@@ -59,6 +59,7 @@ struct appendstate {
struct mailbox *mailbox;
/* do we own it? */
int close_mailbox_when_done:1;
int isoutbox:1;
int myrights;
char userid[MAX_MAILBOX_BUFFER];

@@ -1349,6 +1349,9 @@ And the notification message will be available on \fIstdin\fR.
value of the \fBdefaultpartion\fR option is \fBdefault\fR, then the
\fBpartition-default\fR field is required. */

{ "outbox_sendlater", 0, SWITCH }
/* If enabled, any message with a \Draft flag will be sent at the time of its INTERNALDATE */

{ "partition_select_mode", "freespace-most", STRINGLIST("random", "freespace-most", "freespace-percent-most", "freespace-percent-weighted", "freespace-percent-weighted-delta") }
/* Partition selection mode.
.PP

0 comments on commit 3bd7fff

Please sign in to comment.
You can’t perform that action at this time.