This fixes bug #297
To impliment this I created a new API call CtdlGetCurrentMessageNumber()
this returns the message number currently in use IE the last one
allocated. This is good enough for Sieve in this case and probably good
enough for other things too.
+/*
+ * CtdlGetCurrentMessageNumber() - Obtain the current highest message number in the system
+ * This provides a quick way to initialise a variable that might be used to indicate
+ * messages that should not be processed. EG. a new Sieve script will use this
+ * to record determine that messages older than this should not be processed.
+ */
+long CtdlGetCurrentMessageNumber(void)
+{
+ long retval = 0L;
+ begin_critical_section(S_CONTROL);
+ get_control();
+ retval = CitControl.MMhighest;
+ end_critical_section(S_CONTROL);
+ return(retval);
+}
+
+
/*
* get_new_user_number() - Obtain a new, unique ID to be used for a user.
*/
/*
* get_new_user_number() - Obtain a new, unique ID to be used for a user.
*/
+/*
+ * CtdlGetCurrentMessageNumber() - Obtain the current highest message number in the system
+ * This provides a quick way to initialise a variable that might be used to indicate
+ * messages that should not be processed. EG. a new Sieve script will use this
+ * to record determine that messages older than this should not be processed.
+ * This function is defined in control.c
+ */
+long CtdlGetCurrentMessageNumber(void);
+
#endif /* CTDL_MODULE_H */
#endif /* CTDL_MODULE_H */
}
void msiv_store(struct sdm_userdata *u, int yes_write_to_disk) {
}
void msiv_store(struct sdm_userdata *u, int yes_write_to_disk) {
+/*
+ * Initialise the sieve configs last processed message number.
+ * We don't need to get the highest message number for the users inbox since the systems
+ * highest message number will be higher than that and loer than this scripts message number
+ * This prevents this new script from processing any old messages in the inbox.
+ * Most importantly it will prevent vacation messages being sent to lots of old messages
+ * in the inbox.
+ */
+ u->lastproc = CtdlGetCurrentMessageNumber();
rewrite_ctdl_sieve_config(u, yes_write_to_disk);
}
rewrite_ctdl_sieve_config(u, yes_write_to_disk);
}