needed save users that can view channel instead of checking
This commit is contained in:
+10
-5
@@ -20,7 +20,8 @@ var minClient *minio.Client
|
||||
type DataType uint8
|
||||
|
||||
const (
|
||||
File DataType = iota
|
||||
ConnectionFile DataType = iota
|
||||
HubChannelFile
|
||||
UserAvatar
|
||||
UserProfileBg
|
||||
)
|
||||
@@ -28,14 +29,16 @@ const (
|
||||
type DataTypePrefix string
|
||||
|
||||
const (
|
||||
FilePrefix DataTypePrefix = "upload/"
|
||||
UserAvatarPrefix DataTypePrefix = "userAvatar/"
|
||||
UserProfileBgPrefix DataTypePrefix = "userProfileBg/"
|
||||
ConnectionFilePrefix DataTypePrefix = "connection/"
|
||||
HubChannelFilePrefix DataTypePrefix = "hub/"
|
||||
UserAvatarPrefix DataTypePrefix = "userAvatar/"
|
||||
UserProfileBgPrefix DataTypePrefix = "userProfileBg/"
|
||||
)
|
||||
|
||||
type GetKeyOptions struct {
|
||||
UserId uuid.UUID
|
||||
ConnectionId uuid.UUID
|
||||
ChannelId uuid.UUID
|
||||
MimeType string
|
||||
UploadType DataType
|
||||
}
|
||||
@@ -49,12 +52,14 @@ func GetKey(opts GetKeyOptions) string {
|
||||
key := "/" + strconv.FormatInt(time.Now().UnixMilli(), 10) + extensions[0]
|
||||
|
||||
switch opts.UploadType {
|
||||
case HubChannelFile:
|
||||
return string(HubChannelFilePrefix) + opts.ChannelId.String() + key
|
||||
case UserAvatar:
|
||||
return string(UserAvatarPrefix) + opts.UserId.String() + key
|
||||
case UserProfileBg:
|
||||
return string(UserProfileBgPrefix) + opts.UserId.String() + key
|
||||
default:
|
||||
return string(FilePrefix) + opts.ConnectionId.String() + key
|
||||
return string(ConnectionFilePrefix) + opts.ConnectionId.String() + key
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user