mirror of
https://github.com/42wim/matterbridge.git
synced 2024-11-22 03:49:25 +01:00
implement parsing of quotes/replies from whatsapp
This commit is contained in:
parent
0a6d64ab48
commit
6afa93e537
@ -62,6 +62,7 @@ func (b *Bwhatsapp) handleTextMessage(messageInfo types.MessageInfo, msg *proto.
|
||||
}
|
||||
|
||||
var text string
|
||||
var parent string
|
||||
|
||||
// nolint:nestif
|
||||
if msg.GetExtendedTextMessage() == nil {
|
||||
@ -89,6 +90,10 @@ func (b *Bwhatsapp) handleTextMessage(messageInfo types.MessageInfo, msg *proto.
|
||||
text = strings.Replace(text, "@"+numberAndSuffix[0], "@"+mention, 1)
|
||||
}
|
||||
}
|
||||
|
||||
if ci.StanzaId != nil {
|
||||
parent = *ci.StanzaId
|
||||
}
|
||||
}
|
||||
|
||||
rmsg := config.Message{
|
||||
@ -99,8 +104,8 @@ func (b *Bwhatsapp) handleTextMessage(messageInfo types.MessageInfo, msg *proto.
|
||||
Account: b.Account,
|
||||
Protocol: b.Protocol,
|
||||
Extra: make(map[string][]interface{}),
|
||||
// ParentID: TODO, // TODO handle thread replies // map from Info.QuotedMessageID string
|
||||
ID: messageInfo.ID,
|
||||
ParentID: parent,
|
||||
ID: messageInfo.ID,
|
||||
}
|
||||
|
||||
if avatarURL, exists := b.userAvatars[senderJID.String()]; exists {
|
||||
@ -125,6 +130,11 @@ func (b *Bwhatsapp) handleImageMessage(msg *events.Message) {
|
||||
senderJID = types.NewJID(ci.GetParticipant(), types.DefaultUserServer)
|
||||
}
|
||||
|
||||
var parent string
|
||||
if ci.StanzaId != nil {
|
||||
parent = *ci.StanzaId
|
||||
}
|
||||
|
||||
rmsg := config.Message{
|
||||
UserID: senderJID.String(),
|
||||
Username: senderName,
|
||||
@ -133,6 +143,7 @@ func (b *Bwhatsapp) handleImageMessage(msg *events.Message) {
|
||||
Protocol: b.Protocol,
|
||||
Extra: make(map[string][]interface{}),
|
||||
ID: msg.Info.ID,
|
||||
ParentID: parent,
|
||||
}
|
||||
|
||||
if avatarURL, exists := b.userAvatars[senderJID.String()]; exists {
|
||||
@ -188,6 +199,11 @@ func (b *Bwhatsapp) handleVideoMessage(msg *events.Message) {
|
||||
senderJID = types.NewJID(ci.GetParticipant(), types.DefaultUserServer)
|
||||
}
|
||||
|
||||
var parent string
|
||||
if ci.StanzaId != nil {
|
||||
parent = *ci.StanzaId
|
||||
}
|
||||
|
||||
rmsg := config.Message{
|
||||
UserID: senderJID.String(),
|
||||
Username: senderName,
|
||||
@ -196,6 +212,7 @@ func (b *Bwhatsapp) handleVideoMessage(msg *events.Message) {
|
||||
Protocol: b.Protocol,
|
||||
Extra: make(map[string][]interface{}),
|
||||
ID: msg.Info.ID,
|
||||
ParentID: parent,
|
||||
}
|
||||
|
||||
if avatarURL, exists := b.userAvatars[senderJID.String()]; exists {
|
||||
@ -244,6 +261,11 @@ func (b *Bwhatsapp) handleAudioMessage(msg *events.Message) {
|
||||
if senderJID == (types.JID{}) && ci.Participant != nil {
|
||||
senderJID = types.NewJID(ci.GetParticipant(), types.DefaultUserServer)
|
||||
}
|
||||
|
||||
var parent string
|
||||
if ci.StanzaId != nil {
|
||||
parent = *ci.StanzaId
|
||||
}
|
||||
|
||||
rmsg := config.Message{
|
||||
UserID: senderJID.String(),
|
||||
@ -253,6 +275,7 @@ func (b *Bwhatsapp) handleAudioMessage(msg *events.Message) {
|
||||
Protocol: b.Protocol,
|
||||
Extra: make(map[string][]interface{}),
|
||||
ID: msg.Info.ID,
|
||||
ParentID: parent,
|
||||
}
|
||||
|
||||
if avatarURL, exists := b.userAvatars[senderJID.String()]; exists {
|
||||
@ -276,7 +299,7 @@ func (b *Bwhatsapp) handleAudioMessage(msg *events.Message) {
|
||||
|
||||
data, err := b.wc.Download(imsg)
|
||||
if err != nil {
|
||||
b.Log.Errorf("Download video failed: %s", err)
|
||||
b.Log.Errorf("Download audio failed: %s", err)
|
||||
|
||||
return
|
||||
}
|
||||
@ -302,6 +325,11 @@ func (b *Bwhatsapp) handleDocumentMessage(msg *events.Message) {
|
||||
senderJID = types.NewJID(ci.GetParticipant(), types.DefaultUserServer)
|
||||
}
|
||||
|
||||
var parent string
|
||||
if ci.StanzaId != nil {
|
||||
parent = *ci.StanzaId
|
||||
}
|
||||
|
||||
rmsg := config.Message{
|
||||
UserID: senderJID.String(),
|
||||
Username: senderName,
|
||||
@ -310,6 +338,7 @@ func (b *Bwhatsapp) handleDocumentMessage(msg *events.Message) {
|
||||
Protocol: b.Protocol,
|
||||
Extra: make(map[string][]interface{}),
|
||||
ID: msg.Info.ID,
|
||||
ParentID: parent,
|
||||
}
|
||||
|
||||
if avatarURL, exists := b.userAvatars[senderJID.String()]; exists {
|
||||
|
Loading…
Reference in New Issue
Block a user