fix bug
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
|||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"github.com/labstack/echo/v4/middleware"
|
"github.com/labstack/echo/v4/middleware"
|
||||||
ring "github.com/zfjagann/golang-ring"
|
ring "github.com/zfjagann/golang-ring"
|
||||||
|
"github.com/mitchellh/mapstructure"
|
||||||
)
|
)
|
||||||
|
|
||||||
type API struct {
|
type API struct {
|
||||||
@@ -137,6 +138,11 @@ func (b *API) handlePostMessage(c echo.Context) error {
|
|||||||
message.Account = b.Account
|
message.Account = b.Account
|
||||||
message.ID = ""
|
message.ID = ""
|
||||||
message.Timestamp = time.Now()
|
message.Timestamp = time.Now()
|
||||||
|
for i, f := range message.Extra["file"] {
|
||||||
|
fi := config.FileInfo{}
|
||||||
|
mapstructure.Decode(f.(map[string]interface{}), &fi)
|
||||||
|
message.Extra["file"][i] = fi
|
||||||
|
}
|
||||||
b.Log.Debugf("Sending message from %s on %s to gateway", message.Username, "api")
|
b.Log.Debugf("Sending message from %s on %s to gateway", message.Username, "api")
|
||||||
b.Remote <- message
|
b.Remote <- message
|
||||||
return c.JSON(http.StatusOK, message)
|
return c.JSON(http.StatusOK, message)
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import (
|
|||||||
"github.com/42wim/matterbridge/bridge"
|
"github.com/42wim/matterbridge/bridge"
|
||||||
"github.com/42wim/matterbridge/bridge/config"
|
"github.com/42wim/matterbridge/bridge/config"
|
||||||
"github.com/42wim/matterbridge/gateway/bridgemap"
|
"github.com/42wim/matterbridge/gateway/bridgemap"
|
||||||
"github.com/mitchellh/mapstructure"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// handleEventFailure handles failures and reconnects bridges.
|
// handleEventFailure handles failures and reconnects bridges.
|
||||||
@@ -85,11 +84,7 @@ func (gw *Gateway) handleFiles(msg *config.Message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i, f := range msg.Extra["file"] {
|
for i, f := range msg.Extra["file"] {
|
||||||
fi, ok := f.(config.FileInfo)
|
fi := f.(config.FileInfo)
|
||||||
if !ok {
|
|
||||||
fi = config.FileInfo{}
|
|
||||||
mapstructure.Decode(f.(map[string]interface{}), &fi)
|
|
||||||
}
|
|
||||||
ext := filepath.Ext(fi.Name)
|
ext := filepath.Ext(fi.Name)
|
||||||
fi.Name = fi.Name[0 : len(fi.Name)-len(ext)]
|
fi.Name = fi.Name[0 : len(fi.Name)-len(ext)]
|
||||||
fi.Name = reg.ReplaceAllString(fi.Name, "_")
|
fi.Name = reg.ReplaceAllString(fi.Name, "_")
|
||||||
|
|||||||
Reference in New Issue
Block a user