Skip to content

Commit c91572f

Browse files
committed
Revert "Add debug code to troubleshoot missing discord/xmpp replies"
This reverts commit 0faf1ed. not needed anymore !
1 parent e3a60a8 commit c91572f

3 files changed

Lines changed: 3 additions & 34 deletions

File tree

gateway/gateway.go

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ func New(rootLogger *logrus.Logger, cfg *config.Gateway, r *Router) *Gateway {
6565
// FindCanonicalMsgID returns the ID under which a message was stored in the cache.
6666
func (gw *Gateway) FindCanonicalMsgID(protocol string, mID string) string {
6767
ID := protocol + " " + mID
68-
gw.logger.Debugf("FindCanonicalMsgID: looking for ID=%s in cache (cache has %d entries)", ID, gw.Messages.Len())
6968
if gw.Messages.Contains(ID) {
70-
gw.logger.Debugf("FindCanonicalMsgID: found ID=%s directly in cache", ID)
7169
return ID
7270
}
7371

@@ -77,12 +75,10 @@ func (gw *Gateway) FindCanonicalMsgID(protocol string, mID string) string {
7775
ids := v.([]*BrMsgID)
7876
for _, downstreamMsgObj := range ids {
7977
if ID == downstreamMsgObj.ID {
80-
gw.logger.Debugf("FindCanonicalMsgID: found ID=%s as downstream of canonical=%s", ID, mid.(string))
8178
return mid.(string)
8279
}
8380
}
8481
}
85-
gw.logger.Debugf("FindCanonicalMsgID: ID=%s not found in cache", ID)
8682
return ""
8783
}
8884

@@ -263,23 +259,15 @@ func (gw *Gateway) getDestChannel(msg *config.Message, dest bridge.Bridge) []con
263259
}
264260

265261
func (gw *Gateway) getDestMsgID(msgID string, dest *bridge.Bridge, channel *config.ChannelInfo) string {
266-
gw.logger.Debugf("getDestMsgID: looking for msgID=%s, dest.Protocol=%s, dest.Name=%s, channel.ID=%s", msgID, dest.Protocol, dest.Name, channel.ID)
267262
if res, ok := gw.Messages.Get(msgID); ok {
268263
IDs := res.([]*BrMsgID)
269-
gw.logger.Debugf("getDestMsgID: found %d cached destination IDs for msgID=%s", len(IDs), msgID)
270264
for _, id := range IDs {
271-
gw.logger.Debugf("getDestMsgID: checking cached entry: br.Protocol=%s, br.Name=%s, ChannelID=%s, ID=%s", id.br.Protocol, id.br.Name, id.ChannelID, id.ID)
272265
// check protocol, bridge name and channelname
273266
// for people that reuse the same bridge multiple times. see #342
274267
if dest.Protocol == id.br.Protocol && dest.Name == id.br.Name && channel.ID == id.ChannelID {
275-
result := strings.Replace(id.ID, dest.Protocol+" ", "", 1)
276-
gw.logger.Debugf("getDestMsgID: match found, returning %s", result)
277-
return result
268+
return strings.Replace(id.ID, dest.Protocol+" ", "", 1)
278269
}
279270
}
280-
gw.logger.Debugf("getDestMsgID: no matching entry found in cached IDs")
281-
} else {
282-
gw.logger.Debugf("getDestMsgID: msgID=%s not found in cache", msgID)
283271
}
284272
return ""
285273
}
@@ -486,21 +474,16 @@ func (gw *Gateway) SendMessage(
486474
msg.Channel = rmsg.Channel
487475
}
488476

489-
gw.logger.Debugf("SendMessage: rmsg.ParentID=%s, canonicalParentMsgID=%s", rmsg.ParentID, canonicalParentMsgID)
490477
msg.ParentID = gw.getDestMsgID(canonicalParentMsgID, dest, channel)
491-
gw.logger.Debugf("SendMessage: after getDestMsgID, msg.ParentID=%s", msg.ParentID)
492478
if msg.ParentID == "" {
493479
msg.ParentID = strings.Replace(canonicalParentMsgID, dest.Protocol+" ", "", 1)
494-
gw.logger.Debugf("SendMessage: after fallback strip, msg.ParentID=%s", msg.ParentID)
495480
}
496481

497482
// if the parentID is still empty and we have a parentID set in the original message
498483
// this means that we didn't find it in the cache so set it to a "msg-parent-not-found" constant
499484
if msg.ParentID == "" && rmsg.ParentID != "" {
500-
gw.logger.Debugf("SendMessage: parent not found in cache, setting to ParentIDNotFound")
501485
msg.ParentID = config.ParentIDNotFound
502486
}
503-
gw.logger.Debugf("SendMessage: final msg.ParentID=%s", msg.ParentID)
504487

505488
drop, err := gw.modifyOutMessageTengo(rmsg, &msg, dest)
506489
if err != nil {

gateway/handlers.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,7 @@ func (gw *Gateway) handleMessage(rmsg *config.Message, dest *bridge.Bridge) []*B
217217
// Get the ID of the parent message in thread
218218
var canonicalParentMsgID string
219219
if rmsg.ParentID != "" && dest.GetBool("PreserveThreading") {
220-
gw.logger.Debugf("handleMessage: rmsg.ParentID=%s, dest.Protocol=%s, PreserveThreading=true, looking up canonical parent", rmsg.ParentID, dest.Protocol)
221220
canonicalParentMsgID = gw.FindCanonicalMsgID(rmsg.Protocol, rmsg.ParentID)
222-
gw.logger.Debugf("handleMessage: canonicalParentMsgID=%s", canonicalParentMsgID)
223-
} else if rmsg.ParentID != "" {
224-
gw.logger.Debugf("handleMessage: rmsg.ParentID=%s but PreserveThreading=%v for dest %s", rmsg.ParentID, dest.GetBool("PreserveThreading"), dest.Account)
225221
}
226222

227223
channels := gw.getDestChannel(rmsg, *dest)

gateway/router.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,26 +155,16 @@ func (r *Router) handleReceive() {
155155
}
156156

157157
if msg.ID != "" {
158-
cacheKey := msg.Protocol + " " + msg.ID
159-
_, exists := gw.Messages.Get(cacheKey)
158+
_, exists := gw.Messages.Get(msg.Protocol + " " + msg.ID)
160159

161160
// Only add the message ID if it doesn't already exist
162161
//
163162
// For some bridges we always add/update the message ID.
164163
// This is necessary as msgIDs will change if a bridge returns
165164
// a different ID in response to edits.
166165
if !exists {
167-
gw.logger.Debugf("Messages.Add: caching key=%s with %d destination IDs", cacheKey, len(msgIDs))
168-
for i, brMsgID := range msgIDs {
169-
gw.logger.Debugf("Messages.Add: [%d] br.Protocol=%s, br.Name=%s, ChannelID=%s, ID=%s", i, brMsgID.br.Protocol, brMsgID.br.Name, brMsgID.ChannelID, brMsgID.ID)
170-
}
171-
gw.Messages.Add(cacheKey, msgIDs)
172-
gw.logger.Debugf("Messages.Add: cache now has %d entries", gw.Messages.Len())
173-
} else {
174-
gw.logger.Debugf("Messages.Add: key=%s already exists, not re-adding", cacheKey)
166+
gw.Messages.Add(msg.Protocol+" "+msg.ID, msgIDs)
175167
}
176-
} else {
177-
gw.logger.Debugf("Messages.Add: msg.ID is empty, not caching")
178168
}
179169
}
180170
}

0 commit comments

Comments
 (0)