Reducing the filestore dependencies from the rest of the source code (#16816)
* Reducing the filestore dependencies from the rest of the source code * Making more generic config conversion to FileBackendSettings * Fixing usage of the NewFileBackend function * Fixing more usages of the NewFileBackend function * Fix some linter errors * Fix more linter errors * Fixing some unit tests * Fixing linter problem * Addressing PR review comments * Simplifing the CopyFile for tests Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
a246104d04
Коммит
a3de71fba4
@@ -21,6 +21,7 @@ import (
|
||||
"github.com/mattermost/ldap"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/mlog"
|
||||
"github.com/mattermost/mattermost-server/v5/services/filesstore"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -1452,6 +1453,28 @@ func (s *FileSettings) SetDefaults(isUpdate bool) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *FileSettings) ToFileBackendSettings(enableComplianceFeature bool) filesstore.FileBackendSettings {
|
||||
if *s.DriverName == IMAGE_DRIVER_LOCAL {
|
||||
return filesstore.FileBackendSettings{
|
||||
DriverName: *s.DriverName,
|
||||
Directory: *s.Directory,
|
||||
}
|
||||
}
|
||||
return filesstore.FileBackendSettings{
|
||||
DriverName: *s.DriverName,
|
||||
AmazonS3AccessKeyId: *s.AmazonS3AccessKeyId,
|
||||
AmazonS3SecretAccessKey: *s.AmazonS3SecretAccessKey,
|
||||
AmazonS3Bucket: *s.AmazonS3Bucket,
|
||||
AmazonS3PathPrefix: *s.AmazonS3PathPrefix,
|
||||
AmazonS3Region: *s.AmazonS3Region,
|
||||
AmazonS3Endpoint: *s.AmazonS3Endpoint,
|
||||
AmazonS3SSL: s.AmazonS3SSL == nil || *s.AmazonS3SSL,
|
||||
AmazonS3SignV2: s.AmazonS3SignV2 != nil && *s.AmazonS3SignV2,
|
||||
AmazonS3SSE: s.AmazonS3SSE != nil && *s.AmazonS3SSE && enableComplianceFeature,
|
||||
AmazonS3Trace: s.AmazonS3Trace != nil && *s.AmazonS3Trace,
|
||||
}
|
||||
}
|
||||
|
||||
type EmailSettings struct {
|
||||
EnableSignUpWithEmail *bool `access:"authentication"`
|
||||
EnableSignInWithEmail *bool `access:"authentication"`
|
||||
|
||||
@@ -12,11 +12,6 @@ const (
|
||||
MaxImageSize = int64(6048 * 4032) // 24 megapixels, roughly 36MB as a raw image
|
||||
)
|
||||
|
||||
var (
|
||||
IMAGE_EXTENSIONS = [7]string{".jpg", ".jpeg", ".gif", ".bmp", ".png", ".tiff", "tif"}
|
||||
IMAGE_MIME_TYPES = map[string]string{".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".gif": "image/gif", ".bmp": "image/bmp", ".png": "image/png", ".tiff": "image/tiff", ".tif": "image/tif"}
|
||||
)
|
||||
|
||||
type FileUploadResponse struct {
|
||||
FileInfos []*FileInfo `json:"file_infos"`
|
||||
ClientIds []string `json:"client_ids"`
|
||||
|
||||
@@ -484,24 +484,6 @@ func ParseHashtags(text string) (string, string) {
|
||||
return strings.TrimSpace(hashtagString), strings.TrimSpace(plainString)
|
||||
}
|
||||
|
||||
func IsFileExtImage(ext string) bool {
|
||||
ext = strings.ToLower(ext)
|
||||
for _, imgExt := range IMAGE_EXTENSIONS {
|
||||
if ext == imgExt {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func GetImageMimeType(ext string) string {
|
||||
ext = strings.ToLower(ext)
|
||||
if IMAGE_MIME_TYPES[ext] == "" {
|
||||
return "image"
|
||||
}
|
||||
return IMAGE_MIME_TYPES[ext]
|
||||
}
|
||||
|
||||
func ClearMentionTags(post string) string {
|
||||
post = strings.Replace(post, "<mention>", "", -1)
|
||||
post = strings.Replace(post, "</mention>", "", -1)
|
||||
|
||||
Ссылка в новой задаче
Block a user