fix channelType

This commit is contained in:
divyam234 2023-10-02 13:09:54 +05:30
parent e237f1422d
commit d4bc51d730
3 changed files with 12 additions and 8 deletions

View file

@ -31,7 +31,7 @@ func MapFileInToFile(file schemas.FileIn) models.File {
UserID: file.UserID,
ParentID: file.ParentID,
Parts: file.Parts,
ChannelID: file.ChannelID,
ChannelID: &file.ChannelID,
Status: file.Status,
}
}

View file

@ -35,7 +35,7 @@ type FileIn struct {
Type string `json:"type" mapstructure:"type,omitempty"`
Parts *models.Parts `json:"parts,omitempty" mapstructure:"parts,omitempty"`
MimeType string `json:"mimeType" mapstructure:"mime_type,omitempty"`
ChannelID *int64 `json:"channelId,omitempty" mapstructure:"channel_id,omitempty"`
ChannelID int64 `json:"channelId" mapstructure:"channel_id,omitempty"`
Path string `json:"path" mapstructure:"path,omitempty"`
Size int64 `json:"size" mapstructure:"size,omitempty"`
Starred *bool `json:"starred" mapstructure:"starred,omitempty"`

View file

@ -65,14 +65,18 @@ func (fs *FileService) CreateFile(c *gin.Context) (*schemas.FileOut, *types.AppE
fileIn.Depth = utils.IntPointer(len(strings.Split(fileIn.Path, "/")) - 1)
} else if fileIn.Type == "file" {
fileIn.Path = ""
channelId, err := GetDefaultChannel(c, userId)
if err != nil {
return nil, &types.AppError{Error: err, Code: http.StatusInternalServerError}
var channelId int64
var err error
if fileIn.ChannelID == 0 {
channelId, err = GetDefaultChannel(c, userId)
if err != nil {
return nil, &types.AppError{Error: err, Code: http.StatusInternalServerError}
}
} else {
channelId = fileIn.ChannelID
}
fileIn.ChannelID = &channelId
fileIn.ChannelID = channelId
}
fileIn.UserID = userId