feat: 后台增加开放消息开关

关闭后前台隐藏私聊/群聊入口并由后端拦截;同步去掉公告页重复计数胶囊。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-17 04:16:10 +08:00
parent 9a55c2f6f2
commit 4b93739468
18 changed files with 275 additions and 91 deletions

View File

@@ -179,25 +179,28 @@ func Setup(cfg *config.Config) (*gin.Engine, error) {
api.GET("/my/media", h.MyMedia)
api.DELETE("/my/attachments/:id", h.DeleteAttachment)
// 群聊(二期):建群/成员/消息/未读
api.GET("/chat/rooms", h.ListChatRooms)
api.POST("/chat/rooms", h.CreateChatRoom)
api.POST("/chat/direct", h.OpenDirectChat)
api.GET("/chat/users", h.SearchChatUsers)
api.GET("/chat/rooms/:id", h.GetChatRoom)
api.PUT("/chat/rooms/:id", h.UpdateChatRoom)
api.PUT("/chat/rooms/:id/pin", h.PinChatRoom)
api.DELETE("/chat/rooms/:id", h.DissolveChatRoom)
api.POST("/chat/rooms/:id/join", h.JoinChatRoom)
api.POST("/chat/rooms/:id/leave", h.LeaveChatRoom)
api.GET("/chat/rooms/:id/members", h.ListChatMembers)
api.POST("/chat/rooms/:id/members", h.InviteChatMembers)
api.DELETE("/chat/rooms/:id/members/:uid", h.KickChatMember)
api.GET("/chat/rooms/:id/messages", h.ListChatMessages)
api.POST("/chat/rooms/:id/messages", middleware.RateLimitMiddleware(limiter, service.RateChat), h.SendChatMessage)
api.DELETE("/chat/rooms/:id/messages/:mid", h.RecallChatMessage)
api.PUT("/chat/rooms/:id/read", h.MarkChatRead)
api.GET("/chat/unread-summary", h.ChatUnreadSummary)
// 群聊(二期):建群/成员/消息/未读;全站关闭消息时前台一律 403
chatAPI := api.Group("/chat", h.RequireMessagesOpen)
{
chatAPI.GET("/rooms", h.ListChatRooms)
chatAPI.POST("/rooms", h.CreateChatRoom)
chatAPI.POST("/direct", h.OpenDirectChat)
chatAPI.GET("/users", h.SearchChatUsers)
chatAPI.GET("/rooms/:id", h.GetChatRoom)
chatAPI.PUT("/rooms/:id", h.UpdateChatRoom)
chatAPI.PUT("/rooms/:id/pin", h.PinChatRoom)
chatAPI.DELETE("/rooms/:id", h.DissolveChatRoom)
chatAPI.POST("/rooms/:id/join", h.JoinChatRoom)
chatAPI.POST("/rooms/:id/leave", h.LeaveChatRoom)
chatAPI.GET("/rooms/:id/members", h.ListChatMembers)
chatAPI.POST("/rooms/:id/members", h.InviteChatMembers)
chatAPI.DELETE("/rooms/:id/members/:uid", h.KickChatMember)
chatAPI.GET("/rooms/:id/messages", h.ListChatMessages)
chatAPI.POST("/rooms/:id/messages", middleware.RateLimitMiddleware(limiter, service.RateChat), h.SendChatMessage)
chatAPI.DELETE("/rooms/:id/messages/:mid", h.RecallChatMessage)
chatAPI.PUT("/rooms/:id/read", h.MarkChatRead)
chatAPI.GET("/unread-summary", h.ChatUnreadSummary)
}
}
// 管理后台 API:RequireStaff 基础鉴权(板块管理员及以上,Actor 实时从 DB 现取),