mirror of
https://github.com/42wim/matterbridge.git
synced 2024-12-18 09:02:39 +01:00
This commit is contained in:
parent
0b9bc18236
commit
727fa9f929
@ -291,7 +291,8 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, channel string, fi *conf
|
|||||||
content := bytes.NewReader(*fi.Data)
|
content := bytes.NewReader(*fi.Data)
|
||||||
sp := strings.Split(fi.Name, ".")
|
sp := strings.Split(fi.Name, ".")
|
||||||
mtype := mime.TypeByExtension("." + sp[len(sp)-1])
|
mtype := mime.TypeByExtension("." + sp[len(sp)-1])
|
||||||
if !strings.Contains(mtype, "image") && !strings.Contains(mtype, "video") {
|
if !(strings.Contains(mtype, "image") || strings.Contains(mtype, "video") ||
|
||||||
|
strings.Contains(mtype, "application") || strings.Contains(mtype, "audio")) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if fi.Comment != "" {
|
if fi.Comment != "" {
|
||||||
@ -326,6 +327,18 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, channel string, fi *conf
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
b.Log.Errorf("sendImage failed: %#v", err)
|
b.Log.Errorf("sendImage failed: %#v", err)
|
||||||
}
|
}
|
||||||
|
case strings.Contains(mtype, "application"):
|
||||||
|
b.Log.Debugf("sendFile %s", res.ContentURI)
|
||||||
|
_, err = b.mc.SendFile(channel, fi.Name, res.ContentURI, mtype, uint(len(*fi.Data)))
|
||||||
|
if err != nil {
|
||||||
|
b.Log.Errorf("sendFile failed: %#v", err)
|
||||||
|
}
|
||||||
|
case strings.Contains(mtype, "audio"):
|
||||||
|
b.Log.Debugf("sendAudio %s", res.ContentURI)
|
||||||
|
_, err = b.mc.SendAudio(channel, fi.Name, res.ContentURI, mtype, uint(len(*fi.Data)))
|
||||||
|
if err != nil {
|
||||||
|
b.Log.Errorf("sendAudio failed: %#v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
b.Log.Debugf("result: %#v", res)
|
b.Log.Debugf("result: %#v", res)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user