#include "html.h"
#include "genstamp.h"
#include "internet_addressing.h"
-#include "serv_fulltext.h"
#include "vcard.h"
#include "euidindex.h"
#include "journaling.h"
#include "citadel_dirs.h"
-#include "serv_network.h"
-#ifdef HAVE_LIBSIEVE
-# include "serv_sieve.h"
-#endif /* HAVE_LIBSIEVE */
long config_msgnum;
struct addresses_to_be_filed *atbf = NULL;
int num_search_msgs = 0;
long *search_msgs = NULL;
regex_t re;
+ int need_to_free_re = 0;
regmatch_t pm;
if (content_type) if (strlen(content_type) > 0) {
regcomp(&re, content_type, 0);
+ need_to_free_re = 1;
}
/* Learn about the user and room in question */
num_msgs = cdbfr->len / sizeof(long);
cdb_free(cdbfr);
} else {
+ if (need_to_free_re) regfree(&re);
return 0; /* No messages at all? No further action. */
}
* over again.
*/
if ( (num_msgs > 0) && (mode == MSGS_SEARCH) && (search_string) ) {
- ft_search(&num_search_msgs, &search_msgs, search_string);
+
+ /* Call search module via hook mechanism.
+ * NULL means use any search function available.
+ * otherwise replace with a char * to name of search routine
+ */
+ CtdlModuleDoSearch(&num_search_msgs, &search_msgs, search_string, "fulltext");
+
if (num_search_msgs > 0) {
int orig_num_msgs;
}
}
free(msglist); /* Clean up */
+ if (need_to_free_re) regfree(&re);
return num_processed;
}
*found_it = 1;
- cprintf("%d %d\n", BINARY_FOLLOWS, length);
+ cprintf("%d %d\n", BINARY_FOLLOWS, (int)length);
client_write(content, length);
}
lprintf(CTDL_DEBUG, "CtdlSaveMsgPointerInRoom() skips repl checks\n");
}
- /* Submit this room for net processing */
- network_queue_room(&CC->room, NULL);
-
-#ifdef HAVE_LIBSIEVE
- /* If this is someone's inbox, submit the room for sieve processing */
- if (!strcasecmp(&CC->room.QRname[11], MAILROOM)) {
- sieve_queue_room(&CC->room);
- }
-#endif /* HAVE_LIBSIEVE */
+ /* Submit this room for processing by hooks */
+ PerformRoomHooks(&CC->room);
/* Go back to the room we were in before we wandered here... */
getroom(&CC->room, hold_rm);
char dest_node[256];
char buf[1024];
struct CtdlMessage *msg;
+ int i;
msg = malloc(sizeof(struct CtdlMessage));
memset(msg, 0, sizeof(struct CtdlMessage));
striplt(recipient);
striplt(recp_cc);
- snprintf(buf, sizeof buf, "cit%ld", author->usernum); /* Path */
- msg->cm_fields['P'] = strdup(buf);
+ /* Path or Return-Path */
+ if (my_email == NULL) my_email = "";
+
+ if (strlen(my_email) > 0) {
+ msg->cm_fields['P'] = strdup(my_email);
+ }
+ else {
+ snprintf(buf, sizeof buf, "%s", author->fullname);
+ msg->cm_fields['P'] = strdup(buf);
+ }
+ for (i=0; (msg->cm_fields['P'][i]!=0); ++i) {
+ if (isspace(msg->cm_fields['P'][i])) {
+ msg->cm_fields['P'][i] = '_';
+ }
+ }
snprintf(buf, sizeof buf, "%ld", (long)time(NULL)); /* timestamp */
msg->cm_fields['T'] = strdup(buf);
struct recptypes *valid_cc = NULL;
struct recptypes *valid_bcc = NULL;
char subject[SIZ];
+ int subject_required = 0;
int do_confirm = 0;
long msgnum;
int i, j;
recp[0] = 0;
}
+ /* Recommend to the client that the use of a message subject is
+ * strongly recommended in this room, if either the SUBJECTREQ flag
+ * is set, or if there is one or more Internet email recipients.
+ */
+ if (CC->room.QRflags2 & QR2_SUBJECTREQ) subject_required = 1;
+ if (valid_to) if (valid_to->num_internet > 0) subject_required = 1;
+ if (valid_cc) if (valid_cc->num_internet > 0) subject_required = 1;
+ if (valid_bcc) if (valid_bcc->num_internet > 0) subject_required = 1;
+
/* If we're only checking the validity of the request, return
* success without creating the message.
*/
if (post == 0) {
- cprintf("%d %s\n", CIT_OK,
- ((valid_to != NULL) ? valid_to->display_recp : "") );
+ cprintf("%d %s|%d\n", CIT_OK,
+ ((valid_to != NULL) ? valid_to->display_recp : ""),
+ subject_required);
free_recipients(valid_to);
free_recipients(valid_cc);
free_recipients(valid_bcc);
struct MetaData smi;
regex_t re;
regmatch_t pm;
+ int need_to_free_re = 0;
if (content_type) if (strlen(content_type) > 0) {
regcomp(&re, content_type, 0);
+ need_to_free_re = 1;
}
lprintf(CTDL_DEBUG, "CtdlDeleteMessages(%s, %d msgs, %s)\n",
room_name, num_dmsgnums, content_type);
if (lgetroom(&qrbuf, room_name) != 0) {
lprintf(CTDL_ERR, "CtdlDeleteMessages(): Room <%s> not found\n",
room_name);
+ if (need_to_free_re) regfree(&re);
return (0); /* room not found */
}
cdbfr = cdb_fetch(CDB_MSGLISTS, &qrbuf.QRnumber, sizeof(long));
if (msglist != NULL) free(msglist);
if (dellist != NULL) free(dellist);
lprintf(CTDL_DEBUG, "%d message(s) deleted.\n", num_deleted);
+ if (need_to_free_re) regfree(&re);
return (num_deleted);
}
*/
if (smi.meta_refcount == 0) {
lprintf(CTDL_DEBUG, "Deleting message <%ld>\n", msgnum);
-
- /* Remove from fulltext index */
- if (config.c_enable_fulltext) {
- ft_index_message(msgnum, 0);
- }
+
+ /* Call delete hooks with NULL room to show it has gone altogether */
+ PerformDeleteHooks(NULL, msgnum);
/* Remove from message base */
delnum = msgnum;