1
0
mirror of https://github.com/mattermost/focalboard.git synced 2024-11-24 08:22:29 +02:00

Fix import

This commit is contained in:
Miguel de la Cruz 2022-12-20 19:47:46 +01:00
parent ca52343fcb
commit c6a0e9cd19
3 changed files with 5 additions and 20 deletions

View File

@ -10,7 +10,6 @@ import (
"github.com/mattermost/focalboard/mattermost-plugin/server/boards"
"github.com/mattermost/focalboard/server/model"
"github.com/mattermost/mattermost-server/v6/app"
"github.com/mattermost/mattermost-server/v6/einterfaces"
mm_model "github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/plugin"

View File

@ -72,7 +72,11 @@ func (a *App) GetFileInfo(filename string) (*mmModel.FileInfo, error) {
return nil, errEmptyFilename
}
fileInfoID := utils.GetFileInfoFromFilename(filename)
// filename is in the format 7<some-alphanumeric-string>.<extension>
// we want to extract the <some-alphanumeric-string> part of this as this
// will be the fileinfo id.
parts := strings.Split(filename, ".")
fileInfoID := parts[0][1:]
fileInfo, err := a.store.GetFileInfo(fileInfoID)
if err != nil {
return nil, err

View File

@ -3,7 +3,6 @@ package utils
import (
"encoding/json"
"reflect"
"strings"
"time"
mmModel "github.com/mattermost/mattermost-server/v6/model"
@ -103,20 +102,3 @@ func IsCloudLicense(license *mmModel.License) bool {
license.Features.Cloud != nil &&
*license.Features.Cloud
}
// GetFileInfoFromFilename strips the initial 7 from the filename as
// it is in the format 7<some-alphanumeric-string>.<extension>,
// extracting the <some-alphanumeric-string> which corresponds to the
// fileinfo id.
func GetFileInfoFromFilename(filename string) string {
if !strings.HasPrefix(filename, "7") {
return filename
}
parts := strings.Split(filename, ".")
if len(parts) != 2 {
return filename
}
return parts[0][1:]
}