summaryrefslogtreecommitdiffstats
path: root/bridge/zulip
diff options
context:
space:
mode:
authorWim <wim@42.be>2019-03-02 20:31:38 +0100
committerGitHub <noreply@github.com>2019-03-02 20:31:38 +0100
commitc557d51b6faf146e67ececceaeb731a87e1a498b (patch)
tree632be4cb5390df898d2d0cfe0b2f4c3bbb30ce7a /bridge/zulip
parentdf3fdc26a01a20c3568b824f4f15f9b56a2f3db3 (diff)
downloadmatterbridge-msglm-c557d51b6faf146e67ececceaeb731a87e1a498b.tar.gz
matterbridge-msglm-c557d51b6faf146e67ececceaeb731a87e1a498b.tar.bz2
matterbridge-msglm-c557d51b6faf146e67ececceaeb731a87e1a498b.zip
Need to specify /topic:mytopic for channel configuration (zulip). (#751)
Breaking change for zulip channel configuration. For zulip the channel configuration will now need to specify also the topic with /topic:yourtopic. Example: [[gateway.inout]] account="zulip.streamchat" channel="general/topic:mytopic" This fixes the incorrect PR #701 which didn't work with multiple gateways.
Diffstat (limited to 'bridge/zulip')
-rw-r--r--bridge/zulip/zulip.go33
1 files changed, 15 insertions, 18 deletions
diff --git a/bridge/zulip/zulip.go b/bridge/zulip/zulip.go
index 77bb7e7e..cdf433af 100644
--- a/bridge/zulip/zulip.go
+++ b/bridge/zulip/zulip.go
@@ -4,6 +4,7 @@ import (
"encoding/json"
"io/ioutil"
"strconv"
+ "strings"
"sync"
"time"
@@ -18,12 +19,11 @@ type Bzulip struct {
bot *gzb.Bot
streams map[int]string
*bridge.Config
- channelToTopic map[string]string
sync.RWMutex
}
func New(cfg *bridge.Config) bridge.Bridger {
- return &Bzulip{Config: cfg, streams: make(map[int]string), channelToTopic: make(map[string]string)}
+ return &Bzulip{Config: cfg, streams: make(map[int]string)}
}
func (b *Bzulip) Connect() error {
@@ -48,9 +48,6 @@ func (b *Bzulip) Disconnect() error {
}
func (b *Bzulip) JoinChannel(channel config.ChannelInfo) error {
- b.Lock()
- defer b.Unlock()
- b.channelToTopic[channel.Name] = channel.Options.Topic
return nil
}
@@ -138,7 +135,14 @@ func (b *Bzulip) handleQueue() error {
if m.SenderEmail == b.GetString("login") {
continue
}
- rmsg := config.Message{Username: m.SenderFullName, Text: m.Content, Channel: b.getChannel(m.StreamID), Account: b.Account, UserID: strconv.Itoa(m.SenderID), Avatar: m.AvatarURL}
+ rmsg := config.Message{
+ Username: m.SenderFullName,
+ Text: m.Content,
+ Channel: b.getChannel(m.StreamID) + "/topic:" + m.Subject,
+ Account: b.Account,
+ UserID: strconv.Itoa(m.SenderID),
+ Avatar: m.AvatarURL,
+ }
b.Log.Debugf("<= Sending message from %s on %s to gateway", rmsg.Username, b.Account)
b.Log.Debugf("<= Message is %#v", rmsg)
b.Remote <- rmsg
@@ -149,12 +153,11 @@ func (b *Bzulip) handleQueue() error {
}
func (b *Bzulip) sendMessage(msg config.Message) (string, error) {
- topic := "matterbridge"
- if b.GetString("topic") != "" {
- topic = b.GetString("topic")
- }
- if res := b.getTopic(msg.Channel); res != "" {
- topic = res
+ topic := ""
+ if strings.Contains(msg.Channel, "/topic:") {
+ res := strings.Split(msg.Channel, "/topic:")
+ topic = res[1]
+ msg.Channel = res[0]
}
m := gzb.Message{
Stream: msg.Channel,
@@ -202,9 +205,3 @@ func (b *Bzulip) handleUploadFile(msg *config.Message) (string, error) {
}
return "", nil
}
-
-func (b *Bzulip) getTopic(channel string) string {
- b.RLock()
- defer b.RUnlock()
- return b.channelToTopic[channel]
-}