fix: improving internal protocol - pass messageID and parentMessageID
messageID and parentMessageID are cleared in the gateway. We need this info in Status to handle replies. Issue #13258
This commit is contained in:
parent
6d31343205
commit
1c7da47b09
@ -48,6 +48,11 @@ type Message struct {
|
|||||||
Extra map[string][]interface{}
|
Extra map[string][]interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type OriginalMessageIds struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
ParentID string `json:"parent_id"`
|
||||||
|
}
|
||||||
|
|
||||||
func (m Message) ParentNotFound() bool {
|
func (m Message) ParentNotFound() bool {
|
||||||
return m.ParentID == ParentIDNotFound
|
return m.ParentID == ParentIDNotFound
|
||||||
}
|
}
|
||||||
|
@ -228,6 +228,19 @@ func (b *Bstatus) toStatusMsg(msg config.Message) *common.Message {
|
|||||||
message := common.NewMessage()
|
message := common.NewMessage()
|
||||||
message.ChatId = msg.Channel
|
message.ChatId = msg.Channel
|
||||||
message.ContentType = protobuf.ChatMessage_BRIDGE_MESSAGE
|
message.ContentType = protobuf.ChatMessage_BRIDGE_MESSAGE
|
||||||
|
|
||||||
|
var originalID, originalParentID string
|
||||||
|
if msg.Extra != nil {
|
||||||
|
originalMessageIdsList := msg.Extra["OriginalMessageIds"]
|
||||||
|
if len(originalMessageIdsList) == 1 {
|
||||||
|
originalMessageIds, ok := originalMessageIdsList[0].(config.OriginalMessageIds)
|
||||||
|
if ok {
|
||||||
|
originalID = originalMessageIds.ID
|
||||||
|
originalParentID = originalMessageIds.ParentID
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
message.Payload = &protobuf.ChatMessage_BridgeMessage{
|
message.Payload = &protobuf.ChatMessage_BridgeMessage{
|
||||||
BridgeMessage: &protobuf.BridgeMessage{
|
BridgeMessage: &protobuf.BridgeMessage{
|
||||||
BridgeName: msg.Protocol,
|
BridgeName: msg.Protocol,
|
||||||
@ -235,8 +248,8 @@ func (b *Bstatus) toStatusMsg(msg config.Message) *common.Message {
|
|||||||
UserAvatar: msg.Avatar,
|
UserAvatar: msg.Avatar,
|
||||||
UserID: msg.UserID,
|
UserID: msg.UserID,
|
||||||
Content: msg.Text,
|
Content: msg.Text,
|
||||||
MessageID: msg.ID,
|
MessageID: originalID,
|
||||||
ParentMessageID: msg.ParentID,
|
ParentMessageID: originalParentID,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,6 +464,16 @@ func (gw *Gateway) SendMessage(
|
|||||||
msg.Avatar = gw.modifyAvatar(rmsg, dest)
|
msg.Avatar = gw.modifyAvatar(rmsg, dest)
|
||||||
msg.Username = gw.modifyUsername(rmsg, dest)
|
msg.Username = gw.modifyUsername(rmsg, dest)
|
||||||
|
|
||||||
|
// ID and ParentID are for some reason cleared by getDestMsgID
|
||||||
|
// We need them to send to Status
|
||||||
|
if msg.Extra == nil {
|
||||||
|
msg.Extra = make(map[string][]interface{})
|
||||||
|
}
|
||||||
|
msg.Extra["OriginalMessageIds"] = []interface{}{config.OriginalMessageIds{
|
||||||
|
ID: msg.ID,
|
||||||
|
ParentID: msg.ParentID,
|
||||||
|
}}
|
||||||
|
|
||||||
// exclude file delete event as the msg ID here is the native file ID that needs to be deleted
|
// exclude file delete event as the msg ID here is the native file ID that needs to be deleted
|
||||||
if msg.Event != config.EventFileDelete {
|
if msg.Event != config.EventFileDelete {
|
||||||
msg.ID = gw.getDestMsgID(rmsg.Protocol+" "+rmsg.ID, dest, channel)
|
msg.ID = gw.getDestMsgID(rmsg.Protocol+" "+rmsg.ID, dest, channel)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user