diff --git a/include/proto.h b/include/proto.h index 2a56c5d94..b2ccb6847 100644 --- a/include/proto.h +++ b/include/proto.h @@ -101,6 +101,7 @@ void log_crosspost_in_allpost(const char *brd, const fileheader_t *postfile); #ifdef USE_COOLDOWN int check_cooldown(boardheader_t *bp); #endif +bool is_user_sms_verified(); /* board */ #define setutmpbid(bid) currutmp->brc_id=bid; diff --git a/include/pttstruct.h b/include/pttstruct.h index 38f2047a0..6ed092d1d 100644 --- a/include/pttstruct.h +++ b/include/pttstruct.h @@ -232,6 +232,7 @@ typedef struct boardheader_t { /* 256 bytes */ #define BRD_ALIGNEDCMT 0x04000000 /* 對齊式的推文 */ #define BRD_NOSELFDELPOST 0x08000000 /* 不可自刪 */ #define BRD_BM_MASK_CONTENT 0x10000000 /* 允許板主刪除特定文字 */ +#define BRD_NEEDS_SMS_VERIFICATION 0x20000000 /* 允許版主設定看板發文需完成過簡訊認證 */ // Board group linked-list type. Used for array index of firstchild and next. #define BRD_GROUP_LL_TYPE_NAME (0) diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index 481635e0a..58074587a 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -433,6 +433,38 @@ int IsFreeBoardName(const char *brdname) return 0; } +/* + * Check if user phone number is verified by sms + * + * This function will check is current user have already register their + * phone number with verifydb library. + * The verify process is modified from verifydb_check_vmethod_unused, + * it will pass cuser.userid and cuser.firstlogin as parameter and find + * VMETHOD_SMS record. + * + * Note that, ptt system might has two different user has the same userid + * but won't be happen in same time, so we need firstlogin as second + * parameter, and ptt accept Taiwan phone register only since Jul. 2021 + * so we can just verify whether in database. + * + * Return true when user has verified phone, false when no register record + */ +bool +is_user_sms_verified() +{ + Bytes buf; + const VerifyDb::GetReply *reply; + if (!verifydb_getuser(cuser.userid, cuser.firstlogin, &buf, &reply)) { + // The verifydb may occur some problem, maybe we should log it and + // notifiy SYSOP? + return false; + } + if (verifydb_find_vmethod(reply, VMETHOD_SMS)) { + return true; + } + return false; +} + int CheckModifyPerm(const char **preason) { diff --git a/mbbsd/board.c b/mbbsd/board.c index c84b0d2f0..5c1b7a1ff 100644 --- a/mbbsd/board.c +++ b/mbbsd/board.c @@ -496,6 +496,11 @@ b_config(void) (bp->brdattr & BRD_OVER18) ? ANSI_COLOR(1) "禁止 " : "允許\ " ); + prints( " " ANSI_COLOR(1;36) "t" ANSI_RESET + " - %s" ANSI_RESET "已驗證台灣門號發/推文\n", + (bp->brdattr & BRD_TAIWAN_PHONE_ONLY) ? + ANSI_COLOR(1) "限定 " : "不限定 " ); + if (!canpost) outs(ANSI_COLOR(1;31)" ★ 您在此看板無發文或推文權限," "詳細原因請參考上面顯示為紅色或有 * 的項目。"ANSI_RESET"\n"); @@ -813,6 +818,11 @@ b_config(void) } break; + case 't': + bp->brdattr ^= BRD_NEEDS_SMS_VERIFICATION; + touched = 1; + break; + case 'v': clear(); friend_edit(BOARD_VISABLE); diff --git a/mbbsd/cache.c b/mbbsd/cache.c index a82146913..99e98685c 100644 --- a/mbbsd/cache.c +++ b/mbbsd/cache.c @@ -233,6 +233,10 @@ postperm_msg(const char *bname) assert(0<=i-1 && i-1brdattr & BRD_TAIWAN_PHONE_ONLY) + if (!is_user_sms_verified()) + return "看板限定已驗證台灣門號發/推文"; + if (bp->brdattr & BRD_GUESTPOST) return NULL;