fix: handle opaque attachment references
This commit is contained in:
+10
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user