summaryrefslogtreecommitdiffstats
path: root/bridge
diff options
context:
space:
mode:
Diffstat (limited to 'bridge')
-rw-r--r--bridge/slack/handlers.go3
-rw-r--r--bridge/slack/helpers.go7
-rw-r--r--bridge/slack/slack.go6
-rw-r--r--bridge/zulip/zulip.go25
4 files changed, 40 insertions, 1 deletions
diff --git a/bridge/slack/handlers.go b/bridge/slack/handlers.go
index e013b830..5cfcc42b 100644
--- a/bridge/slack/handlers.go
+++ b/bridge/slack/handlers.go
@@ -192,6 +192,9 @@ func (b *Bslack) handleMessageEvent(ev *slack.MessageEvent) (*config.Message, er
// This is probably a webhook we couldn't resolve.
return nil, fmt.Errorf("message handling resulted in an empty bot message (probably an incoming webhook we couldn't resolve): %#v", ev)
}
+ if ev.SubMessage != nil {
+ return nil, fmt.Errorf("message handling resulted in an empty message: %#v with submessage %#v", ev, ev.SubMessage)
+ }
return nil, fmt.Errorf("message handling resulted in an empty message: %#v", ev)
}
return rmsg, nil
diff --git a/bridge/slack/helpers.go b/bridge/slack/helpers.go
index 9959d4fa..4d191c0d 100644
--- a/bridge/slack/helpers.go
+++ b/bridge/slack/helpers.go
@@ -254,6 +254,13 @@ func (b *Bslack) populateReceivedMessage(ev *slack.MessageEvent) (*config.Messag
}
}
+ // For edits, only submessage has thread ts.
+ // Ensures edits to threaded messages maintain their prefix hint on the
+ // unthreaded end.
+ if ev.SubMessage != nil {
+ rmsg.ParentID = ev.SubMessage.ThreadTimestamp
+ }
+
if err = b.populateMessageWithUserInfo(ev, rmsg); err != nil {
return nil, err
}
diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go
index 001b1268..1685c4fc 100644
--- a/bridge/slack/slack.go
+++ b/bridge/slack/slack.go
@@ -293,6 +293,12 @@ func (b *Bslack) sendRTM(msg config.Message) (string, error) {
return "", err
}
+ // Handle prefix hint for unthreaded messages.
+ if msg.ParentID == "msg-parent-not-found" {
+ msg.ParentID = ""
+ msg.Text = fmt.Sprintf("[thread]: %s", msg.Text)
+ }
+
// Handle message deletions.
if handled, err = b.deleteMessage(&msg, channelInfo); handled {
return msg.ID, err
diff --git a/bridge/zulip/zulip.go b/bridge/zulip/zulip.go
index 88832d36..3c6c7ec6 100644
--- a/bridge/zulip/zulip.go
+++ b/bridge/zulip/zulip.go
@@ -100,7 +100,30 @@ func (b *Bzulip) getChannel(id int) string {
func (b *Bzulip) handleQueue() error {
for {
- messages, _ := b.q.GetEvents()
+ messages, err := b.q.GetEvents()
+ switch err {
+ case gzb.BackoffError:
+ time.Sleep(time.Second * 5)
+ case gzb.NoJSONError:
+ b.Log.Error("Response wasn't JSON, server down or restarting? sleeping 10 seconds")
+ time.Sleep(time.Second * 10)
+ case gzb.BadEventQueueError:
+ b.Log.Info("got a bad event queue id error, reconnecting")
+ b.bot.Queues = nil
+ b.q, err = b.bot.RegisterAll()
+ if err != nil {
+ b.Log.Errorf("reconnecting failed: %s. Sleeping 10 seconds", err)
+ time.Sleep(time.Second * 10)
+ continue
+ }
+ case gzb.HeartbeatError:
+ b.Log.Debug("heartbeat received.")
+ default:
+ b.Log.Debugf("receiving error: %#v", err)
+ }
+ if err != nil {
+ continue
+ }
for _, m := range messages {
b.Log.Debugf("== Receiving %#v", m)
// ignore our own messages