Skip to content
Snippets Groups Projects
Commit bd17a29f authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Make read/unread mail-waiting stats easier to access

New JS User.stats properties:
- read_mail_waiting
- unread_mail_waiting
- spam_waiting

New @-codes:
- MAILR (read mail waiting)
- MAILU (unread mail waiting)

And the corresponding MAILR# and MAILU# codes (for non-current user's stats).

Addresses feature request #191.
parent 63f42a77
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #969 passed
...@@ -1593,6 +1593,16 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen, long* pmode, bool ...@@ -1593,6 +1593,16 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen, long* pmode, bool
return(tp); return(tp);
} }
if(!strcmp(sp,"MAILR")) {
safe_snprintf(str,maxlen,"%u",getmail(&cfg,useron.number, /* Sent: */FALSE, /* attr: */MSG_READ));
return(str);
}
if(!strcmp(sp,"MAILU")) {
safe_snprintf(str,maxlen,"%u",getmail(&cfg,useron.number, /* Sent: */FALSE, /* attr: */~MSG_READ));
return(str);
}
if(!strcmp(sp,"MAILW")) { if(!strcmp(sp,"MAILW")) {
safe_snprintf(str,maxlen,"%u",getmail(&cfg,useron.number, /* Sent: */FALSE, /* attr: */0)); safe_snprintf(str,maxlen,"%u",getmail(&cfg,useron.number, /* Sent: */FALSE, /* attr: */0));
return(str); return(str);
...@@ -1608,6 +1618,16 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen, long* pmode, bool ...@@ -1608,6 +1618,16 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen, long* pmode, bool
return(str); return(str);
} }
if(!strncmp(sp,"MAILR:",6) || !strncmp(sp,"MAILR#",6)) {
safe_snprintf(str,maxlen,"%u",getmail(&cfg,atoi(sp+6), /* Sent: */FALSE, /* attr: */MSG_READ));
return(str);
}
if(!strncmp(sp,"MAILU:",6) || !strncmp(sp,"MAILU#",6)) {
safe_snprintf(str,maxlen,"%u",getmail(&cfg,atoi(sp+6), /* Sent: */FALSE, /* attr: */~MSG_READ));
return(str);
}
if(!strncmp(sp,"MAILW:",6) || !strncmp(sp,"MAILW#",6)) { if(!strncmp(sp,"MAILW:",6) || !strncmp(sp,"MAILW#",6)) {
safe_snprintf(str,maxlen,"%u",getmail(&cfg,atoi(sp+6), /* Sent: */FALSE, /* attr: */0)); safe_snprintf(str,maxlen,"%u",getmail(&cfg,atoi(sp+6), /* Sent: */FALSE, /* attr: */0));
return(str); return(str);
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
/* If sent is non-zero, it returns the number of mail sent by usernumber */ /* If sent is non-zero, it returns the number of mail sent by usernumber */
/* If usernumber is 0, it returns all mail on the system */ /* If usernumber is 0, it returns all mail on the system */
/****************************************************************************/ /****************************************************************************/
int DLLCALL getmail(scfg_t* cfg, int usernumber, BOOL sent, uint16_t attr) int DLLCALL getmail(scfg_t* cfg, int usernumber, BOOL sent, int attr)
{ {
char path[MAX_PATH+1]; char path[MAX_PATH+1];
int i=0; int i=0;
...@@ -55,7 +55,9 @@ int DLLCALL getmail(scfg_t* cfg, int usernumber, BOOL sent, uint16_t attr) ...@@ -55,7 +55,9 @@ int DLLCALL getmail(scfg_t* cfg, int usernumber, BOOL sent, uint16_t attr)
continue; continue;
if(idx.attr&MSG_DELETE) if(idx.attr&MSG_DELETE)
continue; continue;
if((idx.attr&attr) != attr) if(attr < 0 && (idx.attr & (~attr)) != 0)
continue;
if(attr > 0 && (idx.attr & attr) != attr)
continue; continue;
if(usernumber == 0 if(usernumber == 0
|| (!sent && idx.to==usernumber) || (!sent && idx.to==usernumber)
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
extern "C" { extern "C" {
#endif #endif
DLLEXPORT int getmail(scfg_t* cfg, int usernumber, BOOL sent, uint16_t attr); DLLEXPORT int getmail(scfg_t* cfg, int usernumber, BOOL sent, int attr);
DLLEXPORT mail_t * loadmail(smb_t* smb, uint32_t* msgs, uint usernumber DLLEXPORT mail_t * loadmail(smb_t* smb, uint32_t* msgs, uint usernumber
,int which, long mode); ,int which, long mode);
DLLEXPORT void freemail(mail_t* mail); DLLEXPORT void freemail(mail_t* mail);
......
/* Synchronet JavaScript "User" Object */ /* Synchronet JavaScript "User" Object */
// vi: tabstop=4
/* $Id: js_user.c,v 1.119 2020/08/11 03:54:58 rswindell Exp $ */
/**************************************************************************** /****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.tab-size 4 (Plain Text/Source Code File Header) *
...@@ -16,21 +13,9 @@ ...@@ -16,21 +13,9 @@
* See the GNU General Public License for more details: gpl.txt or * * See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html * * http://www.fsf.org/copyleft/gpl.html *
* * * *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see * * For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html * * http://www.synchro.net/source.html *
* * * *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. * * Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/ ****************************************************************************/
...@@ -88,6 +73,9 @@ enum { ...@@ -88,6 +73,9 @@ enum {
,USER_PROP_ETODAY ,USER_PROP_ETODAY
,USER_PROP_PTODAY ,USER_PROP_PTODAY
,USER_PROP_MAIL_WAITING ,USER_PROP_MAIL_WAITING
,USER_PROP_READ_WAITING
,USER_PROP_UNREAD_WAITING
,USER_PROP_SPAM_WAITING
,USER_PROP_MAIL_PENDING ,USER_PROP_MAIL_PENDING
,USER_PROP_ULB ,USER_PROP_ULB
,USER_PROP_ULS ,USER_PROP_ULS
...@@ -391,7 +379,16 @@ static JSBool js_user_get(JSContext *cx, JSObject *obj, jsid id, jsval *vp) ...@@ -391,7 +379,16 @@ static JSBool js_user_get(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
val=scfg->level_freecdtperday[p->user->level]; val=scfg->level_freecdtperday[p->user->level];
break; break;
case USER_PROP_MAIL_WAITING: case USER_PROP_MAIL_WAITING:
val=getmail(scfg,p->user->number,/* sent? */FALSE, /* SPAM: */FALSE); val=getmail(scfg,p->user->number,/* sent? */FALSE, /* attr: */0);
break;
case USER_PROP_READ_WAITING:
val=getmail(scfg,p->user->number,/* sent? */FALSE, /* attr: */MSG_READ);
break;
case USER_PROP_UNREAD_WAITING:
val=getmail(scfg,p->user->number,/* sent? */FALSE, /* attr: */~MSG_READ);
break;
case USER_PROP_SPAM_WAITING:
val=getmail(scfg,p->user->number,/* sent? */FALSE, /* attr: */MSG_SPAM);
break; break;
case USER_PROP_MAIL_PENDING: case USER_PROP_MAIL_PENDING:
val=getmail(scfg,p->user->number,/* sent? */TRUE, /* SPAM: */FALSE); val=getmail(scfg,p->user->number,/* sent? */TRUE, /* SPAM: */FALSE);
...@@ -960,6 +957,9 @@ static jsSyncPropertySpec js_user_stats_properties[] = { ...@@ -960,6 +957,9 @@ static jsSyncPropertySpec js_user_stats_properties[] = {
{ "files_downloaded" ,USER_PROP_DLS ,USER_PROP_FLAGS, 310 }, { "files_downloaded" ,USER_PROP_DLS ,USER_PROP_FLAGS, 310 },
{ "leech_attempts" ,USER_PROP_LEECH ,USER_PROP_FLAGS, 310 }, { "leech_attempts" ,USER_PROP_LEECH ,USER_PROP_FLAGS, 310 },
{ "mail_waiting" ,USER_PROP_MAIL_WAITING ,USER_PROP_FLAGS, 312 }, { "mail_waiting" ,USER_PROP_MAIL_WAITING ,USER_PROP_FLAGS, 312 },
{ "read_mail_waiting" ,USER_PROP_READ_WAITING ,USER_PROP_FLAGS, 31802 },
{ "unread_mail_waiting",USER_PROP_UNREAD_WAITING,USER_PROP_FLAGS, 31802 },
{ "spam_waiting" ,USER_PROP_SPAM_WAITING ,USER_PROP_FLAGS, 31802 },
{ "mail_pending" ,USER_PROP_MAIL_PENDING ,USER_PROP_FLAGS, 312 }, { "mail_pending" ,USER_PROP_MAIL_PENDING ,USER_PROP_FLAGS, 312 },
{0} {0}
}; };
...@@ -984,7 +984,10 @@ static char* user_stats_prop_desc[] = { ...@@ -984,7 +984,10 @@ static char* user_stats_prop_desc[] = {
,"total bytes downloaded" ,"total bytes downloaded"
,"total files downloaded" ,"total files downloaded"
,"suspected leech downloads" ,"suspected leech downloads"
,"number of e-mail messages currently waiting" ,"total number of e-mail messages currently waiting in inbox"
,"number of read e-mail messages currently waiting in inbox"
,"number of unread e-mail messages currently waiting in inbox"
,"number of SPAM e-mail messages currently waiting in inbox"
,"number of e-mail messages sent, currently pending deletion" ,"number of e-mail messages sent, currently pending deletion"
,NULL ,NULL
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment