summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/proto.h1
-rw-r--r--include/pttstruct.h4
-rw-r--r--mbbsd/bbs.c16
-rw-r--r--mbbsd/mail.c16
-rw-r--r--mbbsd/passwd.c10
-rw-r--r--mbbsd/var.c1
6 files changed, 39 insertions, 9 deletions
diff --git a/include/proto.h b/include/proto.h
index ff7d4bcb..5ae70d75 100644
--- a/include/proto.h
+++ b/include/proto.h
@@ -351,6 +351,7 @@ int x_love(void);
/* mail */
int load_mailalert(const char *userid);
int sendalert(const char *userid, int alert);
+int sendalert_uid(int uid, int alert);
int mail_muser(const userec_t muser, const char *title, const char *filename);
int mail_log2id(const char *id, const char *title, const char *srcfile, const char *owner, char newmail, char trymove);
int mail_id(const char* id, const char *title, const char *filename, const char *owner);
diff --git a/include/pttstruct.h b/include/pttstruct.h
index 74c61199..ea6cf302 100644
--- a/include/pttstruct.h
+++ b/include/pttstruct.h
@@ -310,9 +310,9 @@ typedef struct msgque_t {
#define ALERT_PWD_GOODPOST (0x08)
#define ALERT_PWD_JUSTIFY (0x10)
// #define ALERT_PWD_LOGINS (0x20)
-// #define ALERT_PWD_POSTS (0x40)
+#define ALERT_PWD_POSTS (0x40)
#define ALERT_PWD_RELOAD (0x80) // reload entire pwd
-#define ALERT_PWD (ALERT_PWD_PERM|ALERT_PWD_BADPOST|ALERT_PWD_GOODPOST|ALERT_PWD_JUSTIFY|ALERT_PWD_RELOAD)
+#define ALERT_PWD (ALERT_PWD_PERM|ALERT_PWD_BADPOST|ALERT_PWD_GOODPOST|ALERT_PWD_JUSTIFY|ALERT_PWD_POSTS|ALERT_PWD_RELOAD)
// userinfo_t.angelpause values
#define ANGELPAUSE_NONE (0) // reject none (accept all)
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index 344c534f..3831ec12 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -1108,8 +1108,9 @@ do_general(int isbid)
#endif
aborted /= 2;
- // drop money for free boards
- if (IsFreeBoardName(currboard) || (currbrdattr&BRD_BAD))
+ // drop money & numposts for free boards
+ // including: special boards (e.g. TEST, ALLPOST), bad boards, no BM boards
+ if (IsFreeBoardName(currboard) || (currbrdattr&BRD_BAD) || bp->BM[0] < ' ')
{
aborted = 0;
}
@@ -3330,8 +3331,15 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
// not owner case
if (tusernum)
{
+ userec_t xuser;
+ passwd_query(tusernum, &xuser);
+ xuser.numposts--;
+ passwd_update(tusernum, &xuser);
+ sendalert_uid(tusernum, ALERT_PWD_POSTS);
+
// TODO alert user?
deumoney(tusernum, -fhdr->multi.money);
+
#ifdef USE_COOLDOWN
if (bp->brdattr & BRD_COOLDOWN)
add_cooldowntime(tusernum, 15);
@@ -3341,8 +3349,10 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
else
{
// owner case
- if (cuser.numposts)
+ if (cuser.numposts){
cuser.numposts--;
+ sendalert(cuser.userid, ALERT_PWD_POSTS);
+ }
demoney(-fhdr->multi.money);
vmsgf("您的文章減為 %d 篇,支付清潔費 %d 銀",
cuser.numposts, fhdr->multi.money);
diff --git a/mbbsd/mail.c b/mbbsd/mail.c
index d0eecd2f..fc7ae823 100644
--- a/mbbsd/mail.c
+++ b/mbbsd/mail.c
@@ -119,16 +119,24 @@ built_mail_index(void)
int
sendalert(const char *userid, int alert)
{
- userinfo_t *uentp = NULL;
- int n, tuid, i;
+ int tuid;
if ((tuid = searchuser(userid, NULL)) == 0)
return -1;
- n = count_logins(tuid, 0);
+ return sendalert_uid(tuid, alert);
+}
+
+int
+sendalert_uid(int uid, int alert){
+ userinfo_t *uentp = NULL;
+ int n, i;
+
+ n = count_logins(uid, 0);
for (i = 1; i <= n; i++)
- if ((uentp = (userinfo_t *) search_ulistn(tuid, i)))
+ if ((uentp = (userinfo_t *) search_ulistn(uid, i)))
uentp->alerts |= alert;
+
return 0;
}
diff --git a/mbbsd/passwd.c b/mbbsd/passwd.c
index b5e85907..95e655a1 100644
--- a/mbbsd/passwd.c
+++ b/mbbsd/passwd.c
@@ -101,6 +101,7 @@ passwd_update(int num, userec_t * buf)
memcpy(buf->email, u.email, sizeof(u.email));
memcpy(cuser.email, u.email, sizeof(u.email));
}
+ cuser.numposts += u.numposts - latest_numposts;
currutmp->alerts &= ~ALERT_PWD;
// ALERT_PWD_RELOAD: reload all! No need to write.
@@ -115,6 +116,11 @@ passwd_update(int num, userec_t * buf)
lseek(pwdfd, sizeof(userec_t) * (num - 1), SEEK_SET);
write(pwdfd, buf, sizeof(userec_t));
close(pwdfd);
+
+ if (latest_numposts != cuser.numposts) {
+ sendalert_uid(usernum, ALERT_PWD_POSTS);
+ latest_numposts = cuser.numposts;
+ }
return 0;
}
@@ -129,6 +135,10 @@ passwd_query(int num, userec_t * buf)
lseek(pwdfd, sizeof(userec_t) * (num - 1), SEEK_SET);
read(pwdfd, buf, sizeof(userec_t));
close(pwdfd);
+
+ if (buf == &cuser)
+ latest_numposts = cuser.numposts;
+
return 0;
}
diff --git a/mbbsd/var.c b/mbbsd/var.c
index a6d3811e..46e58bd3 100644
--- a/mbbsd/var.c
+++ b/mbbsd/var.c
@@ -104,6 +104,7 @@ userec_t cuser; /* current user structure */
crosspost_t postrecord; /* anti cross post */
unsigned int currbrdattr;
unsigned int currstat;
+uint32_t latest_numposts;
/* global string variables */
/* filename */