feat: 帖子分级置顶(板块/全站)与板块管理员置顶权限、消息管理权限调整
This commit is contained in:
@@ -42,11 +42,6 @@ var (
|
||||
ErrChatAdminAccess = errors.New("无权管理消息")
|
||||
)
|
||||
|
||||
// CanOverseeChat 站长/超管可旁路查看全部群(含私聊)并撤回任意消息
|
||||
func CanOverseeChat(role model.Role) bool {
|
||||
return role == model.RoleOwner || role == model.RoleSuperAdmin
|
||||
}
|
||||
|
||||
const (
|
||||
chatNameMinRune = 2
|
||||
chatNameMaxRune = 32
|
||||
@@ -929,7 +924,7 @@ func (s *ChatService) isChatRoomModerator(userID, roomID uint) bool {
|
||||
return m.Role == model.ChatRoleOwner || m.Role == model.ChatRoleAdmin
|
||||
}
|
||||
|
||||
// hasSiteGroupMessagePerm 站点消息管理 flag(不含超管/站长,调用方通常已判 oversee)
|
||||
// hasSiteGroupMessagePerm 站点消息管理 flag(不含站长,超管经 oversee 已放行;调用方通常已判 oversee)
|
||||
func (s *ChatService) hasSiteGroupMessagePerm(userID uint) bool {
|
||||
var u model.User
|
||||
if err := s.db.Select("can_manage_messages").First(&u, userID).Error; err != nil {
|
||||
@@ -1219,7 +1214,7 @@ type AdminChatMessageItem struct {
|
||||
}
|
||||
|
||||
// AdminListMessages 按房间类型分页;scope 限制可见房间;非全站监管脱敏已撤回正文。
|
||||
// actor 为站长/超管:全站;HasSiteMessagePerm:全部群聊(无私聊);否则仅群管房间。
|
||||
// actor 为站长或已授权超管:全站;HasSiteMessagePerm:全部群聊(无私聊);否则仅群管房间。
|
||||
func (s *ChatService) AdminListMessages(actor *Actor, page int, keyword, roomType string) ([]AdminChatMessageItem, int64, error) {
|
||||
if actor == nil || !s.CanAccessAdminMessages(actor) {
|
||||
return nil, 0, ErrChatAdminAccess
|
||||
@@ -1227,7 +1222,7 @@ func (s *ChatService) AdminListMessages(actor *Actor, page int, keyword, roomTyp
|
||||
if page < 1 {
|
||||
page = 1
|
||||
}
|
||||
fullOversee := CanOverseeChat(actor.Role)
|
||||
fullOversee := actor.CanOverseeChat()
|
||||
siteGroup := actor.HasSiteMessagePerm() && !fullOversee
|
||||
if roomType != model.ChatRoomTypeGroup && roomType != model.ChatRoomTypeDirect {
|
||||
return nil, 0, errors.New("房间类型无效")
|
||||
|
||||
Reference in New Issue
Block a user