disabling marksbot when third-party verifications if turned off
This commit is contained in:
parent
2491088e81
commit
818c9a58a3
7 changed files with 158 additions and 1 deletions
|
|
@ -858,6 +858,19 @@ func (s *server) handleSetChannelAvatarAPI(w http.ResponseWriter, r *http.Reques
|
|||
writeCommandResultAPI(w, result, err)
|
||||
}
|
||||
|
||||
// filterOutBot drops the given bot id from a row slice in place, preserving
|
||||
// order. Used to keep a hidden built-in bot out of admin listings without
|
||||
// touching the underlying SQL projection.
|
||||
func filterOutBot(rows []BotRow, excludeID int64) []BotRow {
|
||||
out := rows[:0]
|
||||
for _, row := range rows {
|
||||
if row.ID != excludeID {
|
||||
out = append(out, row)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func (s *server) handleBotsAPI(w http.ResponseWriter, r *http.Request) {
|
||||
if s.read == nil {
|
||||
writeAPIError(w, http.StatusServiceUnavailable, "read store is not configured")
|
||||
|
|
@ -878,6 +891,12 @@ func (s *server) handleBotsAPI(w http.ResponseWriter, r *http.Request) {
|
|||
writeAPIError(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
// @marksbot is not fully finished (see requireThirdPartyVerificationVisible):
|
||||
// while third-party verification is hidden, it must not be discoverable in
|
||||
// the bot list either, not just unreachable at /api/botverification/*.
|
||||
if s.cfg.HideThirdPartyVerification {
|
||||
rows = filterOutBot(rows, domain.VerifierBotUserID)
|
||||
}
|
||||
nextBeforeID := int64(0)
|
||||
if hasMore && len(rows) > 0 {
|
||||
nextBeforeID = rows[len(rows)-1].ID
|
||||
|
|
@ -908,6 +927,10 @@ func (s *server) handleBotDetailAPI(w http.ResponseWriter, r *http.Request) {
|
|||
writeAPIError(w, http.StatusBadRequest, "invalid id")
|
||||
return
|
||||
}
|
||||
if s.cfg.HideThirdPartyVerification && botID == domain.VerifierBotUserID {
|
||||
writeAPIError(w, http.StatusNotFound, "bot not found")
|
||||
return
|
||||
}
|
||||
detail, err := s.read.BotDetail(r.Context(), botID)
|
||||
if err != nil {
|
||||
writeAPIError(w, http.StatusInternalServerError, err.Error())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue