feat: 实时消息与管理端运营能力

新增群聊/私信与公共 WebSocket 总线,站长用户内容档案,并将通知与待审角标改为推送驱动;同步精简管理仪表盘并修复主题换肤 DOM 冲突。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-15 22:58:16 +08:00
parent 29db9ae9b5
commit 42c395a864
55 changed files with 7607 additions and 346 deletions

View File

@@ -2,12 +2,16 @@ package handler
import (
"github.com/freefire/jiang13-bbs/config"
"github.com/freefire/jiang13-bbs/model"
"github.com/freefire/jiang13-bbs/realtime"
"github.com/freefire/jiang13-bbs/service"
"github.com/gin-gonic/gin"
)
// Handlers 聚合所有服务引用
type Handlers struct {
Cfg *config.Config
Hub *realtime.Hub
Auth *service.AuthService
Board *service.BoardService
Post *service.PostService
@@ -21,4 +25,46 @@ type Handlers struct {
Setting *service.SettingService
AdminUser *service.AdminUserService
Moderation *service.ModerationService
Chat *service.ChatService
}
// broadcastFeedChanged 帖子流有公开发布内容时全员广播(三期)
func (h *Handlers) broadcastFeedChanged(kind string, postID, boardID, actorID uint) {
if h.Hub == nil {
return
}
h.Hub.BroadcastAll(realtime.Envelope{
Type: realtime.EventFeedChanged,
Data: gin.H{
"kind": kind,
"post_id": postID,
"board_id": boardID,
"actor_id": actorID,
},
})
}
// notifyPendingReview 待审内容通知该板可审者(WS 红点由 Notification.OnNotifyNew 统一推送)
func (h *Handlers) notifyPendingReview(boardID, actorID, postID, commentID uint, preview string) {
ids, err := h.Auth.ListBoardModeratorIDs(boardID)
if err != nil || len(ids) == 0 {
return
}
for _, uid := range ids {
if uid == actorID {
continue
}
h.Notification.Create(uid, actorID, model.NotificationTypePendingReview, postID, commentID, preview)
}
h.broadcastModerationChanged()
}
// broadcastModerationChanged 通知管理团队待审队列有变化(角标由客户端按权限再拉一次)
func (h *Handlers) broadcastModerationChanged() {
if h.Hub == nil {
return
}
h.Hub.BroadcastRoom(realtime.RoomStaff, realtime.Envelope{
Type: realtime.EventModerationChanged,
})
}