Add personal mail scan

This commit is contained in:
Andrew Pamment 2018-02-18 13:51:39 +10:00
parent 9fe6c9d475
commit 9390dedc82
11 changed files with 83 additions and 19 deletions

View File

@ -19,6 +19,10 @@ LINE: 204 MODIFIED
OLDSTRING: "\e[1;31mUser not found! Assuming new user...\e[0m\r\n\r\n" OLDSTRING: "\e[1;31mUser not found! Assuming new user...\e[0m\r\n\r\n"
NEWSTRING: "\r\n\e[1;31mUser not found!\e[0m\r\n\r\n" NEWSTRING: "\r\n\e[1;31mUser not found!\e[0m\r\n\r\n"
LINE: 277 NEW
OLDSTRING: (NONE)
NEWSTRING: "\r\nScan for new personal mail? (Y/N/S): "
Changes from v0.8-alpha -> v0.9-alpha Changes from v0.8-alpha -> v0.9-alpha
-------------------------------------------------------------- --------------------------------------------------------------
LINE: 255 NEW LINE: 255 NEW

View File

@ -274,3 +274,4 @@ File exists!\r\n
\e[10;22H\e[1;37mPress \e[1;33mA \e[1;37m to Add yours or \e[1;33mQ \e[1;37mto Quit\e[0m \e[10;22H\e[1;37mPress \e[1;33mA \e[1;37m to Add yours or \e[1;33mQ \e[1;37mto Quit\e[0m
\r\n\e[1;31mError executing archiver.\r\n\e[0m \r\n\e[1;31mError executing archiver.\r\n\e[0m
\r\n\r\n\e[1;37m(\e[1;32mV\e[1;37m)iew or \e[1;37m(\e[1;32mU\e[1;37m)pdate Automessage or \e[1;37m(\e[1;31mQ\e[1;37m)uit: \e[0m \r\n\r\n\e[1;37m(\e[1;32mV\e[1;37m)iew or \e[1;37m(\e[1;32mU\e[1;37m)pdate Automessage or \e[1;37m(\e[1;31mQ\e[1;37m)uit: \e[0m
\r\nScan for new personal mail? (Y/N/S):

View File

@ -83,6 +83,8 @@ end
bbs_mail_scan(); bbs_mail_scan();
bbs_personal_mail_scan();
bbs_file_scan(); bbs_file_scan();
-- Display Auto Message -- Display Auto Message

View File

@ -118,7 +118,7 @@ Finally, an optional SECLEVEL command indicates the required security level for
**FILESCAN** Scan for new files. **FILESCAN** Scan for new files.
**FULLMAILSCAN** Scan for new messages and display them. **FULLMAILSCAN** Scan for new messages and display them. Optional DATA PERSONAL for personal mail scan.
**FILESEARCH** Search for a file. **FILESEARCH** Search for a file.

View File

@ -96,6 +96,8 @@ Where data is the name of the lua script to call without the extension.
**bbs_full_mail_scan** Performs a full mail scan (like a mail scan but also displays new messages) **bbs_full_mail_scan** Performs a full mail scan (like a mail scan but also displays new messages)
**bbs_personal_mail_scan** Performs a full mail scan (like a full mail scan but only displays personal messages)
**bbs_get_userhandle** Returns the logged in user's handle **bbs_get_userhandle** Returns the logged in user's handle
**bbs_message_found** Takes three numbers, the conference, area and the message number, returns one number, 1 if found, 0 if not. **bbs_message_found** Takes three numbers, the conference, area and the message number, returns one number, 1 if found, 0 if not.

View File

@ -284,7 +284,7 @@ extern void display_textfiles();
extern time_t utc_to_local(time_t utc); extern time_t utc_to_local(time_t utc);
extern s_JamBase *open_jam_base(char *path); extern s_JamBase *open_jam_base(char *path);
extern void free_message_headers(struct msg_headers *msghs); extern void free_message_headers(struct msg_headers *msghs);
extern struct msg_headers *read_message_headers(int msgconf, int msgarea, struct user_record *user); extern struct msg_headers *read_message_headers(int msgconf, int msgarea, struct user_record *user, int personal);
extern void mail_scan(struct user_record *user); extern void mail_scan(struct user_record *user);
extern char *editor(struct user_record *user, char *quote, int qlen, char *from, int email, int sig); extern char *editor(struct user_record *user, char *quote, int qlen, char *from, int email, int sig);
extern char *external_editor(struct user_record *user, char *to, char *from, char *quote, int qlen, char *qfrom, char *subject, int email, int sig); extern char *external_editor(struct user_record *user, char *to, char *from, char *quote, int qlen, char *qfrom, char *subject, int email, int sig);
@ -304,6 +304,7 @@ extern void msg_conf_sub_bases();
extern void msgbase_reset_pointers(int conference, int msgarea, int readm, int msgno); extern void msgbase_reset_pointers(int conference, int msgarea, int readm, int msgno);
extern void msgbase_reset_all_pointers(int readm); extern void msgbase_reset_all_pointers(int readm);
extern void full_mail_scan(struct user_record *user); extern void full_mail_scan(struct user_record *user);
extern void full_mail_scan_personal(struct user_record *user);
extern int read_new_msgs(struct user_record *user, struct msg_headers *msghs); extern int read_new_msgs(struct user_record *user, struct msg_headers *msghs);
extern int new_messages(struct user_record *user, int conference, int area); extern int new_messages(struct user_record *user, int conference, int area);

View File

@ -134,7 +134,7 @@ int bwave_scan_email(int areano, int totmsgs, FILE *fti_file, FILE *mix_file, FI
} }
int bwave_scan_area(int confr, int area, int areano, int totmsgs, FILE *fti_file, FILE *mix_file, FILE *dat_file, int *last_ptr) { int bwave_scan_area(int confr, int area, int areano, int totmsgs, FILE *fti_file, FILE *mix_file, FILE *dat_file, int *last_ptr) {
struct msg_headers *msghs = read_message_headers(confr, area, gUser); struct msg_headers *msghs = read_message_headers(confr, area, gUser, 0);
int all_unread = 1; int all_unread = 1;
s_JamBase *jb; s_JamBase *jb;
s_JamLastRead jlr; s_JamLastRead jlr;

View File

@ -115,6 +115,11 @@ int l_bbsFullMailScan(lua_State *L) {
return 0; return 0;
} }
int l_bbsPersonalMailScan(lua_State *L) {
full_mail_scan_personal(gUser);
return 0;
}
int l_bbsMailScan(lua_State *L) { int l_bbsMailScan(lua_State *L) {
mail_scan(gUser); mail_scan(gUser);
return 0; return 0;
@ -609,6 +614,8 @@ void lua_push_cfunctions(lua_State *L) {
lua_setglobal(L, "bbs_data_path"); lua_setglobal(L, "bbs_data_path");
lua_pushcfunction(L, l_userSecurity); lua_pushcfunction(L, l_userSecurity);
lua_setglobal(L, "bbs_user_security"); lua_setglobal(L, "bbs_user_security");
lua_pushcfunction(L, l_bbsPersonalMailScan);
lua_setglobal(L, "bbs_personal_mail_scan");
} }
void do_lua_script(char *script) { void do_lua_script(char *script) {

View File

@ -206,7 +206,7 @@ int msg_is_from(struct user_record *user, char *addressed_from, char *address, i
} }
} }
struct msg_headers *read_message_headers(int msgconf, int msgarea, struct user_record *user) { struct msg_headers *read_message_headers(int msgconf, int msgarea, struct user_record *user, int personal) {
s_JamBase *jb; s_JamBase *jb;
s_JamBaseHeader jbh; s_JamBaseHeader jbh;
s_JamMsgHeader jmh; s_JamMsgHeader jmh;
@ -340,6 +340,36 @@ struct msg_headers *read_message_headers(int msgconf, int msgarea, struct user_r
k++; k++;
continue; continue;
} }
} else if (personal) {
if (!msg_is_to(user, jamm->to, jamm->daddress, conf.mail_conferences[msgconf]->nettype, conf.mail_conferences[msgconf]->realnames, msgconf) &&
!msg_is_to(user, jamm->to, jamm->daddress, conf.mail_conferences[msgconf]->nettype, !conf.mail_conferences[msgconf]->realnames, msgconf)) {
if (jamm->subject != NULL) {
free(jamm->subject);
}
if (jamm->from != NULL) {
free(jamm->from);
}
if (jamm->to != NULL) {
free(jamm->to);
}
if (jamm->oaddress != NULL) {
free(jamm->oaddress);
}
if (jamm->daddress != NULL) {
free(jamm->daddress);
}
if (jamm->msgid != NULL) {
free(jamm->msgid);
}
if (jamm->replyid != NULL) {
free(jamm->replyid);
}
free(jamm->msg_h);
free(jamm);
k++;
continue;
}
} }
if (msghs->msg_count == 0) { if (msghs->msg_count == 0) {
@ -2012,7 +2042,7 @@ void read_mail(struct user_record *user) {
s_printf("\r\n"); s_printf("\r\n");
// list mail in message base // list mail in message base
msghs = read_message_headers(user->cur_mail_conf, user->cur_mail_area, user); msghs = read_message_headers(user->cur_mail_conf, user->cur_mail_area, user, 0);
if (msghs != NULL && msghs->msg_count > 0) { if (msghs != NULL && msghs->msg_count > 0) {
jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path); jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
if (!jb) { if (!jb) {
@ -2341,7 +2371,7 @@ void list_messages(struct user_record *user) {
s_printf("\r\n"); s_printf("\r\n");
// list mail in message base // list mail in message base
msghs = read_message_headers(user->cur_mail_conf, user->cur_mail_area, user); msghs = read_message_headers(user->cur_mail_conf, user->cur_mail_area, user, 0);
if (msghs != NULL && msghs->msg_count > 0) { if (msghs != NULL && msghs->msg_count > 0) {
jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path); jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
if (!jb) { if (!jb) {
@ -2570,7 +2600,7 @@ void list_messages(struct user_record *user) {
redraw = 1; redraw = 1;
read_message(user, msghs, i - 1, 0); read_message(user, msghs, i - 1, 0);
free_message_headers(msghs); free_message_headers(msghs);
msghs = read_message_headers(user->cur_mail_conf, user->cur_mail_area, user); msghs = read_message_headers(user->cur_mail_conf, user->cur_mail_area, user, 0);
jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path); jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
if (!jb) { if (!jb) {
dolog("Error opening JAM base.. %s", conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path); dolog("Error opening JAM base.. %s", conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
@ -2959,7 +2989,7 @@ void prev_mail_area(struct user_record *user) {
void do_mail_scan(struct user_record *user, int oldscan) { void do_mail_scan(struct user_record *user, int oldscan, int personal) {
s_JamBase *jb; s_JamBase *jb;
s_JamBaseHeader jbh; s_JamBaseHeader jbh;
s_JamLastRead jlr; s_JamLastRead jlr;
@ -2971,7 +3001,12 @@ void do_mail_scan(struct user_record *user, int oldscan) {
int orig_conf; int orig_conf;
int orig_area; int orig_area;
int res = 0; int res = 0;
s_printf(get_string(139));
if (personal) {
s_printf(get_string(276));
} else {
s_printf(get_string(139));
}
c = s_getc(); c = s_getc();
if (tolower(c) == 'y' || tolower(c) == 's') { if (tolower(c) == 'y' || tolower(c) == 's') {
@ -3014,7 +3049,7 @@ void do_mail_scan(struct user_record *user, int oldscan) {
continue; continue;
} }
if (conf.mail_conferences[i]->mail_areas[j]->type == TYPE_NETMAIL_AREA) { if (conf.mail_conferences[i]->mail_areas[j]->type == TYPE_NETMAIL_AREA) {
msghs = read_message_headers(i, j, user); msghs = read_message_headers(i, j, user, personal);
if (msghs != NULL) { if (msghs != NULL) {
if (msghs->msg_count > 0) { if (msghs->msg_count > 0) {
if (oldscan) { if (oldscan) {
@ -3050,7 +3085,7 @@ void do_mail_scan(struct user_record *user, int oldscan) {
lines = 0; lines = 0;
} }
} else { } else {
msghs = read_message_headers(i, j, user); msghs = read_message_headers(i, j, user, personal);
if (msghs != NULL) { if (msghs != NULL) {
if (msghs->msg_count > 0) { if (msghs->msg_count > 0) {
orig_conf = user->cur_mail_conf; orig_conf = user->cur_mail_conf;
@ -3071,7 +3106,7 @@ void do_mail_scan(struct user_record *user, int oldscan) {
} else { } else {
if (jlr.HighReadMsg < jbh.ActiveMsgs) { if (jlr.HighReadMsg < jbh.ActiveMsgs) {
if (conf.mail_conferences[i]->mail_areas[j]->type == TYPE_NETMAIL_AREA) { if (conf.mail_conferences[i]->mail_areas[j]->type == TYPE_NETMAIL_AREA) {
msghs = read_message_headers(i, j, user); msghs = read_message_headers(i, j, user, personal);
if (msghs != NULL) { if (msghs != NULL) {
if (msghs->msg_count > 0) { if (msghs->msg_count > 0) {
if (msghs->msgs[msghs->msg_count-1]->msg_no > jlr.HighReadMsg) { if (msghs->msgs[msghs->msg_count-1]->msg_no > jlr.HighReadMsg) {
@ -3109,7 +3144,7 @@ void do_mail_scan(struct user_record *user, int oldscan) {
lines = 0; lines = 0;
} }
} else { } else {
msghs = read_message_headers(i, j, user); msghs = read_message_headers(i, j, user, personal);
if (msghs != NULL) { if (msghs != NULL) {
if (msghs->msg_count > 0) { if (msghs->msg_count > 0) {
orig_conf = user->cur_mail_conf; orig_conf = user->cur_mail_conf;
@ -3149,12 +3184,16 @@ void do_mail_scan(struct user_record *user, int oldscan) {
} }
} }
void full_mail_scan_personal(struct user_record *user) {
do_mail_scan(user, 0, 1);
}
void full_mail_scan(struct user_record *user) { void full_mail_scan(struct user_record *user) {
do_mail_scan(user, 0); do_mail_scan(user, 0, 0);
} }
void mail_scan(struct user_record *user) { void mail_scan(struct user_record *user) {
do_mail_scan(user, 1); do_mail_scan(user, 1, 0);
} }
@ -3352,7 +3391,7 @@ int new_messages(struct user_record *user, int conference, int area) {
return 0; return 0;
} }
if (conf.mail_conferences[conference]->mail_areas[area]->type == TYPE_NETMAIL_AREA) { if (conf.mail_conferences[conference]->mail_areas[area]->type == TYPE_NETMAIL_AREA) {
msghs = read_message_headers(conference, area, user); msghs = read_message_headers(conference, area, user, 0);
if (msghs != NULL) { if (msghs != NULL) {
if (msghs->msg_count > 0) { if (msghs->msg_count > 0) {
count = msghs->msg_count; count = msghs->msg_count;
@ -3365,7 +3404,7 @@ int new_messages(struct user_record *user, int conference, int area) {
} else { } else {
if (jlr.HighReadMsg < jbh.ActiveMsgs) { if (jlr.HighReadMsg < jbh.ActiveMsgs) {
if (conf.mail_conferences[conference]->mail_areas[area]->type == TYPE_NETMAIL_AREA) { if (conf.mail_conferences[conference]->mail_areas[area]->type == TYPE_NETMAIL_AREA) {
msghs = read_message_headers(conference, area, user); msghs = read_message_headers(conference, area, user, 0);
if (msghs != NULL) { if (msghs != NULL) {
if (msghs->msg_count > 0) { if (msghs->msg_count > 0) {
if (msghs->msgs[msghs->msg_count-1]->msg_h->MsgNum > jlr.HighReadMsg) { if (msghs->msgs[msghs->msg_count-1]->msg_h->MsgNum > jlr.HighReadMsg) {

View File

@ -545,7 +545,15 @@ int menu_system(char *menufile) {
file_scan(); file_scan();
break; break;
case MENU_FULLMAILSCAN: case MENU_FULLMAILSCAN:
full_mail_scan(gUser); if (menu[i]->data != NULL) {
if (strcasecmp(menu[i]->data, "PERSONAL") == 0) {
full_mail_scan_personal(gUser);
} else {
full_mail_scan(gUser);
}
} else {
full_mail_scan(gUser);
}
break; break;
case MENU_FILESEARCH: case MENU_FILESEARCH:
file_search(); file_search();

View File

@ -150,7 +150,7 @@ char *www_msgs_messagelist(struct user_record *user, int conference, int area, i
strcat(page, buffer); strcat(page, buffer);
len += strlen(buffer); len += strlen(buffer);
} }
mhrs = read_message_headers(conference, area, user); mhrs = read_message_headers(conference, area, user, 0);
if (mhrs == NULL) { if (mhrs == NULL) {
sprintf(buffer, "<h3>No Messages</h3>\n"); sprintf(buffer, "<h3>No Messages</h3>\n");