feat(live): 按用户名禁言、后台右侧管控栏、前台抖音式布局与禁言 Toast
Made-with: Cursor
This commit is contained in:
@@ -62,8 +62,10 @@ func handleDanmakuWS(c *gin.Context) {
|
||||
claims, tokenOK := handlers.ParseSiteClaims(c.Query("token"))
|
||||
canSend := tokenOK
|
||||
fromDisplay := "***"
|
||||
fullUsername := ""
|
||||
if tokenOK && claims != nil {
|
||||
fromDisplay = handlers.MaskSiteUsernameForDanmaku(claims.Username)
|
||||
fullUsername = strings.TrimSpace(claims.Username)
|
||||
}
|
||||
|
||||
ws, err := upgrader.Upgrade(c.Writer, c.Request, nil)
|
||||
@@ -72,7 +74,7 @@ func handleDanmakuWS(c *gin.Context) {
|
||||
}
|
||||
ws.SetReadLimit(4096)
|
||||
clientIP := c.ClientIP()
|
||||
sessionID := RegisterOnlineSession("danmaku", clientIP, fromDisplay)
|
||||
sessionID := RegisterOnlineSession("danmaku", clientIP, fullUsername)
|
||||
|
||||
danmakuClientsMu.Lock()
|
||||
danmakuClients[ws] = clientIP
|
||||
@@ -95,11 +97,11 @@ func handleDanmakuWS(c *gin.Context) {
|
||||
continue
|
||||
}
|
||||
TouchOnlineSession(sessionID)
|
||||
if IsMutedForIP(clientIP) {
|
||||
if IsMutedForSend(clientIP, fullUsername) {
|
||||
_ = writeDanmakuJSON(ws, map[string]interface{}{
|
||||
"type": "error",
|
||||
"code": "muted",
|
||||
"message": "当前已被禁言",
|
||||
"message": "您已被禁言,暂时无法发弹幕或送礼物",
|
||||
})
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user