fix: handle opaque attachment references

This commit is contained in:
richjohnrambo
2026-09-30 10:50:42 +08:00
parent 9f30995787
commit 06e08a65e4
4 changed files with 88 additions and 14 deletions
+10 -2
View File
@@ -4684,8 +4684,8 @@ func (fileMapper) LinkAttachments(tenantID types.TenantID, topic string, msgId t
return err
}
userId := types.ZeroUid
if topic != "" && types.GetTopicCat(topic) == types.TopicCatMe {
userId = types.ParseUserId(topic)
if parsedUserID, ok := fileLinkUserID(topic); ok {
userId = parsedUserID
topic = ""
}
return tenantAdp.TenantFileLinkAttachments(tenantID, topic, userId, msgId, fids)
@@ -4693,6 +4693,14 @@ func (fileMapper) LinkAttachments(tenantID types.TenantID, topic string, msgId t
return nil
}
// File link topics may also be opaque retention keys, such as cultivate's cvp prefix.
func fileLinkUserID(topic string) (types.Uid, bool) {
if !strings.HasPrefix(topic, "usr") {
return types.ZeroUid, false
}
return types.ParseUserId(topic), true
}
func (fileMapper) UserHasAccess(tenantID types.TenantID, fid string, uid types.Uid) (bool, error) {
if fid == "" || uid.IsZero() {
return false, types.ErrMalformed