int days = 1;
const char *message;
char *vacamsg_text = NULL;
+ char vacamsg_subject[1024];
lprintf(CTDL_DEBUG, "Action is VACATION\n");
message = sieve2_getvalue_string(s, "message");
if (message == NULL) return SIEVE2_ERROR_BADARGS;
+ if (sieve2_getvalue_string(s, "subject") != NULL) {
+ safestrncpy(vacamsg_subject, sieve2_getvalue_string(s, "subject"), sizeof vacamsg_subject);
+ }
+ else {
+ snprintf(vacamsg_subject, sizeof vacamsg_subject, "Re: %s", cs->subject);
+ }
+
days = sieve2_getvalue_int(s, "days");
if (days < 1) days = 1;
if (days > MAX_VACATION) days = MAX_VACATION;
NULL,
vacamsg_text,
FMT_RFC822,
- "Delivery status notification"
+ vacamsg_subject
);
free(vacamsg_text);
*/
void parse_sieve_config(char *conf, struct sdm_userdata *u) {
char *ptr;
- char *c;
+ char *c, *vacrec;
char keyword[256];
struct sdm_script *sptr;
struct sdm_vacation *vptr;
}
else if (!strcasecmp(keyword, "vacation")) {
- vptr = malloc(sizeof(struct sdm_vacation));
- vptr->timestamp = extract_long(c, 1);
- extract_token(vptr->fromaddr, c, 2, '|', sizeof vptr->fromaddr);
- vptr->next = u->first_vacation;
- u->first_vacation = vptr;
+
+ if (c != NULL) while (vacrec=c, c=strchr(c, '\n'), (c != NULL)) {
+
+ *c = 0;
+ ++c;
+
+ if (strncasecmp(vacrec, "vacation|", 9)) {
+ vptr = malloc(sizeof(struct sdm_vacation));
+ extract_token(vptr->fromaddr, vacrec, 0, '|', sizeof vptr->fromaddr);
+ vptr->timestamp = extract_long(vacrec, 1);
+ vptr->next = u->first_vacation;
+ u->first_vacation = vptr;
+ }
+ }
}
/* ignore unknown keywords */
free(sptr);
}
- while (u->first_vacation != NULL) {
- if ( (time(NULL) - u->first_vacation->timestamp) < MAX_VACATION) {
- text = realloc(text, strlen(text) + strlen(u->first_vacation->fromaddr) + 256);
- sprintf(&text[strlen(text)], "vacation|%ld|%s" CTDLSIEVECONFIGSEPARATOR,
- u->first_vacation->timestamp,
- u->first_vacation->fromaddr
- );
+ if (u->first_vacation != NULL) {
+
+ size_t realloc_len = strlen(text) + 256;
+ for (vptr = u->first_vacation; vptr != NULL; vptr = vptr->next) {
+ realloc_len += strlen(vptr->fromaddr + 32);
+ }
+ text = realloc(text, realloc_len);
+
+ sprintf(&text[strlen(text)], "vacation|\n");
+ while (u->first_vacation != NULL) {
+ if ( (time(NULL) - u->first_vacation->timestamp) < (MAX_VACATION * 86400)) {
+ sprintf(&text[strlen(text)], "%s|%ld\n",
+ u->first_vacation->fromaddr,
+ u->first_vacation->timestamp
+ );
+ }
+ vptr = u->first_vacation;
+ u->first_vacation = u->first_vacation->next;
+ free(vptr);
}
- vptr = u->first_vacation;
- u->first_vacation = u->first_vacation->next;
- free(vptr);
+ sprintf(&text[strlen(text)], CTDLSIEVECONFIGSEPARATOR);
}
/* Save the config */
/* See if the user who owns this 'mailbox' has any Sieve scripts that
* require execution.
*/
- snprintf(u.config_roomname, sizeof u.config_roomname, "%010ld.%s", atol(roomname), SIEVERULES);
+ snprintf(u.config_roomname, sizeof u.config_roomname, "%010ld.%s", atol(roomname), USERCONFIGROOM);
if (getroom(&CC->room, u.config_roomname) != 0) {
lprintf(CTDL_DEBUG, "<%s> does not exist. No processing is required.\n", u.config_roomname);
return;
strcpy(hold_rm, CC->room.QRname); /* save current room */
/* Take a spin through the user's personal address book */
- if (getroom(&CC->room, SIEVERULES) == 0) {
+ if (getroom(&CC->room, USERCONFIGROOM) == 0) {
u->config_msgnum = (-1);
strcpy(u->config_roomname, CC->room.QRname);
extract_token(script_name, argbuf, 1, '|', sizeof script_name);
script_content = msiv_getscript(&u, script_name);
if (script_content != NULL) {
- cprintf("%d Script:\n", SEND_LISTING);
+ cprintf("%d Script:\n", LISTING_FOLLOWS);
cprintf("%s000\n", script_content);
}
else {