Try   HackMD

PTT 新版本開發:看板權限驗證

維護人 提莫
tags: Ptt App
位置: 主目錄/20240811func

名詞解釋、定義

  • 站長: 擁有 PERM_SYSP 的使用者帳號,以這個定義而言 視覺站長 不一定是站長。
  • 版務版:
  • 版主: ID 存在於某個 BBS 看板版主列表的使用者,要注意版主 ID 總和長度是有固定的。參考資料
  • 版友: ID 存在於某個 BBS 看板中的板友清單的使用者。此處的板友和 fandom 鄉民百科上的板友定義不同
  • 18 歲:註冊時填寫的生日距離目前滿18年零天

功能驗證

整理看板權限規則、對應的程式碼與測試。

板主權限:

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

看板可讀權限

  1. 如果有「站長(PERM_SYSOP)」權限: 可以進入看板。
  2. 版務(BM)板:如果有「看板警察(PERM_POLICE)」或是「待查(PERM_POLICE_MAN)」權限,可以進入看板。
  3. 如果是此板板主:可以進入看板。
  4. 系統公告板(看板無 post 的功能,單純系統文章刊載,例如 ALLPOST):任何帳號皆可以進入看板。
  5. 如果是隱板
    1. 如果是板友(可見會員名單):可以進入看板。
    2. 其他:不能進入看板,板名變成"本看板為隱藏看板"。
  6. 權限板:如果板有限定權限,且使用者沒有對應權限:不可以進入看板。(okcool:看板可讀權限,到看板設定>設定讀寫權限(y)>共有32種權限可以選)一般使用者可以看得見板標,但進不去。(例如:PTT20_Selfie)
  7. 如果是 18 禁的看板,使用者未滿 18 歲:不可以進入看板。
  8. 其他:可以進入看板。

測試程式碼

  1. 執行測試之處:https://github.com/Ptt-official-app/go-pttbbs/blob/ca7f78907efe173873e2f117fae78e45cf902f33/ptt/board_test.go#L30-L39
  2. 詳列測試案例:https://github.com/Ptt-official-app/go-pttbbs/blob/main/ptt/testcases_test.go

帳號權限列表

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

pttbbs 列出之帳號權限列表:
https://github.com/ptt/pttbbs/blob/master/include/perm.h

go-pttbbs 列出之帳號權限列表:
https://github.com/Ptt-official-app/go-pttbbs/blob/main/ptttype/perm.go

由 Teemo 盤點出目前重要之帳號權限列表:

  • PERM_BBSADM BBSADM
  • PERM_SYSOP 站長
  • PERM_ACCOUNTS 帳號總管
  • PERM_CHATROOM 聊天室總管
  • PERM_BOARD 看板總管
  • PERM_PRG 程式組
  • PERM_VIEWSYSOP 視覺站長
  • PERM_POLICE_MAN 警察總管
  • PERM_SYSSUPERSUBOP 群組長
  • PERM_ACCTREG 帳號審核組
  • PERM_POLICE 警察
  • PERM_SYSSUBOP 小組長
  • ROLE_ANGEL_CIA (天使)品管帳號(CIA)
  • ROLE_ANGEL_ACTIVITY (天使)活動用帳號
  • ROLE_POLICE_ANONYMOUS (警察)匿名警察

  1. 如果是隱板:
    2. 如果板是不能 post 的 (站裡特殊看板,譬如 ALLPOST): 可以進入看板 (return 2)

go-pttbbs 的 code: https://github.com/Ptt-official-app/go-pttbbs/blob/main/ptt/board.go#L46
測試:https://github.com/Ptt-official-app/go-pttbbs/blob/main/ptt/board_test.go

原本 c-pttbbs 的 code: https://github.com/ptt/pttbbs/blob/master/mbbsd/board.c#L76

https://github.com/ptt/pttbbs/blob/master/mbbsd/board.c#L185

https://github.com/ptt/pttbbs/blob/master/mbbsd/board.c#L145