5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-11-22 12:50:27 +00:00

Make edits/delete work for bridges that gets reused. Closes #342

This commit is contained in:
Wim 2018-01-20 21:58:59 +01:00
parent 7119e378a7
commit a4d5c94d9b

View File

@ -29,8 +29,9 @@ type Gateway struct {
} }
type BrMsgID struct { type BrMsgID struct {
br *bridge.Bridge br *bridge.Bridge
ID string ID string
ChannelID string
} }
func New(cfg config.Gateway, r *Router) *Gateway { func New(cfg config.Gateway, r *Router) *Gateway {
@ -190,7 +191,9 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) []*BrM
if res, ok := gw.Messages.Get(origmsg.ID); ok { if res, ok := gw.Messages.Get(origmsg.ID); ok {
IDs := res.([]*BrMsgID) IDs := res.([]*BrMsgID)
for _, id := range IDs { for _, id := range IDs {
if dest.Protocol == id.br.Protocol { // check protocol, bridge name and channelname
// for people that reuse the same bridge multiple times. see #342
if dest.Protocol == id.br.Protocol && dest.Name == id.br.Name && channel.ID == id.ChannelID {
msg.ID = id.ID msg.ID = id.ID
} }
} }
@ -205,7 +208,7 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) []*BrM
} }
// append the message ID (mID) from this bridge (dest) to our brMsgIDs slice // append the message ID (mID) from this bridge (dest) to our brMsgIDs slice
if mID != "" { if mID != "" {
brMsgIDs = append(brMsgIDs, &BrMsgID{dest, mID}) brMsgIDs = append(brMsgIDs, &BrMsgID{dest, mID, channel.ID})
} }
} }
return brMsgIDs return brMsgIDs