improvement on netmail message scan

This commit is contained in:
Andrew Pamment 2016-08-12 13:33:04 +10:00
parent fe197a13c3
commit 10ad4711ee

View File

@ -1865,7 +1865,7 @@ void mail_scan(struct user_record *user) {
s_JamBase *jb; s_JamBase *jb;
s_JamBaseHeader jbh; s_JamBaseHeader jbh;
s_JamLastRead jlr; s_JamLastRead jlr;
struct msg_headers *msghs;
char c; char c;
int i; int i;
int j; int j;
@ -1882,30 +1882,48 @@ void mail_scan(struct user_record *user) {
for (j=0;j<conf.mail_conferences[i]->mail_area_count;j++) { for (j=0;j<conf.mail_conferences[i]->mail_area_count;j++) {
if (conf.mail_conferences[i]->mail_areas[j]->read_sec_level > user->sec_level) { if (conf.mail_conferences[i]->mail_areas[j]->read_sec_level > user->sec_level) {
continue; continue;
} }
jb = open_jam_base(conf.mail_conferences[i]->mail_areas[j]->path); jb = open_jam_base(conf.mail_conferences[i]->mail_areas[j]->path);
if (!jb) { if (!jb) {
dolog("Unable to open message base"); dolog("Unable to open message base");
continue; continue;
} }
if (JAM_ReadMBHeader(jb, &jbh) != 0) { if (JAM_ReadMBHeader(jb, &jbh) != 0) {
JAM_CloseMB(jb); JAM_CloseMB(jb);
continue; continue;
} }
if (JAM_ReadLastRead(jb, user->id, &jlr) == JAM_NO_USER) { if (JAM_ReadLastRead(jb, user->id, &jlr) == JAM_NO_USER) {
if (jbh.ActiveMsgs == 0) { if (jbh.ActiveMsgs == 0) {
JAM_CloseMB(jb); JAM_CloseMB(jb);
continue; continue;
} }
s_printf(" --> %d. %s (%d new)\r\n", j, conf.mail_conferences[i]->mail_areas[j]->name, jbh.ActiveMsgs); if (conf.mail_conferences[i]->mail_areas[j]->type == TYPE_NETMAIL_AREA) {
} else { msghs = read_message_headers(user->cur_mail_conf, user->cur_mail_area, user);
if (jlr.HighReadMsg < (jbh.ActiveMsgs - 1)) { if (msghs != NULL) {
s_printf(" --> %d. %s (%d new)\r\n", j, conf.mail_conferences[i]->mail_areas[j]->name, (jbh.ActiveMsgs - 1) - jlr.HighReadMsg); s_printf(" --> %d. %s (%d new)\r\n", j, conf.mail_conferences[i]->mail_areas[j]->name, msghs->msg_count);
} else { free_message_headers(msghs);
JAM_CloseMB(jb); }
continue; } else {
} s_printf(" --> %d. %s (%d new)\r\n", j, conf.mail_conferences[i]->mail_areas[j]->name, jbh.ActiveMsgs);
} }
} else {
if (jlr.HighReadMsg < (jbh.ActiveMsgs - 1)) {
if (conf.mail_conferences[i]->mail_areas[j]->type == TYPE_NETMAIL_AREA) {
msghs = read_message_headers(user->cur_mail_conf, user->cur_mail_area, user);
if (msghs != NULL) {
if (msghs->msgs[msghs->msg_count-1]->msg_no > jlr.HighReadMsg) {
s_printf(" --> %d. %s (%d new)\r\n", j, conf.mail_conferences[i]->mail_areas[j]->name, msghs->msgs[msghs->msg_count-1]->msg_no - jlr.HighReadMsg);
}
free_message_headers(msghs);
}
} else {
s_printf(" --> %d. %s (%d new)\r\n", j, conf.mail_conferences[i]->mail_areas[j]->name, (jbh.ActiveMsgs - 1) - jlr.HighReadMsg);
}
} else {
JAM_CloseMB(jb);
continue;
}
}
JAM_CloseMB(jb); JAM_CloseMB(jb);
} }
} }