diff options
-rw-r--r-- | pttbbs/include/proto.h | 1 | ||||
-rw-r--r-- | pttbbs/mbbsd/bbs.c | 14 | ||||
-rw-r--r-- | pttbbs/mbbsd/cal.c | 19 | ||||
-rw-r--r-- | pttbbs/mbbsd/friend.c | 11 | ||||
-rw-r--r-- | pttbbs/mbbsd/mail.c | 31 | ||||
-rw-r--r-- | pttbbs/mbbsd/ordersong.c | 10 | ||||
-rw-r--r-- | pttbbs/mbbsd/vtuikit.c | 1 |
7 files changed, 36 insertions, 51 deletions
diff --git a/pttbbs/include/proto.h b/pttbbs/include/proto.h index 7770cc46..476a31d3 100644 --- a/pttbbs/include/proto.h +++ b/pttbbs/include/proto.h @@ -273,6 +273,7 @@ void friend_delete(const char *uident, int type); void friend_delete_all(const char *uident, int type); void friend_special(void); void setfriendfile(char *fpath, int type); +int is_rejected(const char *userid); /* gamble */ int ticket_main(void); diff --git a/pttbbs/mbbsd/bbs.c b/pttbbs/mbbsd/bbs.c index 31ee86ba..3518b17f 100644 --- a/pttbbs/mbbsd/bbs.c +++ b/pttbbs/mbbsd/bbs.c @@ -1501,17 +1501,9 @@ do_general(int garbage GCC_UNUSED) { genbuf[0] = 0; msg = err_uid; - } else { - // check friend / reject list - char name_fpath[PATHLEN]; - int i = 0; - sethomefile(name_fpath, quote_user, FN_REJECT); - i = file_exist_record(name_fpath, cuser.userid); - sethomefile(name_fpath, quote_user, FN_OVERRIDES); - if (i && !file_exist_record(name_fpath, cuser.userid)) { - genbuf[0] = 0; - msg = "作者拒收"; - } + } else if(is_rejected(quote_user)) { + genbuf[0] = 0; + msg = "作者拒收"; } } diff --git a/pttbbs/mbbsd/cal.c b/pttbbs/mbbsd/cal.c index 7076c743..0cf6472b 100644 --- a/pttbbs/mbbsd/cal.c +++ b/pttbbs/mbbsd/cal.c @@ -439,20 +439,11 @@ give_money_ui(const char *userid) } #endif // PLAY_ANGEL - { - char fpath[PATHLEN]; - int in_list; - - // check reject - sethomefile(fpath, id, FN_REJECT); - in_list = file_exist_record(fpath, cuser.userid); - sethomefile(fpath, id, FN_OVERRIDES); - if (in_list && !file_exist_record(fpath, cuser.userid)) { - move(13, 0); - outs(ANSI_COLOR(1;35) - "對方拒絕收信,完成交易後將不寄送紅包袋。" ANSI_RESET); - can_send_mail = 0; - } + if (is_rejected(id)) { + move(13, 0); + outs(ANSI_COLOR(1;35) + "對方拒絕收信,完成交易後將不寄送紅包袋。" ANSI_RESET); + can_send_mail = 0; } // safe context starts at (7, 0) diff --git a/pttbbs/mbbsd/friend.c b/pttbbs/mbbsd/friend.c index 948de5fb..386ffc14 100644 --- a/pttbbs/mbbsd/friend.c +++ b/pttbbs/mbbsd/friend.c @@ -93,6 +93,17 @@ friend_add(const char *uident, int type, const char* des) } } + +int +is_rejected(const char *userid) { + char fpath[PATHLEN]; + sethomefile(fpath, userid, FN_REJECT); + if (!file_exist_record(fpath, cuser.userid)) + return 0; + sethomefile(fpath, userid, FN_OVERRIDES); + return !file_exist_record(fpath, cuser.userid); +} + void friend_special(void) { diff --git a/pttbbs/mbbsd/mail.c b/pttbbs/mbbsd/mail.c index 6a56d1af..54ed9488 100644 --- a/pttbbs/mbbsd/mail.c +++ b/pttbbs/mbbsd/mail.c @@ -120,7 +120,6 @@ invalidaddr(const char *addr) { return 1; } - int load_mailalert(const char *userid) { @@ -364,16 +363,10 @@ do_innersend(const char *userid, char *mfpath, const char *title, char *newtitle fileheader_t mhdr; char fpath[PATHLEN]; char _mfpath[PATHLEN]; - int i = 0; int oldstat = currstat; char save_title[STRLEN]; - // check friend - sethomefile(fpath, userid, FN_REJECT); - i = file_exist_record(fpath, cuser.userid); - sethomefile(fpath, userid, FN_OVERRIDES); - if (i && !file_exist_record(fpath, cuser.userid)) { - // in reject list + if (is_rejected(userid)) { vmsg("對方拒收。"); return -2; } @@ -924,16 +917,10 @@ multi_list(struct Vector *namelist, int *recipient) cRemoved = 0; for (i = 0; i < Vector_length(namelist); i++) { const char *p = Vector_get(namelist, i); - if (searchuser(p, uid) && strcmp(STR_GUEST, uid)) { - // check rejected list - sethomefile(genbuf, uid, FN_REJECT); - if (!file_exist_record(genbuf, cuser.userid)) - continue; - // check if that's friend+reject - sethomefile(genbuf, uid, FN_OVERRIDES); - if (file_exist_record(genbuf, cuser.userid)) - continue; - } + if (searchuser(p, uid) && + strcmp(STR_GUEST, uid) && + !is_rejected(uid)) + continue; // ok, bad guys exist. if (!cRemoved) outs("下列 ID 無法收到信件,已自名單移除;" @@ -1364,8 +1351,6 @@ doforward(const char *direct, const fileheader_t * fh, int mode) // 處理站內黑名單 do { char xid[IDLEN+1], *dot; - char fpath[PATHLEN]; - int i = 0; strlcpy(xid, address, sizeof(xid)); dot = strchr(xid, '.'); @@ -1393,11 +1378,7 @@ doforward(const char *direct, const fileheader_t * fh, int mode) if (strcasecmp(xid, cuser.userid) == 0) break; - sethomefile(fpath, xid, FN_REJECT); - i = file_exist_record(fpath, cuser.userid); - sethomefile(fpath, xid, FN_OVERRIDES); - - if (i && !file_exist_record(fpath, cuser.userid)) { + if (is_rejected(xid)) { // We used to simply ignore here, and then people (especially those // in BuyTogether and similiars) say "my mail is lost". // After notifying SYSOPs, we believe it will be better to let all diff --git a/pttbbs/mbbsd/ordersong.c b/pttbbs/mbbsd/ordersong.c index 58ffde41..cb90bcc7 100644 --- a/pttbbs/mbbsd/ordersong.c +++ b/pttbbs/mbbsd/ordersong.c @@ -116,8 +116,16 @@ do_order_song(void) move(22, 0); clrtobot(); getdata_str(22, 0, "寄到誰的信箱(站內真實ID)?", address, sizeof(address), LCECHO, receiver); - if (!*address || searchuser(address, address)) + if (!*address) break; + if (searchuser(address, address)) { + if (is_rejected(address)) { + vmsg("對方拒收"); + continue; + } else { + break; + } + } vmsg("請輸入站內 ID 或直接 ENTER"); } while (1); diff --git a/pttbbs/mbbsd/vtuikit.c b/pttbbs/mbbsd/vtuikit.c index b116aa72..2820ee47 100644 --- a/pttbbs/mbbsd/vtuikit.c +++ b/pttbbs/mbbsd/vtuikit.c @@ -1008,6 +1008,7 @@ InputHistoryDelta(char *s, int sz, int d) // copy buffer strlcpy(s, ih.buf[ih.icurr], sz); + // TODO(piaip) serious check here, in case s contains invalid data. // DBCS safe i = strlen(s); |