mirror of
https://github.com/mattermost/focalboard.git
synced 2024-12-24 13:43:12 +02:00
Fix MM-40428 (#1926)
This commit is contained in:
parent
87daacceca
commit
199da41f6d
@ -1,6 +1,8 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/mattermost/focalboard/server/model"
|
||||
"github.com/mattermost/focalboard/server/services/notify"
|
||||
"github.com/mattermost/focalboard/server/services/store"
|
||||
@ -124,6 +126,20 @@ func (a *App) DeleteBlock(c store.Container, blockID string, modifiedBy string)
|
||||
return err
|
||||
}
|
||||
|
||||
if block.Type == model.TypeImage {
|
||||
fileName, fileIDExists := block.Fields["fileId"]
|
||||
if fileName, fileIDIsString := fileName.(string); fileIDExists && fileIDIsString {
|
||||
filePath := filepath.Join(block.WorkspaceID, block.RootID, fileName)
|
||||
err = a.filesBackend.RemoveFile(filePath)
|
||||
|
||||
if err != nil {
|
||||
a.logger.Error("Error deleting image file",
|
||||
mlog.String("FilePath", filePath),
|
||||
mlog.Err(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
a.wsAdapter.BroadcastBlockDelete(c.WorkspaceID, blockID, block.ParentID)
|
||||
a.metrics.IncrementBlocksDeleted(1)
|
||||
go func() {
|
||||
|
@ -20,6 +20,7 @@ const (
|
||||
TypeView = "view"
|
||||
TypeText = "text"
|
||||
TypeComment = "comment"
|
||||
TypeImage = "image"
|
||||
)
|
||||
|
||||
func (bt BlockType) String() string {
|
||||
@ -39,6 +40,8 @@ func BlockTypeFromString(s string) (BlockType, error) {
|
||||
return TypeText, nil
|
||||
case "comment":
|
||||
return TypeComment, nil
|
||||
case "image":
|
||||
return TypeImage, nil
|
||||
}
|
||||
return TypeUnknown, ErrInvalidBlockType{s}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user