[TASK] add support to receive audio from threema
This commit is contained in:
parent
b9bf07389c
commit
c21927e4d5
|
@ -44,6 +44,24 @@ func (a *Account) receiving(receivedMessage o3.ReceivedMsg) (xmpp.Packet, error)
|
|||
requestExtensions(&xMSG)
|
||||
return xMSG, nil
|
||||
|
||||
case o3.AudioMessage:
|
||||
if a.threema.httpUploadPath == "" {
|
||||
return nil, errors.New("no place to store files at transport configurated")
|
||||
}
|
||||
data, err := msg.GetAudioData(a.Session)
|
||||
if err != nil {
|
||||
log.Warnf("unable to read data from message: %s", err)
|
||||
return nil, err
|
||||
}
|
||||
xMSG, err := a.FileToXMPP(msg.Sender().String(), msg.ID(), "mp3", data)
|
||||
if err != nil {
|
||||
log.Warnf("unable to create data from message: %s", err)
|
||||
return nil, err
|
||||
}
|
||||
xMSG.Type = "chat"
|
||||
requestExtensions(&xMSG)
|
||||
return xMSG, nil
|
||||
|
||||
case o3.ImageMessage:
|
||||
if a.threema.httpUploadPath == "" {
|
||||
return nil, errors.New("no place to store files at transport configurated")
|
||||
|
|
|
@ -69,6 +69,32 @@ func TestReceiveText(t *testing.T) {
|
|||
assert.Equal("Oojoh0Ah", xMSG.Body)
|
||||
}
|
||||
|
||||
func TestReceiveAudio(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
a := createDummyAccount()
|
||||
a.threema = &Threema{}
|
||||
|
||||
/* receiving image
|
||||
session := o3.SessionContext{
|
||||
ID: o3.ThreemaID{
|
||||
ID: o3.NewIDString("12345678"),
|
||||
Nick: o3.NewPubNick("user"),
|
||||
},
|
||||
}*/
|
||||
dataMsg := o3.AudioMessage{}
|
||||
_, err := a.receiving(o3.ReceivedMsg{
|
||||
Msg: dataMsg,
|
||||
})
|
||||
assert.Error(err)
|
||||
|
||||
a.threema.httpUploadPath = "/tmp"
|
||||
dataMsg = o3.AudioMessage{}
|
||||
_, err = a.receiving(o3.ReceivedMsg{
|
||||
Msg: dataMsg,
|
||||
})
|
||||
assert.Error(err)
|
||||
}
|
||||
func TestReceiveImage(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
|
Reference in New Issue