检查点:保留账号分组隔离实现,继续权限复审

This commit is contained in:
xuans committed 2026-09-25 21:46:42 +08:00
1 parent 4084bc0682
commit 8ad62d8509
23 files changed
+811 -81

No files matched your search

+8 -1
View File
@@ -16,6 +16,7 @@ import (
"git.pcux.cn/xuans/Smail/db/migration"
"git.pcux.cn/xuans/Smail/models"
"git.pcux.cn/xuans/Smail/services/access"
"git.pcux.cn/xuans/Smail/services/accountgroup"
"git.pcux.cn/xuans/Smail/utils/logpolicy"
)
@@ -197,7 +198,13 @@ func (s *Store) Query(ctx context.Context, query Query) ([]Entry, error) {
if s.dialect == migration.DialectMySQL {
userTable, idType = "`user`", "CHAR"
}
statement += "actor_id IN (SELECT CAST(id AS " + idType + ") FROM " + userTable + " WHERE " + models.OrdinaryUserPredicate + ")"
actorID, parseErr := strconv.Atoi(query.ScopeActorID)
if parseErr != nil || actorID <= 0 {
return nil, ErrInvalid
}
groupScope, groupArgs := accountgroup.ScopePredicate(actorID)
statement += "actor_id IN (SELECT CAST(id AS " + idType + ") FROM " + userTable + " WHERE " + models.OrdinaryUserPredicate + " AND " + groupScope + ")"
args = append(args, groupArgs...)
// 代管视图还要核对操作发生时的角色,不能因账号降级暴露旧管理操作。
// 缺少历史角色的操作仅本人和超级管理员可见,收发信元数据不包含管理操作。
if isOperationKind(query.Kind) {