commit 87a3574c7d1d22b49e073364877724df34411e3e
Author: Wim <wim@42.be>
Date: Sat Mar 02 20:31:38 2019 +0000
diff --git a/bridge/zulip/zulip.go b/bridge/zulip/zulip.go
index 77bb7e7..cdf433a 100644
--- a/bridge/zulip/zulip.go
+++ b/bridge/zulip/zulip.go
@@ -46 +47 @@ import (
"encoding/json"
"io/ioutil"
"strconv"
+ "strings"
"sync"
"time"
@@ -1812 +1911 @@ 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 {
@@ -489 +486 @@ 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
}
@@ -1387 +13514 @@ 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
@@ -14912 +15311 @@ 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,
@@ -2029 +2053 @@ 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]
-}
diff --git a/gateway/gateway.go b/gateway/gateway.go
index be45086..82be2a9 100644
--- a/gateway/gateway.go
+++ b/gateway/gateway.go
@@ -1596 +15910 @@ func (gw *Gateway) mapChannelConfig(cfg []config.Bridge, direction string) {
gw.logger.Errorf("Mattermost channels do not start with a #: remove the # in %s", br.Channel)
os.Exit(1)
}
+ if strings.HasPrefix(br.Account, "zulip.") && !strings.Contains(br.Channel, "/topic:") {
+ gw.logger.Errorf("Breaking change, since matterbridge 1.14.0 zulip channels need to specify the topic with channel/topic:mytopic in %s of %s", br.Channel, br.Account)
+ os.Exit(1)
+ }
ID := br.Channel + br.Account
if _, ok := gw.Channels[ID]; !ok {
channel := &config.ChannelInfo{
diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample
index 1c517a5..8fbbfe0 100644
--- a/matterbridge.toml.sample
+++ b/matterbridge.toml.sample
@@ -136312 +13636 @@ Login="yourbot-bot@yourserver.zulipchat.com"
#REQUIRED
Server="https://yourserver.zulipchat.com"
-#Topic of the messages matterbridge will use
-#OPTIONAL (default "matterbridge")
-#You can specify a specific topic for each channel using [gateway.inout.options]
-#See more information below at the gateway configuration
-Topic="matterbridge"
-
## RELOADABLE SETTINGS
## Settings below can be reloaded by editing the file
@@ -16087 +16027 @@ enable=true
- # zulip - stream (without the #)
+ # zulip - stream/topic:topicname (without the #)
@@ -165010 +16447 @@ enable=true
- channel="general"
- #OPTIONAL - topic only works for zulip
- [gateway.inout.options]
- topic="topic1"
+ channel="general/topic:mytopic"