mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-06-26 17:49:23 +00:00
Compare commits
20 Commits
v0.4.2
...
v0.5.0-bet
Author | SHA1 | Date | |
---|---|---|---|
c769e23a9a | |||
9db48f4794 | |||
911c597377 | |||
28244ffd9a | |||
3e38c7945c | |||
79ffb76f6e | |||
5fe4b749cf | |||
6991d85da9 | |||
c1c187a1ab | |||
055d12e3ef | |||
b49429d722 | |||
815c7f8d64 | |||
c879f79456 | |||
3bc25f4707 | |||
300cfe044a | |||
fb586f4a96 | |||
ced371bece | |||
a87cac1982 | |||
8fb5c7afa6 | |||
aceb830378 |
113
README.md
113
README.md
@ -1,14 +1,25 @@
|
||||
# matterbridge
|
||||
|
||||
Simple bridge between mattermost and IRC. Uses the in/outgoing webhooks.
|
||||
Relays public channel messages between mattermost and IRC.
|
||||
Simple bridge between mattermost and IRC.
|
||||
|
||||
Requires mattermost 1.2.0+
|
||||
* Relays public channel messages between mattermost and IRC.
|
||||
* Supports multiple mattermost and irc channels.
|
||||
* Matterbridge -plus also works with private groups on your mattermost.
|
||||
|
||||
There is also [matterbridge-plus] (https://github.com/42wim/matterbridge-plus) which uses the mattermost API and needs a dedicated user (bot). But requires no incoming/outgoing webhook setup.
|
||||
This project has now [matterbridge-plus](https://github.com/42wim/matterbridge-plus/) merged in.
|
||||
Breaking changes for matterbridge can be found in [migration](https://github.com/42wim/matterbridge/blob/master/migration.md)
|
||||
|
||||
## Requirements:
|
||||
* [Mattermost] (https://github.com/mattermost/platform/) 3.x (stable, not a dev build)
|
||||
|
||||
### Webhooks version
|
||||
* Configured incoming/outgoing [webhooks](https://www.mattermost.org/webhooks/) on your mattermost instance.
|
||||
|
||||
### Plus (API) version
|
||||
* A dedicated user(bot) on your mattermost instance.
|
||||
|
||||
## binaries
|
||||
Binaries can be found [here] (https://github.com/42wim/matterbridge/releases/tag/v0.4.2)
|
||||
Binaries can be found [here] (https://github.com/42wim/matterbridge/releases/tag/v0.5-beta2)
|
||||
|
||||
## building
|
||||
Go 1.6+ is required. Make sure you have [Go](https://golang.org/doc/install) properly installed, including setting up your [GOPATH] (https://golang.org/doc/code.html#GOPATH)
|
||||
@ -31,77 +42,26 @@ matterbridge
|
||||
3) Now you can run matterbridge.
|
||||
|
||||
```
|
||||
Usage of matterbridge:
|
||||
-conf="matterbridge.conf": config file
|
||||
Usage of ./matterbridge:
|
||||
-conf string
|
||||
config file (default "matterbridge.conf")
|
||||
-debug
|
||||
enable debug
|
||||
-plus
|
||||
running using API instead of webhooks
|
||||
-version
|
||||
show version
|
||||
```
|
||||
|
||||
Matterbridge will:
|
||||
* start a webserver listening on the port specified in the configuration.
|
||||
* connect to specified irc server and channel.
|
||||
* send messages from mattermost to irc and vice versa, messages in mattermost will appear with irc-nick
|
||||
|
||||
## config
|
||||
### matterbridge
|
||||
matterbridge looks for matterbridge.conf in current directory. (use -conf to specify another file)
|
||||
|
||||
Look at matterbridge.conf.sample for an example
|
||||
|
||||
|
||||
```
|
||||
[IRC]
|
||||
server="irc.freenode.net"
|
||||
port=6667
|
||||
UseTLS=false
|
||||
SkipTLSVerify=true
|
||||
nick="matterbot"
|
||||
channel="#matterbridge"
|
||||
UseSlackCircumfix=false
|
||||
#Freenode nickserv
|
||||
NickServNick="nickserv"
|
||||
#Password for nickserv
|
||||
NickServPassword="secret"
|
||||
#Ignore the messages from these nicks. They will not be sent to mattermost
|
||||
IgnoreNicks="ircspammer1 ircspammer2"
|
||||
|
||||
[mattermost]
|
||||
#url is your incoming webhook url (account settings - integrations - incoming webhooks)
|
||||
url="http://mattermost.yourdomain.com/hooks/incomingwebhookkey"
|
||||
#port the bridge webserver will listen on
|
||||
port=9999
|
||||
#address the webserver will bind to
|
||||
BindAddress="0.0.0.0"
|
||||
showjoinpart=true #show irc users joining and parting
|
||||
#the token you get from the outgoing webhook in mattermost. If empty no token check will be done.
|
||||
#if you use multiple IRC channel (see below, this must be empty!)
|
||||
token=yourtokenfrommattermost
|
||||
#disable certificate checking (selfsigned certificates)
|
||||
#SkipTLSVerify=true
|
||||
#whether to prefix messages from IRC to mattermost with the sender's nick. Useful if username overrides for incoming webhooks isn't enabled on the mattermost server
|
||||
PrefixMessagesWithNick=false
|
||||
#how to format the list of IRC nicks when displayed in mattermost. Possible options are "table" and "plain"
|
||||
NickFormatter=plain
|
||||
#how many nicks to list per row for formatters that support this
|
||||
NicksPerRow=4
|
||||
#Ignore the messages from these nicks. They will not be sent to irc
|
||||
IgnoreNicks="mmbot spammer2"
|
||||
|
||||
#multiple channel config
|
||||
#token you can find in your outgoing webhook
|
||||
[Token "outgoingwebhooktoken1"]
|
||||
IRCChannel="#off-topic"
|
||||
MMChannel="off-topic"
|
||||
|
||||
[Token "outgoingwebhooktoken2"]
|
||||
IRCChannel="#testing"
|
||||
MMChannel="testing"
|
||||
|
||||
[general]
|
||||
#request your API key on https://github.com/giphy/GiphyAPI. This is a public beta key
|
||||
GiphyApiKey="dc6zaTOxFJmzC"
|
||||
```
|
||||
Look at [matterbridge.conf.sample] (https://github.com/42wim/matterbridge/blob/master/matterbridge.conf.sample) for an example.
|
||||
|
||||
### mattermost
|
||||
You'll have to configure the incoming en outgoing webhooks.
|
||||
#### webhooks version
|
||||
You'll have to configure the incoming and outgoing webhooks.
|
||||
|
||||
* incoming webhooks
|
||||
Go to "account settings" - integrations - "incoming webhooks".
|
||||
@ -112,5 +72,20 @@ This URL should be set in the matterbridge.conf in the [mattermost] section (see
|
||||
Go to "account settings" - integrations - "outgoing webhooks".
|
||||
Choose a channel (the same as the one from incoming webhooks) and fill in the address and port of the server matterbridge will run on.
|
||||
|
||||
e.g. http://192.168.1.1:9999 (9999 is the port specified in [mattermost] section of matterbridge.conf)
|
||||
e.g. http://192.168.1.1:9999 (192.168.1.1:9999 is the BindAddress specified in [mattermost] section of matterbridge.conf)
|
||||
|
||||
#### plus version
|
||||
You'll have to create a new dedicated user on your mattermost instance.
|
||||
Specify the login and password in [mattermost] section of matterbridge.conf
|
||||
|
||||
## FAQ
|
||||
Please look at [matterbridge.conf.sample] (https://github.com/42wim/matterbridge/blob/master/matterbridge.conf.sample) for more information first.
|
||||
### Mattermost doesn't show the IRC nicks
|
||||
If you're running the webhooks version, this can be fixed by either:
|
||||
* enabling "override usernames". See [mattermost documentation](http://docs.mattermost.com/developer/webhooks-incoming.html#enabling-incoming-webhooks)
|
||||
* setting ```PrefixMessagesWithNick``` to ```true``` in ```mattermost``` section of your matterbridge.conf.
|
||||
|
||||
If you're running the plus version you'll need to:
|
||||
* setting ```PrefixMessagesWithNick``` to ```true``` in ```mattermost``` section of your matterbridge.conf.
|
||||
|
||||
Also look at the ```RemoteNickFormat``` setting.
|
||||
|
407
bridge/bridge.go
Normal file
407
bridge/bridge.go
Normal file
@ -0,0 +1,407 @@
|
||||
package bridge
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"github.com/42wim/matterbridge/matterclient"
|
||||
"github.com/42wim/matterbridge/matterhook"
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/peterhellberg/giphy"
|
||||
ircm "github.com/sorcix/irc"
|
||||
"github.com/thoj/go-ircevent"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
//type Bridge struct {
|
||||
type MMhook struct {
|
||||
mh *matterhook.Client
|
||||
}
|
||||
|
||||
type MMapi struct {
|
||||
mc *matterclient.MMClient
|
||||
mmMap map[string]string
|
||||
mmIgnoreNicks []string
|
||||
}
|
||||
|
||||
type MMirc struct {
|
||||
i *irc.Connection
|
||||
ircNick string
|
||||
ircMap map[string]string
|
||||
names map[string][]string
|
||||
ircIgnoreNicks []string
|
||||
}
|
||||
|
||||
type MMMessage struct {
|
||||
Text string
|
||||
Channel string
|
||||
Username string
|
||||
}
|
||||
|
||||
type Bridge struct {
|
||||
MMhook
|
||||
MMapi
|
||||
MMirc
|
||||
*Config
|
||||
kind string
|
||||
}
|
||||
|
||||
type FancyLog struct {
|
||||
irc *log.Entry
|
||||
mm *log.Entry
|
||||
}
|
||||
|
||||
var flog FancyLog
|
||||
|
||||
const Legacy = "legacy"
|
||||
|
||||
func initFLog() {
|
||||
flog.irc = log.WithFields(log.Fields{"module": "irc"})
|
||||
flog.mm = log.WithFields(log.Fields{"module": "mattermost"})
|
||||
}
|
||||
|
||||
func NewBridge(name string, config *Config, kind string) *Bridge {
|
||||
initFLog()
|
||||
b := &Bridge{}
|
||||
b.Config = config
|
||||
b.kind = kind
|
||||
b.ircNick = b.Config.IRC.Nick
|
||||
b.ircMap = make(map[string]string)
|
||||
b.mmMap = make(map[string]string)
|
||||
b.MMirc.names = make(map[string][]string)
|
||||
b.ircIgnoreNicks = strings.Fields(b.Config.IRC.IgnoreNicks)
|
||||
b.mmIgnoreNicks = strings.Fields(b.Config.Mattermost.IgnoreNicks)
|
||||
for _, val := range b.Config.Channel {
|
||||
b.ircMap[val.IRC] = val.Mattermost
|
||||
b.mmMap[val.Mattermost] = val.IRC
|
||||
}
|
||||
if kind == Legacy {
|
||||
b.mh = matterhook.New(b.Config.Mattermost.URL,
|
||||
matterhook.Config{InsecureSkipVerify: b.Config.Mattermost.SkipTLSVerify,
|
||||
BindAddress: b.Config.Mattermost.BindAddress})
|
||||
} else {
|
||||
b.mc = matterclient.New(b.Config.Mattermost.Login, b.Config.Mattermost.Password,
|
||||
b.Config.Mattermost.Team, b.Config.Mattermost.Server)
|
||||
b.mc.SkipTLSVerify = b.Config.Mattermost.SkipTLSVerify
|
||||
b.mc.NoTLS = b.Config.Mattermost.NoTLS
|
||||
flog.mm.Infof("Trying login %s (team: %s) on %s", b.Config.Mattermost.Login, b.Config.Mattermost.Team, b.Config.Mattermost.Server)
|
||||
err := b.mc.Login()
|
||||
if err != nil {
|
||||
flog.mm.Fatal("Can not connect", err)
|
||||
}
|
||||
flog.mm.Info("Login ok")
|
||||
b.mc.JoinChannel(b.Config.Mattermost.Channel)
|
||||
for _, val := range b.Config.Channel {
|
||||
b.mc.JoinChannel(val.Mattermost)
|
||||
}
|
||||
go b.mc.WsReceiver()
|
||||
}
|
||||
flog.irc.Info("Trying IRC connection")
|
||||
b.i = b.createIRC(name)
|
||||
flog.irc.Info("Connection succeeded")
|
||||
go b.handleMatter()
|
||||
return b
|
||||
}
|
||||
|
||||
func (b *Bridge) createIRC(name string) *irc.Connection {
|
||||
i := irc.IRC(b.Config.IRC.Nick, b.Config.IRC.Nick)
|
||||
i.UseTLS = b.Config.IRC.UseTLS
|
||||
i.UseSASL = b.Config.IRC.UseSASL
|
||||
i.SASLLogin = b.Config.IRC.NickServNick
|
||||
i.SASLPassword = b.Config.IRC.NickServPassword
|
||||
i.TLSConfig = &tls.Config{InsecureSkipVerify: b.Config.IRC.SkipTLSVerify}
|
||||
if b.Config.IRC.Password != "" {
|
||||
i.Password = b.Config.IRC.Password
|
||||
}
|
||||
i.AddCallback(ircm.RPL_WELCOME, b.handleNewConnection)
|
||||
err := i.Connect(b.Config.IRC.Server)
|
||||
if err != nil {
|
||||
flog.irc.Fatal(err)
|
||||
}
|
||||
return i
|
||||
}
|
||||
|
||||
func (b *Bridge) handleNewConnection(event *irc.Event) {
|
||||
flog.irc.Info("Registering callbacks")
|
||||
i := b.i
|
||||
b.ircNick = event.Arguments[0]
|
||||
i.AddCallback("PRIVMSG", b.handlePrivMsg)
|
||||
i.AddCallback("CTCP_ACTION", b.handlePrivMsg)
|
||||
i.AddCallback(ircm.RPL_ENDOFNAMES, b.endNames)
|
||||
i.AddCallback(ircm.RPL_NAMREPLY, b.storeNames)
|
||||
i.AddCallback(ircm.RPL_TOPICWHOTIME, b.handleTopicWhoTime)
|
||||
i.AddCallback(ircm.NOTICE, b.handleNotice)
|
||||
i.AddCallback(ircm.RPL_MYINFO, func(e *irc.Event) { flog.irc.Infof("%s: %s", e.Code, strings.Join(e.Arguments[1:], " ")) })
|
||||
i.AddCallback("PING", func(e *irc.Event) {
|
||||
i.SendRaw("PONG :" + e.Message())
|
||||
flog.irc.Debugf("PING/PONG")
|
||||
})
|
||||
if b.Config.Mattermost.ShowJoinPart {
|
||||
i.AddCallback("JOIN", b.handleJoinPart)
|
||||
i.AddCallback("PART", b.handleJoinPart)
|
||||
}
|
||||
i.AddCallback("*", b.handleOther)
|
||||
b.setupChannels()
|
||||
}
|
||||
|
||||
func (b *Bridge) setupChannels() {
|
||||
i := b.i
|
||||
for _, val := range b.Config.Channel {
|
||||
flog.irc.Infof("Joining %s as %s", val.IRC, b.ircNick)
|
||||
i.Join(val.IRC)
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Bridge) handleIrcBotCommand(event *irc.Event) bool {
|
||||
parts := strings.Fields(event.Message())
|
||||
exp, _ := regexp.Compile("[:,]+$")
|
||||
channel := event.Arguments[0]
|
||||
command := ""
|
||||
if len(parts) == 2 {
|
||||
command = parts[1]
|
||||
}
|
||||
if exp.ReplaceAllString(parts[0], "") == b.ircNick {
|
||||
switch command {
|
||||
case "users":
|
||||
usernames := b.mc.UsernamesInChannel(b.getMMChannel(channel))
|
||||
sort.Strings(usernames)
|
||||
b.i.Privmsg(channel, "Users on Mattermost: "+strings.Join(usernames, ", "))
|
||||
default:
|
||||
b.i.Privmsg(channel, "Valid commands are: [users, help]")
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (b *Bridge) ircNickFormat(nick string) string {
|
||||
if nick == b.ircNick {
|
||||
return nick
|
||||
}
|
||||
if b.Config.Mattermost.RemoteNickFormat == nil {
|
||||
return "irc-" + nick
|
||||
}
|
||||
return strings.Replace(*b.Config.Mattermost.RemoteNickFormat, "{NICK}", nick, -1)
|
||||
}
|
||||
|
||||
func (b *Bridge) handlePrivMsg(event *irc.Event) {
|
||||
flog.irc.Debugf("handlePrivMsg() %s %s", event.Nick, event.Message())
|
||||
if b.ignoreMessage(event.Nick, event.Message(), "irc") {
|
||||
return
|
||||
}
|
||||
if b.handleIrcBotCommand(event) {
|
||||
return
|
||||
}
|
||||
msg := ""
|
||||
if event.Code == "CTCP_ACTION" {
|
||||
msg = event.Nick + " "
|
||||
}
|
||||
msg += event.Message()
|
||||
b.Send(b.ircNickFormat(event.Nick), msg, b.getMMChannel(event.Arguments[0]))
|
||||
}
|
||||
|
||||
func (b *Bridge) handleJoinPart(event *irc.Event) {
|
||||
b.Send(b.ircNick, b.ircNickFormat(event.Nick)+" "+strings.ToLower(event.Code)+"s "+event.Message(), b.getMMChannel(event.Arguments[0]))
|
||||
}
|
||||
|
||||
func (b *Bridge) handleNotice(event *irc.Event) {
|
||||
if strings.Contains(event.Message(), "This nickname is registered") {
|
||||
b.i.Privmsg(b.Config.IRC.NickServNick, "IDENTIFY "+b.Config.IRC.NickServPassword)
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Bridge) nicksPerRow() int {
|
||||
if b.Config.Mattermost.NicksPerRow < 1 {
|
||||
return 4
|
||||
}
|
||||
return b.Config.Mattermost.NicksPerRow
|
||||
}
|
||||
|
||||
func (b *Bridge) formatnicks(nicks []string, continued bool) string {
|
||||
switch b.Config.Mattermost.NickFormatter {
|
||||
case "table":
|
||||
return tableformatter(nicks, b.nicksPerRow(), continued)
|
||||
default:
|
||||
return plainformatter(nicks, b.nicksPerRow())
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Bridge) storeNames(event *irc.Event) {
|
||||
channel := event.Arguments[2]
|
||||
b.MMirc.names[channel] = append(
|
||||
b.MMirc.names[channel],
|
||||
strings.Split(strings.TrimSpace(event.Message()), " ")...)
|
||||
}
|
||||
|
||||
func (b *Bridge) endNames(event *irc.Event) {
|
||||
channel := event.Arguments[1]
|
||||
sort.Strings(b.MMirc.names[channel])
|
||||
maxNamesPerPost := (300 / b.nicksPerRow()) * b.nicksPerRow()
|
||||
continued := false
|
||||
for len(b.MMirc.names[channel]) > maxNamesPerPost {
|
||||
b.Send(
|
||||
b.ircNick,
|
||||
b.formatnicks(b.MMirc.names[channel][0:maxNamesPerPost], continued),
|
||||
b.getMMChannel(channel))
|
||||
b.MMirc.names[channel] = b.MMirc.names[channel][maxNamesPerPost:]
|
||||
continued = true
|
||||
}
|
||||
b.Send(b.ircNick, b.formatnicks(b.MMirc.names[channel], continued), b.getMMChannel(channel))
|
||||
b.MMirc.names[channel] = nil
|
||||
}
|
||||
|
||||
func (b *Bridge) handleTopicWhoTime(event *irc.Event) {
|
||||
parts := strings.Split(event.Arguments[2], "!")
|
||||
t, err := strconv.ParseInt(event.Arguments[3], 10, 64)
|
||||
if err != nil {
|
||||
flog.irc.Errorf("Invalid time stamp: %s", event.Arguments[3])
|
||||
}
|
||||
user := parts[0]
|
||||
if len(parts) > 1 {
|
||||
user += " [" + parts[1] + "]"
|
||||
}
|
||||
flog.irc.Infof("%s: Topic set by %s [%s]", event.Code, user, time.Unix(t, 0))
|
||||
}
|
||||
|
||||
func (b *Bridge) handleOther(event *irc.Event) {
|
||||
flog.irc.Debugf("%#v", event)
|
||||
}
|
||||
|
||||
func (b *Bridge) Send(nick string, message string, channel string) error {
|
||||
return b.SendType(nick, message, channel, "")
|
||||
}
|
||||
|
||||
func (b *Bridge) SendType(nick string, message string, channel string, mtype string) error {
|
||||
if b.Config.Mattermost.PrefixMessagesWithNick {
|
||||
if IsMarkup(message) {
|
||||
message = nick + "\n\n" + message
|
||||
} else {
|
||||
message = nick + " " + message
|
||||
}
|
||||
}
|
||||
if b.kind == Legacy {
|
||||
matterMessage := matterhook.OMessage{IconURL: b.Config.Mattermost.IconURL}
|
||||
matterMessage.Channel = channel
|
||||
matterMessage.UserName = nick
|
||||
matterMessage.Type = mtype
|
||||
matterMessage.Text = message
|
||||
err := b.mh.Send(matterMessage)
|
||||
if err != nil {
|
||||
flog.mm.Info(err)
|
||||
return err
|
||||
}
|
||||
flog.mm.Debug("->mattermost channel: ", channel, " ", message)
|
||||
return nil
|
||||
}
|
||||
flog.mm.Debug("->mattermost channel: ", channel, " ", message)
|
||||
b.mc.PostMessage(channel, message)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *Bridge) handleMatterHook(mchan chan *MMMessage) {
|
||||
for {
|
||||
message := b.mh.Receive()
|
||||
flog.mm.Debugf("receiving from matterhook %#v", message)
|
||||
m := &MMMessage{}
|
||||
m.Username = message.UserName
|
||||
m.Text = message.Text
|
||||
m.Channel = message.ChannelName
|
||||
mchan <- m
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Bridge) handleMatterClient(mchan chan *MMMessage) {
|
||||
for message := range b.mc.MessageChan {
|
||||
// do not post our own messages back to irc
|
||||
if message.Raw.Action == "posted" && b.mc.User.Username != message.Username {
|
||||
flog.mm.Debugf("receiving from matterclient %#v", message)
|
||||
m := &MMMessage{}
|
||||
m.Username = message.Username
|
||||
m.Channel = message.Channel
|
||||
m.Text = message.Text
|
||||
mchan <- m
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Bridge) handleMatter() {
|
||||
flog.mm.Infof("Choosing Mattermost connection type %s", b.kind)
|
||||
mchan := make(chan *MMMessage)
|
||||
if b.kind == Legacy {
|
||||
go b.handleMatterHook(mchan)
|
||||
} else {
|
||||
go b.handleMatterClient(mchan)
|
||||
}
|
||||
flog.mm.Info("Start listening for Mattermost messages")
|
||||
for message := range mchan {
|
||||
var username string
|
||||
if b.ignoreMessage(message.Username, message.Text, "mattermost") {
|
||||
continue
|
||||
}
|
||||
username = message.Username + ": "
|
||||
if b.Config.IRC.RemoteNickFormat != "" {
|
||||
username = strings.Replace(b.Config.IRC.RemoteNickFormat, "{NICK}", message.Username, -1)
|
||||
}
|
||||
cmds := strings.Fields(message.Text)
|
||||
// empty message
|
||||
if len(cmds) == 0 {
|
||||
continue
|
||||
}
|
||||
cmd := cmds[0]
|
||||
switch cmd {
|
||||
case "!users":
|
||||
flog.mm.Info("Received !users from ", message.Username)
|
||||
b.i.SendRaw("NAMES " + b.getIRCChannel(message.Channel))
|
||||
continue
|
||||
case "!gif":
|
||||
message.Text = b.giphyRandom(strings.Fields(strings.Replace(message.Text, "!gif ", "", 1)))
|
||||
b.Send(b.ircNick, message.Text, b.getIRCChannel(message.Channel))
|
||||
continue
|
||||
}
|
||||
texts := strings.Split(message.Text, "\n")
|
||||
for _, text := range texts {
|
||||
flog.mm.Debug("Sending message from " + message.Username + " to " + message.Channel)
|
||||
b.i.Privmsg(b.getIRCChannel(message.Channel), username+text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Bridge) giphyRandom(query []string) string {
|
||||
g := giphy.DefaultClient
|
||||
if b.Config.General.GiphyAPIKey != "" {
|
||||
g.APIKey = b.Config.General.GiphyAPIKey
|
||||
}
|
||||
res, err := g.Random(query)
|
||||
if err != nil {
|
||||
return "error"
|
||||
}
|
||||
return res.Data.FixedHeightDownsampledURL
|
||||
}
|
||||
|
||||
func (b *Bridge) getMMChannel(ircChannel string) string {
|
||||
mmChannel := b.ircMap[ircChannel]
|
||||
if b.kind == Legacy {
|
||||
return mmChannel
|
||||
}
|
||||
return b.mc.GetChannelId(mmChannel, "")
|
||||
}
|
||||
|
||||
func (b *Bridge) getIRCChannel(mmChannel string) string {
|
||||
return b.mmMap[mmChannel]
|
||||
}
|
||||
|
||||
func (b *Bridge) ignoreMessage(nick string, message string, protocol string) bool {
|
||||
var ignoreNicks = b.mmIgnoreNicks
|
||||
if protocol == "irc" {
|
||||
ignoreNicks = b.ircIgnoreNicks
|
||||
}
|
||||
// should we discard messages ?
|
||||
for _, entry := range ignoreNicks {
|
||||
if nick == entry {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
61
bridge/config.go
Normal file
61
bridge/config.go
Normal file
@ -0,0 +1,61 @@
|
||||
package bridge
|
||||
|
||||
import (
|
||||
"gopkg.in/gcfg.v1"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
IRC struct {
|
||||
UseTLS bool
|
||||
UseSASL bool
|
||||
SkipTLSVerify bool
|
||||
Server string
|
||||
Nick string
|
||||
Password string
|
||||
Channel string
|
||||
NickServNick string
|
||||
NickServPassword string
|
||||
RemoteNickFormat string
|
||||
IgnoreNicks string
|
||||
}
|
||||
Mattermost struct {
|
||||
URL string
|
||||
ShowJoinPart bool
|
||||
IconURL string
|
||||
SkipTLSVerify bool
|
||||
BindAddress string
|
||||
Channel string
|
||||
PrefixMessagesWithNick bool
|
||||
NicksPerRow int
|
||||
NickFormatter string
|
||||
Server string
|
||||
Team string
|
||||
Login string
|
||||
Password string
|
||||
RemoteNickFormat *string
|
||||
IgnoreNicks string
|
||||
NoTLS bool
|
||||
}
|
||||
Channel map[string]*struct {
|
||||
IRC string
|
||||
Mattermost string
|
||||
}
|
||||
General struct {
|
||||
GiphyAPIKey string
|
||||
}
|
||||
}
|
||||
|
||||
func NewConfig(cfgfile string) *Config {
|
||||
var cfg Config
|
||||
content, err := ioutil.ReadFile(cfgfile)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = gcfg.ReadStringInto(&cfg, string(content))
|
||||
if err != nil {
|
||||
log.Fatal("Failed to parse "+cfgfile+":", err)
|
||||
}
|
||||
return &cfg
|
||||
}
|
59
bridge/helper.go
Normal file
59
bridge/helper.go
Normal file
@ -0,0 +1,59 @@
|
||||
package bridge
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func tableformatter(nicks []string, nicksPerRow int, continued bool) string {
|
||||
result := "|IRC users"
|
||||
if continued {
|
||||
result = "|(continued)"
|
||||
}
|
||||
for i := 0; i < 2; i++ {
|
||||
for j := 1; j <= nicksPerRow && j <= len(nicks); j++ {
|
||||
if i == 0 {
|
||||
result += "|"
|
||||
} else {
|
||||
result += ":-|"
|
||||
}
|
||||
}
|
||||
result += "\r\n|"
|
||||
}
|
||||
result += nicks[0] + "|"
|
||||
for i := 1; i < len(nicks); i++ {
|
||||
if i%nicksPerRow == 0 {
|
||||
result += "\r\n|" + nicks[i] + "|"
|
||||
} else {
|
||||
result += nicks[i] + "|"
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func plainformatter(nicks []string, nicksPerRow int) string {
|
||||
return strings.Join(nicks, ", ") + " currently on IRC"
|
||||
}
|
||||
|
||||
func IsMarkup(message string) bool {
|
||||
switch message[0] {
|
||||
case '|':
|
||||
fallthrough
|
||||
case '#':
|
||||
fallthrough
|
||||
case '_':
|
||||
fallthrough
|
||||
case '*':
|
||||
fallthrough
|
||||
case '~':
|
||||
fallthrough
|
||||
case '-':
|
||||
fallthrough
|
||||
case ':':
|
||||
fallthrough
|
||||
case '>':
|
||||
fallthrough
|
||||
case '=':
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
@ -1,39 +1,148 @@
|
||||
#This is configuration for matterbridge.
|
||||
###################################################################
|
||||
#IRC section
|
||||
###################################################################
|
||||
[IRC]
|
||||
server="irc.freenode.net"
|
||||
port=6667
|
||||
#irc server to connect to.
|
||||
#REQUIRED
|
||||
Server="irc.freenode.net:6667"
|
||||
|
||||
#Enable to use TLS connection to your irc server.
|
||||
#OPTIONAL (default false)
|
||||
UseTLS=false
|
||||
|
||||
#Enable SASL (PLAIN) authentication. (freenode requires this from eg AWS hosts)
|
||||
#It uses NickServNick and NickServPassword as login and password
|
||||
#OPTIONAL (deefault false)
|
||||
UseSASL=false
|
||||
|
||||
#Enable to not verify the certificate on your irc server. i
|
||||
#e.g. when using selfsigned certificates
|
||||
#OPTIONAL (default false)
|
||||
SkipTLSVerify=true
|
||||
nick="matterbot"
|
||||
channel="#matterbridge"
|
||||
UseSlackCircumfix=false
|
||||
#NickServNick="nickserv"
|
||||
#NickServPassword="secret"
|
||||
|
||||
#Your nick on irc.
|
||||
#REQUIRED
|
||||
Nick="matterbot"
|
||||
|
||||
#If you registered your bot with a service like Nickserv on freenode.
|
||||
#Also being used when UseSASL=true
|
||||
#OPTIONAL
|
||||
NickServNick="nickserv"
|
||||
NickServPassword="secret"
|
||||
|
||||
#RemoteNickFormat defines how Mattermost users appear on irc
|
||||
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
|
||||
#OPTIONAL (default NICK:)
|
||||
RemoteNickFormat="{NICK}: "
|
||||
|
||||
#Nicks you want to ignore.
|
||||
#Messages from those users will not be sent to mattermost.
|
||||
#OPTIONAL
|
||||
IgnoreNicks="ircspammer1 ircspammer2"
|
||||
|
||||
###################################################################
|
||||
#mattermost section
|
||||
###################################################################
|
||||
|
||||
[mattermost]
|
||||
url="http://yourdomain/hooks/yourhookkey"
|
||||
port=9999
|
||||
showjoinpart=true
|
||||
#remove token when using multiple channels!
|
||||
token=yourtokenfrommattermost
|
||||
#### Settings for webhook matterbridge.
|
||||
#### These settings will not be used when using -plus switch which doesn't use
|
||||
#### webhooks.
|
||||
|
||||
#Url is your incoming webhook url as specified in mattermost.
|
||||
#See account settings - integrations - incoming webhooks on mattermost.
|
||||
#REQUIRED
|
||||
URL="https://yourdomain/hooks/yourhookkey"
|
||||
|
||||
#Address to listen on for outgoing webhook requests from mattermost.
|
||||
#See account settings - integrations - outgoing webhooks on mattermost.
|
||||
#This setting will not be used when using -plus switch which doesn't use
|
||||
#webhooks
|
||||
#REQUIRED
|
||||
BindAddress="0.0.0.0:9999"
|
||||
|
||||
#Icon that will be showed in mattermost.
|
||||
#OPTIONAL
|
||||
IconURL="http://youricon.png"
|
||||
#SkipTLSVerify=true
|
||||
#BindAddress="0.0.0.0"
|
||||
|
||||
#### Settings for matterbridge -plus
|
||||
#### Thse settings will only be used when using the -plus switch.
|
||||
|
||||
#The mattermost hostname.
|
||||
#REQUIRED
|
||||
Server="yourmattermostserver.domain"
|
||||
|
||||
#Your team on mattermost.
|
||||
#REQUIRED
|
||||
Team="yourteam"
|
||||
|
||||
#login/pass of your bot.
|
||||
#Use a dedicated user for this and not your own!
|
||||
#REQUIRED
|
||||
Login="yourlogin"
|
||||
Password="yourpass"
|
||||
|
||||
#Disable to make a http connection to your mattermost.
|
||||
#OPTIONAL (default false)
|
||||
NoTLS=false
|
||||
|
||||
#### Shared settings for matterbridge and -plus
|
||||
|
||||
#Enable to not verify the certificate on your mattermost server.
|
||||
#e.g. when using selfsigned certificates
|
||||
#OPTIONAL (default false)
|
||||
SkipTLSVerify=true
|
||||
|
||||
#Enable to show IRC joins/parts in mattermost.
|
||||
#OPTIONAL (default false)
|
||||
ShowJoinPart=false
|
||||
|
||||
#Whether to prefix messages from IRC to mattermost with the sender's nick.
|
||||
#Useful if username overrides for incoming webhooks isn't enabled on the
|
||||
#mattermost server. If you set PrefixMessagesWithNick to true, each message
|
||||
#from IRC to Mattermost will by default be prefixed by "irc-" + nick. You can,
|
||||
#however, modify how the messages appear, by setting (and modifying) RemoteNickFormat
|
||||
#OPTIONAL (default false)
|
||||
PrefixMessagesWithNick=false
|
||||
|
||||
#RemoteNickFormat defines how IRC users appear on Mattermost.
|
||||
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
|
||||
#OPTIONAL (default irc-NICK)
|
||||
RemoteNickFormat="irc-{NICK}"
|
||||
|
||||
#how to format the list of IRC nicks when displayed in mattermost.
|
||||
#Possible options are "table" and "plain"
|
||||
#OPTIONAL (default plain)
|
||||
NickFormatter=plain
|
||||
#How many nicks to list per row for formatters that support this.
|
||||
#OPTIONAL (default 4)
|
||||
NicksPerRow=4
|
||||
|
||||
#Nicks you want to ignore. Messages from those users will not be sent to IRC.
|
||||
#OPTIONAL
|
||||
IgnoreNicks="mmbot spammer2"
|
||||
|
||||
[general]
|
||||
GiphyAPIKey=dc6zaTOxFJmzC
|
||||
|
||||
###################################################################
|
||||
#multiple channel config
|
||||
#token you can find in your outgoing webhook
|
||||
[Token "outgoingwebhooktoken1"]
|
||||
IRCChannel="#off-topic"
|
||||
MMChannel="off-topic"
|
||||
###################################################################
|
||||
#You can specify multiple channels.
|
||||
#The name is just an identifier for you.
|
||||
#REQUIRED (at least 1 channel)
|
||||
[Channel "channel1"]
|
||||
#Choose the IRC channel to send mattermost messages to.
|
||||
IRC="#off-topic"
|
||||
#Choose the mattermost channel to send IRC messages to.
|
||||
mattermost="off-topic"
|
||||
|
||||
[Token "outgoingwebhooktoken2"]
|
||||
IRCChannel="#testing"
|
||||
MMChannel="testing"
|
||||
[Channel "testchannel"]
|
||||
IRC="#testing"
|
||||
mattermost="testing"
|
||||
|
||||
###################################################################
|
||||
#general
|
||||
###################################################################
|
||||
[general]
|
||||
#request your API key on https://github.com/giphy/GiphyAPI. This is a public beta key.
|
||||
#OPTIONAL
|
||||
GiphyApiKey="dc6zaTOxFJmzC"
|
||||
|
@ -3,11 +3,11 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/42wim/matterbridge-plus/bridge"
|
||||
"github.com/42wim/matterbridge/bridge"
|
||||
log "github.com/Sirupsen/logrus"
|
||||
)
|
||||
|
||||
var Version = "0.4.2"
|
||||
var version = "0.5.0-beta2"
|
||||
|
||||
func init() {
|
||||
log.SetFormatter(&log.TextFormatter{FullTimestamp: true})
|
||||
@ -17,9 +17,10 @@ func main() {
|
||||
flagConfig := flag.String("conf", "matterbridge.conf", "config file")
|
||||
flagDebug := flag.Bool("debug", false, "enable debug")
|
||||
flagVersion := flag.Bool("version", false, "show version")
|
||||
flagPlus := flag.Bool("plus", false, "running using API instead of webhooks")
|
||||
flag.Parse()
|
||||
if *flagVersion {
|
||||
fmt.Println("Version:", Version)
|
||||
fmt.Println("version:", version)
|
||||
return
|
||||
}
|
||||
flag.Parse()
|
||||
@ -27,7 +28,11 @@ func main() {
|
||||
log.Info("enabling debug")
|
||||
log.SetLevel(log.DebugLevel)
|
||||
}
|
||||
fmt.Println("running version", Version)
|
||||
bridge.NewBridge("matterbot", bridge.NewConfig(*flagConfig), "legacy")
|
||||
fmt.Println("running version", version)
|
||||
if *flagPlus {
|
||||
bridge.NewBridge("matterbot", bridge.NewConfig(*flagConfig), "")
|
||||
} else {
|
||||
bridge.NewBridge("matterbot", bridge.NewConfig(*flagConfig), "legacy")
|
||||
}
|
||||
select {}
|
||||
}
|
||||
|
570
matterclient/matterclient.go
Normal file
570
matterclient/matterclient.go
Normal file
@ -0,0 +1,570 @@
|
||||
package matterclient
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"net/http"
|
||||
"net/http/cookiejar"
|
||||
"net/url"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/jpillora/backoff"
|
||||
"github.com/mattermost/platform/model"
|
||||
)
|
||||
|
||||
type Credentials struct {
|
||||
Login string
|
||||
Team string
|
||||
Pass string
|
||||
Server string
|
||||
NoTLS bool
|
||||
SkipTLSVerify bool
|
||||
}
|
||||
|
||||
type Message struct {
|
||||
Raw *model.Message
|
||||
Post *model.Post
|
||||
Team string
|
||||
Channel string
|
||||
Username string
|
||||
Text string
|
||||
}
|
||||
|
||||
type Team struct {
|
||||
Team *model.Team
|
||||
Id string
|
||||
Channels *model.ChannelList
|
||||
MoreChannels *model.ChannelList
|
||||
Users map[string]*model.User
|
||||
}
|
||||
|
||||
type MMClient struct {
|
||||
sync.RWMutex
|
||||
*Credentials
|
||||
Team *Team
|
||||
OtherTeams []*Team
|
||||
Client *model.Client
|
||||
WsClient *websocket.Conn
|
||||
WsQuit bool
|
||||
WsAway bool
|
||||
WsConnected bool
|
||||
User *model.User
|
||||
Users map[string]*model.User
|
||||
MessageChan chan *Message
|
||||
log *log.Entry
|
||||
}
|
||||
|
||||
func New(login, pass, team, server string) *MMClient {
|
||||
cred := &Credentials{Login: login, Pass: pass, Team: team, Server: server}
|
||||
mmclient := &MMClient{Credentials: cred, MessageChan: make(chan *Message, 100), Users: make(map[string]*model.User)}
|
||||
mmclient.log = log.WithFields(log.Fields{"module": "matterclient"})
|
||||
log.SetFormatter(&log.TextFormatter{FullTimestamp: true})
|
||||
return mmclient
|
||||
}
|
||||
|
||||
func (m *MMClient) SetLogLevel(level string) {
|
||||
l, err := log.ParseLevel(level)
|
||||
if err != nil {
|
||||
log.SetLevel(log.InfoLevel)
|
||||
return
|
||||
}
|
||||
log.SetLevel(l)
|
||||
}
|
||||
|
||||
func (m *MMClient) Login() error {
|
||||
m.WsConnected = false
|
||||
if m.WsQuit {
|
||||
return nil
|
||||
}
|
||||
b := &backoff.Backoff{
|
||||
Min: time.Second,
|
||||
Max: 5 * time.Minute,
|
||||
Jitter: true,
|
||||
}
|
||||
uriScheme := "https://"
|
||||
wsScheme := "wss://"
|
||||
if m.NoTLS {
|
||||
uriScheme = "http://"
|
||||
wsScheme = "ws://"
|
||||
}
|
||||
// login to mattermost
|
||||
m.Client = model.NewClient(uriScheme + m.Credentials.Server)
|
||||
m.Client.HttpClient.Transport = &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: m.SkipTLSVerify}}
|
||||
var myinfo *model.Result
|
||||
var appErr *model.AppError
|
||||
var logmsg = "trying login"
|
||||
for {
|
||||
m.log.Debugf("%s %s %s %s", logmsg, m.Credentials.Team, m.Credentials.Login, m.Credentials.Server)
|
||||
if strings.Contains(m.Credentials.Pass, model.SESSION_COOKIE_TOKEN) {
|
||||
m.log.Debugf(logmsg+" with %s", model.SESSION_COOKIE_TOKEN)
|
||||
token := strings.Split(m.Credentials.Pass, model.SESSION_COOKIE_TOKEN+"=")
|
||||
if len(token) != 2 {
|
||||
return errors.New("incorrect MMAUTHTOKEN. valid input is MMAUTHTOKEN=yourtoken")
|
||||
}
|
||||
m.Client.HttpClient.Jar = m.createCookieJar(token[1])
|
||||
m.Client.MockSession(token[1])
|
||||
myinfo, appErr = m.Client.GetMe("")
|
||||
if appErr != nil {
|
||||
return errors.New(appErr.DetailedError)
|
||||
}
|
||||
if myinfo.Data.(*model.User) == nil {
|
||||
m.log.Errorf("LOGIN TOKEN: %s is invalid", m.Credentials.Pass)
|
||||
return errors.New("invalid " + model.SESSION_COOKIE_TOKEN)
|
||||
}
|
||||
} else {
|
||||
myinfo, appErr = m.Client.Login(m.Credentials.Login, m.Credentials.Pass)
|
||||
}
|
||||
if appErr != nil {
|
||||
d := b.Duration()
|
||||
m.log.Debug(appErr.DetailedError)
|
||||
if !strings.Contains(appErr.DetailedError, "connection refused") &&
|
||||
!strings.Contains(appErr.DetailedError, "invalid character") {
|
||||
if appErr.Message == "" {
|
||||
return errors.New(appErr.DetailedError)
|
||||
}
|
||||
return errors.New(appErr.Message)
|
||||
}
|
||||
m.log.Debugf("LOGIN: %s, reconnecting in %s", appErr, d)
|
||||
time.Sleep(d)
|
||||
logmsg = "retrying login"
|
||||
continue
|
||||
}
|
||||
break
|
||||
}
|
||||
// reset timer
|
||||
b.Reset()
|
||||
|
||||
err := m.initUser()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if m.Team == nil {
|
||||
return errors.New("team not found")
|
||||
}
|
||||
// set our team id as default route
|
||||
m.Client.SetTeamId(m.Team.Id)
|
||||
|
||||
// setup websocket connection
|
||||
wsurl := wsScheme + m.Credentials.Server + "/api/v3/users/websocket"
|
||||
header := http.Header{}
|
||||
header.Set(model.HEADER_AUTH, "BEARER "+m.Client.AuthToken)
|
||||
|
||||
m.log.Debug("WsClient: making connection")
|
||||
for {
|
||||
wsDialer := &websocket.Dialer{Proxy: http.ProxyFromEnvironment, TLSClientConfig: &tls.Config{InsecureSkipVerify: m.SkipTLSVerify}}
|
||||
m.WsClient, _, err = wsDialer.Dial(wsurl, header)
|
||||
if err != nil {
|
||||
d := b.Duration()
|
||||
m.log.Debugf("WSS: %s, reconnecting in %s", err, d)
|
||||
time.Sleep(d)
|
||||
continue
|
||||
}
|
||||
break
|
||||
}
|
||||
b.Reset()
|
||||
|
||||
// only start to parse WS messages when login is completely done
|
||||
m.WsConnected = true
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MMClient) Logout() error {
|
||||
m.log.Debugf("logout as %s (team: %s) on %s", m.Credentials.Login, m.Credentials.Team, m.Credentials.Server)
|
||||
m.WsQuit = true
|
||||
m.WsClient.Close()
|
||||
m.WsClient.UnderlyingConn().Close()
|
||||
m.WsClient = nil
|
||||
_, err := m.Client.Logout()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MMClient) WsReceiver() {
|
||||
for {
|
||||
var rmsg model.Message
|
||||
if m.WsQuit {
|
||||
m.log.Debug("exiting WsReceiver")
|
||||
return
|
||||
}
|
||||
if err := m.WsClient.ReadJSON(&rmsg); err != nil {
|
||||
m.log.Error("error:", err)
|
||||
// reconnect
|
||||
m.Login()
|
||||
}
|
||||
// we're not fully logged in yet.
|
||||
if !m.WsConnected {
|
||||
continue
|
||||
}
|
||||
if rmsg.Action == "ping" {
|
||||
m.handleWsPing()
|
||||
continue
|
||||
}
|
||||
msg := &Message{Raw: &rmsg, Team: m.Credentials.Team}
|
||||
m.parseMessage(msg)
|
||||
m.MessageChan <- msg
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (m *MMClient) handleWsPing() {
|
||||
m.log.Debug("Ws PING")
|
||||
if !m.WsQuit && !m.WsAway {
|
||||
m.log.Debug("Ws PONG")
|
||||
m.WsClient.WriteMessage(websocket.PongMessage, []byte{})
|
||||
}
|
||||
}
|
||||
|
||||
func (m *MMClient) parseMessage(rmsg *Message) {
|
||||
switch rmsg.Raw.Action {
|
||||
case model.ACTION_POSTED:
|
||||
m.parseActionPost(rmsg)
|
||||
/*
|
||||
case model.ACTION_USER_REMOVED:
|
||||
m.handleWsActionUserRemoved(&rmsg)
|
||||
case model.ACTION_USER_ADDED:
|
||||
m.handleWsActionUserAdded(&rmsg)
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
func (m *MMClient) parseActionPost(rmsg *Message) {
|
||||
data := model.PostFromJson(strings.NewReader(rmsg.Raw.Props["post"]))
|
||||
// we don't have the user, refresh the userlist
|
||||
if m.GetUser(data.UserId) == nil {
|
||||
m.UpdateUsers()
|
||||
}
|
||||
rmsg.Username = m.GetUser(data.UserId).Username
|
||||
rmsg.Channel = m.GetChannelName(data.ChannelId)
|
||||
rmsg.Team = m.GetTeamName(rmsg.Raw.TeamId)
|
||||
// direct message
|
||||
if data.Type == "D" {
|
||||
rmsg.Channel = m.GetUser(data.UserId).Username
|
||||
}
|
||||
rmsg.Text = data.Message
|
||||
rmsg.Post = data
|
||||
return
|
||||
}
|
||||
|
||||
func (m *MMClient) UpdateUsers() error {
|
||||
mmusers, _ := m.Client.GetProfilesForDirectMessageList(m.Team.Id)
|
||||
m.Lock()
|
||||
m.Users = mmusers.Data.(map[string]*model.User)
|
||||
m.Unlock()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MMClient) UpdateChannels() error {
|
||||
mmchannels, _ := m.Client.GetChannels("")
|
||||
mmchannels2, _ := m.Client.GetMoreChannels("")
|
||||
m.Lock()
|
||||
m.Team.Channels = mmchannels.Data.(*model.ChannelList)
|
||||
m.Team.MoreChannels = mmchannels2.Data.(*model.ChannelList)
|
||||
m.Unlock()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MMClient) GetChannelName(channelId string) string {
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
for _, t := range m.OtherTeams {
|
||||
for _, channel := range append(t.Channels.Channels, t.MoreChannels.Channels...) {
|
||||
if channel.Id == channelId {
|
||||
return channel.Name
|
||||
}
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MMClient) GetChannelId(name string, teamId string) string {
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
if teamId == "" {
|
||||
teamId = m.Team.Id
|
||||
}
|
||||
for _, t := range m.OtherTeams {
|
||||
if t.Id == teamId {
|
||||
for _, channel := range append(t.Channels.Channels, t.MoreChannels.Channels...) {
|
||||
if channel.Name == name {
|
||||
return channel.Id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MMClient) GetChannelHeader(channelId string) string {
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
for _, t := range m.OtherTeams {
|
||||
for _, channel := range append(t.Channels.Channels, t.MoreChannels.Channels...) {
|
||||
if channel.Id == channelId {
|
||||
return channel.Header
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MMClient) PostMessage(channelId string, text string) {
|
||||
post := &model.Post{ChannelId: channelId, Message: text}
|
||||
m.Client.CreatePost(post)
|
||||
}
|
||||
|
||||
func (m *MMClient) JoinChannel(channelId string) error {
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
for _, c := range m.Team.Channels.Channels {
|
||||
if c.Id == channelId {
|
||||
m.log.Debug("Not joining ", channelId, " already joined.")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
m.log.Debug("Joining ", channelId)
|
||||
_, err := m.Client.JoinChannel(channelId)
|
||||
if err != nil {
|
||||
return errors.New("failed to join")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MMClient) GetPostsSince(channelId string, time int64) *model.PostList {
|
||||
res, err := m.Client.GetPostsSince(channelId, time)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return res.Data.(*model.PostList)
|
||||
}
|
||||
|
||||
func (m *MMClient) SearchPosts(query string) *model.PostList {
|
||||
res, err := m.Client.SearchPosts(query, false)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return res.Data.(*model.PostList)
|
||||
}
|
||||
|
||||
func (m *MMClient) GetPosts(channelId string, limit int) *model.PostList {
|
||||
res, err := m.Client.GetPosts(channelId, 0, limit, "")
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return res.Data.(*model.PostList)
|
||||
}
|
||||
|
||||
func (m *MMClient) GetPublicLink(filename string) string {
|
||||
res, err := m.Client.GetPublicLink(filename)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return res.Data.(string)
|
||||
}
|
||||
|
||||
func (m *MMClient) GetPublicLinks(filenames []string) []string {
|
||||
var output []string
|
||||
for _, f := range filenames {
|
||||
res, err := m.Client.GetPublicLink(f)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
output = append(output, res.Data.(string))
|
||||
}
|
||||
return output
|
||||
}
|
||||
|
||||
func (m *MMClient) UpdateChannelHeader(channelId string, header string) {
|
||||
data := make(map[string]string)
|
||||
data["channel_id"] = channelId
|
||||
data["channel_header"] = header
|
||||
m.log.Debugf("updating channelheader %#v, %#v", channelId, header)
|
||||
_, err := m.Client.UpdateChannelHeader(data)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *MMClient) UpdateLastViewed(channelId string) {
|
||||
m.log.Debugf("posting lastview %#v", channelId)
|
||||
_, err := m.Client.UpdateLastViewedAt(channelId)
|
||||
if err != nil {
|
||||
m.log.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *MMClient) UsernamesInChannel(channelId string) []string {
|
||||
ceiRes, err := m.Client.GetChannelExtraInfo(channelId, 5000, "")
|
||||
if err != nil {
|
||||
m.log.Errorf("UsernamesInChannel(%s) failed: %s", channelId, err)
|
||||
return []string{}
|
||||
}
|
||||
extra := ceiRes.Data.(*model.ChannelExtra)
|
||||
result := []string{}
|
||||
for _, member := range extra.Members {
|
||||
result = append(result, member.Username)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func (m *MMClient) createCookieJar(token string) *cookiejar.Jar {
|
||||
var cookies []*http.Cookie
|
||||
jar, _ := cookiejar.New(nil)
|
||||
firstCookie := &http.Cookie{
|
||||
Name: "MMAUTHTOKEN",
|
||||
Value: token,
|
||||
Path: "/",
|
||||
Domain: m.Credentials.Server,
|
||||
}
|
||||
cookies = append(cookies, firstCookie)
|
||||
cookieURL, _ := url.Parse("https://" + m.Credentials.Server)
|
||||
jar.SetCookies(cookieURL, cookies)
|
||||
return jar
|
||||
}
|
||||
|
||||
// SendDirectMessage sends a direct message to specified user
|
||||
func (m *MMClient) SendDirectMessage(toUserId string, msg string) {
|
||||
m.log.Debugf("SendDirectMessage to %s, msg %s", toUserId, msg)
|
||||
// create DM channel (only happens on first message)
|
||||
_, err := m.Client.CreateDirectChannel(toUserId)
|
||||
if err != nil {
|
||||
m.log.Debugf("SendDirectMessage to %#v failed: %s", toUserId, err)
|
||||
}
|
||||
channelName := model.GetDMNameFromIds(toUserId, m.User.Id)
|
||||
|
||||
// update our channels
|
||||
mmchannels, _ := m.Client.GetChannels("")
|
||||
m.Lock()
|
||||
m.Team.Channels = mmchannels.Data.(*model.ChannelList)
|
||||
m.Unlock()
|
||||
|
||||
// build & send the message
|
||||
msg = strings.Replace(msg, "\r", "", -1)
|
||||
post := &model.Post{ChannelId: m.GetChannelId(channelName, ""), Message: msg}
|
||||
m.Client.CreatePost(post)
|
||||
}
|
||||
|
||||
// GetTeamName returns the name of the specified teamId
|
||||
func (m *MMClient) GetTeamName(teamId string) string {
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
for _, t := range m.OtherTeams {
|
||||
if t.Id == teamId {
|
||||
return t.Team.Name
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// GetChannels returns all channels we're members off
|
||||
func (m *MMClient) GetChannels() []*model.Channel {
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
var channels []*model.Channel
|
||||
// our primary team channels first
|
||||
channels = append(channels, m.Team.Channels.Channels...)
|
||||
for _, t := range m.OtherTeams {
|
||||
if t.Id != m.Team.Id {
|
||||
channels = append(channels, t.Channels.Channels...)
|
||||
}
|
||||
}
|
||||
return channels
|
||||
}
|
||||
|
||||
// GetMoreChannels returns existing channels where we're not a member off.
|
||||
func (m *MMClient) GetMoreChannels() []*model.Channel {
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
var channels []*model.Channel
|
||||
for _, t := range m.OtherTeams {
|
||||
channels = append(channels, t.MoreChannels.Channels...)
|
||||
}
|
||||
return channels
|
||||
}
|
||||
|
||||
// GetTeamFromChannel returns teamId belonging to channel (DM channels have no teamId).
|
||||
func (m *MMClient) GetTeamFromChannel(channelId string) string {
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
var channels []*model.Channel
|
||||
for _, t := range m.OtherTeams {
|
||||
channels = append(channels, t.Channels.Channels...)
|
||||
for _, c := range channels {
|
||||
if c.Id == channelId {
|
||||
return t.Id
|
||||
}
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MMClient) GetLastViewedAt(channelId string) int64 {
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
for _, t := range m.OtherTeams {
|
||||
if _, ok := t.Channels.Members[channelId]; ok {
|
||||
return t.Channels.Members[channelId].LastViewedAt
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MMClient) GetUsers() map[string]*model.User {
|
||||
users := make(map[string]*model.User)
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
for k, v := range m.Users {
|
||||
users[k] = v
|
||||
}
|
||||
return users
|
||||
}
|
||||
|
||||
func (m *MMClient) GetUser(userId string) *model.User {
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
return m.Users[userId]
|
||||
}
|
||||
|
||||
// initialize user and teams
|
||||
func (m *MMClient) initUser() error {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
m.log.Debug("initUser()")
|
||||
initLoad, err := m.Client.GetInitialLoad()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
initData := initLoad.Data.(*model.InitialLoad)
|
||||
m.User = initData.User
|
||||
// we only load all team data on initial login.
|
||||
// all other updates are for channels from our (primary) team only.
|
||||
m.log.Debug("initUser(): loading all team data")
|
||||
for _, v := range initData.Teams {
|
||||
m.Client.SetTeamId(v.Id)
|
||||
mmusers, _ := m.Client.GetProfiles(v.Id, "")
|
||||
t := &Team{Team: v, Users: mmusers.Data.(map[string]*model.User), Id: v.Id}
|
||||
mmchannels, _ := m.Client.GetChannels("")
|
||||
t.Channels = mmchannels.Data.(*model.ChannelList)
|
||||
mmchannels, _ = m.Client.GetMoreChannels("")
|
||||
t.MoreChannels = mmchannels.Data.(*model.ChannelList)
|
||||
m.OtherTeams = append(m.OtherTeams, t)
|
||||
if v.Name == m.Credentials.Team {
|
||||
m.Team = t
|
||||
m.log.Debugf("initUser(): found our team %s (id: %s)", v.Name, v.Id)
|
||||
}
|
||||
// add all users
|
||||
for k, v := range t.Users {
|
||||
m.Users[k] = v
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
@ -10,8 +10,8 @@ import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// OMessage for mattermost incoming webhook. (send to mattermost)
|
||||
@ -51,7 +51,6 @@ type Client struct {
|
||||
|
||||
// Config for client.
|
||||
type Config struct {
|
||||
Port int // Port to listen on.
|
||||
BindAddress string // Address to listen on
|
||||
Token string // Only allow this token from Mattermost. (Allow everything when empty)
|
||||
InsecureSkipVerify bool // disable certificate checking
|
||||
@ -61,15 +60,15 @@ type Config struct {
|
||||
// New Mattermost client.
|
||||
func New(url string, config Config) *Client {
|
||||
c := &Client{Url: url, In: make(chan IMessage), Out: make(chan OMessage), Config: config}
|
||||
if c.Port == 0 {
|
||||
c.Port = 9999
|
||||
}
|
||||
c.BindAddress += ":"
|
||||
tr := &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify},
|
||||
}
|
||||
c.httpclient = &http.Client{Transport: tr}
|
||||
if !c.DisableServer {
|
||||
_, _, err := net.SplitHostPort(c.BindAddress)
|
||||
if err != nil {
|
||||
log.Fatalf("incorrect bindaddress %s", c.BindAddress)
|
||||
}
|
||||
go c.StartServer()
|
||||
}
|
||||
return c
|
||||
@ -79,8 +78,8 @@ func New(url string, config Config) *Client {
|
||||
func (c *Client) StartServer() {
|
||||
mux := http.NewServeMux()
|
||||
mux.Handle("/", c)
|
||||
log.Printf("Listening on http://%v:%v...\n", c.BindAddress, c.Port)
|
||||
if err := http.ListenAndServe((c.BindAddress + strconv.Itoa(c.Port)), mux); err != nil {
|
||||
log.Printf("Listening on http://%v...\n", c.BindAddress)
|
||||
if err := http.ListenAndServe(c.BindAddress, mux); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
50
migration.md
Normal file
50
migration.md
Normal file
@ -0,0 +1,50 @@
|
||||
# Breaking changes from 0.4 to 0.5 for matterbridge (webhooks version)
|
||||
## IRC section
|
||||
### Server
|
||||
Port removed, added to server
|
||||
```
|
||||
server="irc.freenode.net"
|
||||
port=6667
|
||||
```
|
||||
changed to
|
||||
```
|
||||
server="irc.freenode.net:6667"
|
||||
```
|
||||
### Channel
|
||||
Removed see Channels section below
|
||||
|
||||
### UseSlackCircumfix=true
|
||||
Removed, can be done by using ```RemoteNickFormat="<{NICK}> "```
|
||||
|
||||
## Mattermost section
|
||||
### BindAddress
|
||||
Port removed, added to BindAddress
|
||||
|
||||
```
|
||||
BindAddress="0.0.0.0"
|
||||
port=9999
|
||||
```
|
||||
|
||||
changed to
|
||||
|
||||
```
|
||||
BindAddress="0.0.0.0:9999"
|
||||
```
|
||||
|
||||
### Token
|
||||
Removed
|
||||
|
||||
## Channels section
|
||||
```
|
||||
[Token "outgoingwebhooktoken1"]
|
||||
IRCChannel="#off-topic"
|
||||
MMChannel="off-topic"
|
||||
```
|
||||
|
||||
changed to
|
||||
|
||||
```
|
||||
[Channel "channelnameofchoice"]
|
||||
IRC="#off-topic"
|
||||
Mattermost="off-topic"
|
||||
```
|
22
vendor/github.com/mattermost/platform/einterfaces/emoji.go
generated
vendored
Normal file
22
vendor/github.com/mattermost/platform/einterfaces/emoji.go
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
package einterfaces
|
||||
|
||||
import (
|
||||
"github.com/mattermost/platform/model"
|
||||
)
|
||||
|
||||
type EmojiInterface interface {
|
||||
CanUserCreateEmoji(string, []*model.TeamMember) bool
|
||||
}
|
||||
|
||||
var theEmojiInterface EmojiInterface
|
||||
|
||||
func RegisterEmojiInterface(newInterface EmojiInterface) {
|
||||
theEmojiInterface = newInterface
|
||||
}
|
||||
|
||||
func GetEmojiInterface() EmojiInterface {
|
||||
return theEmojiInterface
|
||||
}
|
25
vendor/github.com/mattermost/platform/einterfaces/saml.go
generated
vendored
Normal file
25
vendor/github.com/mattermost/platform/einterfaces/saml.go
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
package einterfaces
|
||||
|
||||
import (
|
||||
"github.com/mattermost/platform/model"
|
||||
)
|
||||
|
||||
type SamlInterface interface {
|
||||
ConfigureSP() *model.AppError
|
||||
BuildRequest(relayState string) (*model.SamlAuthRequest, *model.AppError)
|
||||
DoLogin(encodedXML string, relayState map[string]string) (*model.User, *model.AppError)
|
||||
GetMetadata() (string, *model.AppError)
|
||||
}
|
||||
|
||||
var theSamlInterface SamlInterface
|
||||
|
||||
func RegisterSamlInterface(newInterface SamlInterface) {
|
||||
theSamlInterface = newInterface
|
||||
}
|
||||
|
||||
func GetSamlInterface() SamlInterface {
|
||||
return theSamlInterface
|
||||
}
|
143
vendor/github.com/mattermost/platform/model/client.go
generated
vendored
143
vendor/github.com/mattermost/platform/model/client.go
generated
vendored
@ -7,7 +7,9 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
@ -106,6 +108,10 @@ func (c *Client) GetChannelNameRoute(channelName string) string {
|
||||
return fmt.Sprintf("/teams/%v/channels/name/%v", c.GetTeamId(), channelName)
|
||||
}
|
||||
|
||||
func (c *Client) GetEmojiRoute() string {
|
||||
return "/emoji"
|
||||
}
|
||||
|
||||
func (c *Client) GetGeneralRoute() string {
|
||||
return "/general"
|
||||
}
|
||||
@ -185,6 +191,17 @@ func (c *Client) Must(result *Result, err *AppError) *Result {
|
||||
return result
|
||||
}
|
||||
|
||||
// MustGeneric is a convenience function used for testing.
|
||||
func (c *Client) MustGeneric(result interface{}, err *AppError) interface{} {
|
||||
if err != nil {
|
||||
l4g.Close()
|
||||
time.Sleep(time.Second)
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// CheckStatusOK is a convenience function for checking the return of Web Service
|
||||
// call that return the a map of status=OK.
|
||||
func (c *Client) CheckStatusOK(r *http.Response) bool {
|
||||
@ -328,10 +345,18 @@ func (c *Client) FindTeamByName(name string) (*Result, *AppError) {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) AddUserToTeam(userId string) (*Result, *AppError) {
|
||||
// Adds a user directly to the team without sending an invite.
|
||||
// The teamId and userId are required. You must be a valid member of the team and/or
|
||||
// have the correct role to add new users to the team. Returns a map of user_id=userId
|
||||
// if successful, otherwise returns an AppError.
|
||||
func (c *Client) AddUserToTeam(teamId string, userId string) (*Result, *AppError) {
|
||||
if len(teamId) == 0 {
|
||||
teamId = c.GetTeamId()
|
||||
}
|
||||
|
||||
data := make(map[string]string)
|
||||
data["user_id"] = userId
|
||||
if r, err := c.DoApiPost(c.GetTeamRoute()+"/add_user_to_team", MapToJson(data)); err != nil {
|
||||
if r, err := c.DoApiPost(fmt.Sprintf("/teams/%v", teamId)+"/add_user_to_team", MapToJson(data)); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
@ -354,6 +379,26 @@ func (c *Client) AddUserToTeamFromInvite(hash, dataToHash, inviteId string) (*Re
|
||||
}
|
||||
}
|
||||
|
||||
// Removes a user directly from the team.
|
||||
// The teamId and userId are required. You must be a valid member of the team and/or
|
||||
// have the correct role to remove a user from the team. Returns a map of user_id=userId
|
||||
// if successful, otherwise returns an AppError.
|
||||
func (c *Client) RemoveUserFromTeam(teamId string, userId string) (*Result, *AppError) {
|
||||
if len(teamId) == 0 {
|
||||
teamId = c.GetTeamId()
|
||||
}
|
||||
|
||||
data := make(map[string]string)
|
||||
data["user_id"] = userId
|
||||
if r, err := c.DoApiPost(fmt.Sprintf("/teams/%v", teamId)+"/remove_user_from_team", MapToJson(data)); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return &Result{r.Header.Get(HEADER_REQUEST_ID),
|
||||
r.Header.Get(HEADER_ETAG_SERVER), MapFromJson(r.Body)}, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) InviteMembers(invites *Invites) (*Result, *AppError) {
|
||||
if r, err := c.DoApiPost(c.GetTeamRoute()+"/invite_members", invites.ToJson()); err != nil {
|
||||
return nil, err
|
||||
@ -843,6 +888,20 @@ func (c *Client) GetSystemAnalytics(name string) (*Result, *AppError) {
|
||||
}
|
||||
}
|
||||
|
||||
// Initiate immediate synchronization of LDAP users.
|
||||
// The synchronization will be performed asynchronously and this function will
|
||||
// always return OK unless you don't have permissions.
|
||||
// You must be the system administrator to use this function.
|
||||
func (c *Client) LdapSyncNow() (*Result, *AppError) {
|
||||
if r, err := c.DoApiPost("/admin/ldap_sync_now", ""); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return &Result{r.Header.Get(HEADER_REQUEST_ID),
|
||||
r.Header.Get(HEADER_ETAG_SERVER), MapFromJson(r.Body)}, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) CreateChannel(channel *Channel) (*Result, *AppError) {
|
||||
if r, err := c.DoApiPost(c.GetTeamRoute()+"/channels/create", channel.ToJson()); err != nil {
|
||||
return nil, err
|
||||
@ -949,6 +1008,7 @@ func (c *Client) JoinChannel(id string) (*Result, *AppError) {
|
||||
if r, err := c.DoApiPost(c.GetChannelRoute(id)+"/join", ""); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return &Result{r.Header.Get(HEADER_REQUEST_ID),
|
||||
r.Header.Get(HEADER_ETAG_SERVER), nil}, nil
|
||||
}
|
||||
@ -958,6 +1018,7 @@ func (c *Client) JoinChannelByName(name string) (*Result, *AppError) {
|
||||
if r, err := c.DoApiPost(c.GetChannelNameRoute(name)+"/join", ""); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return &Result{r.Header.Get(HEADER_REQUEST_ID),
|
||||
r.Header.Get(HEADER_ETAG_SERVER), nil}, nil
|
||||
}
|
||||
@ -967,6 +1028,7 @@ func (c *Client) LeaveChannel(id string) (*Result, *AppError) {
|
||||
if r, err := c.DoApiPost(c.GetChannelRoute(id)+"/leave", ""); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return &Result{r.Header.Get(HEADER_REQUEST_ID),
|
||||
r.Header.Get(HEADER_ETAG_SERVER), nil}, nil
|
||||
}
|
||||
@ -976,6 +1038,7 @@ func (c *Client) DeleteChannel(id string) (*Result, *AppError) {
|
||||
if r, err := c.DoApiPost(c.GetChannelRoute(id)+"/delete", ""); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return &Result{r.Header.Get(HEADER_REQUEST_ID),
|
||||
r.Header.Get(HEADER_ETAG_SERVER), nil}, nil
|
||||
}
|
||||
@ -987,6 +1050,7 @@ func (c *Client) AddChannelMember(id, user_id string) (*Result, *AppError) {
|
||||
if r, err := c.DoApiPost(c.GetChannelRoute(id)+"/add", MapToJson(data)); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return &Result{r.Header.Get(HEADER_REQUEST_ID),
|
||||
r.Header.Get(HEADER_ETAG_SERVER), nil}, nil
|
||||
}
|
||||
@ -998,6 +1062,7 @@ func (c *Client) RemoveChannelMember(id, user_id string) (*Result, *AppError) {
|
||||
if r, err := c.DoApiPost(c.GetChannelRoute(id)+"/remove", MapToJson(data)); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return &Result{r.Header.Get(HEADER_REQUEST_ID),
|
||||
r.Header.Get(HEADER_ETAG_SERVER), nil}, nil
|
||||
}
|
||||
@ -1007,6 +1072,7 @@ func (c *Client) UpdateLastViewedAt(channelId string) (*Result, *AppError) {
|
||||
if r, err := c.DoApiPost(c.GetChannelRoute(channelId)+"/update_last_viewed_at", ""); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return &Result{r.Header.Get(HEADER_REQUEST_ID),
|
||||
r.Header.Get(HEADER_ETAG_SERVER), nil}, nil
|
||||
}
|
||||
@ -1376,6 +1442,7 @@ func (c *Client) PostToWebhook(id, payload string) (*Result, *AppError) {
|
||||
if r, err := c.DoPost("/hooks/"+id, payload, "application/x-www-form-urlencoded"); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return &Result{r.Header.Get(HEADER_REQUEST_ID),
|
||||
r.Header.Get(HEADER_ETAG_SERVER), nil}, nil
|
||||
}
|
||||
@ -1417,6 +1484,7 @@ func (c *Client) SetPreferences(preferences *Preferences) (*Result, *AppError) {
|
||||
if r, err := c.DoApiPost("/preferences/save", preferences.ToJson()); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return &Result{r.Header.Get(HEADER_REQUEST_ID),
|
||||
r.Header.Get(HEADER_ETAG_SERVER), preferences}, nil
|
||||
}
|
||||
@ -1509,3 +1577,74 @@ func (c *Client) GetInitialLoad() (*Result, *AppError) {
|
||||
r.Header.Get(HEADER_ETAG_SERVER), InitialLoadFromJson(r.Body)}, nil
|
||||
}
|
||||
}
|
||||
|
||||
// ListEmoji returns a list of all user-created emoji for the server.
|
||||
func (c *Client) ListEmoji() ([]*Emoji, *AppError) {
|
||||
if r, err := c.DoApiGet(c.GetEmojiRoute()+"/list", "", ""); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
c.fillInExtraProperties(r)
|
||||
return EmojiListFromJson(r.Body), nil
|
||||
}
|
||||
}
|
||||
|
||||
// CreateEmoji will save an emoji to the server if the current user has permission
|
||||
// to do so. If successful, the provided emoji will be returned with its Id field
|
||||
// filled in. Otherwise, an error will be returned.
|
||||
func (c *Client) CreateEmoji(emoji *Emoji, image []byte, filename string) (*Emoji, *AppError) {
|
||||
c.clearExtraProperties()
|
||||
|
||||
body := &bytes.Buffer{}
|
||||
writer := multipart.NewWriter(body)
|
||||
|
||||
if part, err := writer.CreateFormFile("image", filename); err != nil {
|
||||
return nil, NewLocAppError("CreateEmoji", "model.client.create_emoji.image.app_error", nil, err.Error())
|
||||
} else if _, err = io.Copy(part, bytes.NewBuffer(image)); err != nil {
|
||||
return nil, NewLocAppError("CreateEmoji", "model.client.create_emoji.image.app_error", nil, err.Error())
|
||||
}
|
||||
|
||||
if err := writer.WriteField("emoji", emoji.ToJson()); err != nil {
|
||||
return nil, NewLocAppError("CreateEmoji", "model.client.create_emoji.emoji.app_error", nil, err.Error())
|
||||
}
|
||||
|
||||
if err := writer.Close(); err != nil {
|
||||
return nil, NewLocAppError("CreateEmoji", "model.client.create_emoji.writer.app_error", nil, err.Error())
|
||||
}
|
||||
|
||||
rq, _ := http.NewRequest("POST", c.ApiUrl+c.GetEmojiRoute()+"/create", body)
|
||||
rq.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
|
||||
if len(c.AuthToken) > 0 {
|
||||
rq.Header.Set(HEADER_AUTH, "BEARER "+c.AuthToken)
|
||||
}
|
||||
|
||||
if r, err := c.HttpClient.Do(rq); err != nil {
|
||||
return nil, NewLocAppError("CreateEmoji", "model.client.connecting.app_error", nil, err.Error())
|
||||
} else if r.StatusCode >= 300 {
|
||||
return nil, AppErrorFromJson(r.Body)
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
c.fillInExtraProperties(r)
|
||||
return EmojiFromJson(r.Body), nil
|
||||
}
|
||||
}
|
||||
|
||||
// DeleteEmoji will delete an emoji from the server if the current user has permission
|
||||
// to do so. If successful, it will return status=ok. Otherwise, an error will be returned.
|
||||
func (c *Client) DeleteEmoji(id string) (bool, *AppError) {
|
||||
data := map[string]string{"id": id}
|
||||
|
||||
if r, err := c.DoApiPost(c.GetEmojiRoute()+"/delete", MapToJson(data)); err != nil {
|
||||
return false, err
|
||||
} else {
|
||||
c.fillInExtraProperties(r)
|
||||
return c.CheckStatusOK(r), nil
|
||||
}
|
||||
}
|
||||
|
||||
// GetCustomEmojiImageUrl returns the API route that can be used to get the image used by
|
||||
// the given emoji.
|
||||
func (c *Client) GetCustomEmojiImageUrl(id string) string {
|
||||
return c.GetEmojiRoute() + "/" + id
|
||||
}
|
||||
|
321
vendor/github.com/mattermost/platform/model/config.go
generated
vendored
321
vendor/github.com/mattermost/platform/model/config.go
generated
vendored
@ -6,7 +6,6 @@ package model
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -20,6 +19,9 @@ const (
|
||||
DATABASE_DRIVER_MYSQL = "mysql"
|
||||
DATABASE_DRIVER_POSTGRES = "postgres"
|
||||
|
||||
PASSWORD_MAXIMUM_LENGTH = 64
|
||||
PASSWORD_MINIMUM_LENGTH = 5
|
||||
|
||||
SERVICE_GITLAB = "gitlab"
|
||||
SERVICE_GOOGLE = "google"
|
||||
|
||||
@ -33,17 +35,16 @@ const (
|
||||
DIRECT_MESSAGE_ANY = "any"
|
||||
DIRECT_MESSAGE_TEAM = "team"
|
||||
|
||||
FAKE_SETTING = "********************************"
|
||||
)
|
||||
PERMISSIONS_ALL = "all"
|
||||
PERMISSIONS_TEAM_ADMIN = "team_admin"
|
||||
PERMISSIONS_SYSTEM_ADMIN = "system_admin"
|
||||
|
||||
// should match the values in webapp/i18n/i18n.jsx
|
||||
var LOCALES = []string{
|
||||
"en",
|
||||
"es",
|
||||
"fr",
|
||||
"ja",
|
||||
"pt-BR",
|
||||
}
|
||||
FAKE_SETTING = "********************************"
|
||||
|
||||
RESTRICT_EMOJI_CREATION_ALL = "all"
|
||||
RESTRICT_EMOJI_CREATION_ADMIN = "admin"
|
||||
RESTRICT_EMOJI_CREATION_SYSTEM_ADMIN = "system_admin"
|
||||
)
|
||||
|
||||
type ServiceSettings struct {
|
||||
ListenAddress string
|
||||
@ -70,6 +71,8 @@ type ServiceSettings struct {
|
||||
WebsocketSecurePort *int
|
||||
WebsocketPort *int
|
||||
WebserverMode *string
|
||||
EnableCustomEmoji *bool
|
||||
RestrictCustomEmojiCreation *string
|
||||
}
|
||||
|
||||
type SSOSettings struct {
|
||||
@ -93,12 +96,21 @@ type SqlSettings struct {
|
||||
}
|
||||
|
||||
type LogSettings struct {
|
||||
EnableConsole bool
|
||||
ConsoleLevel string
|
||||
EnableFile bool
|
||||
FileLevel string
|
||||
FileFormat string
|
||||
FileLocation string
|
||||
EnableConsole bool
|
||||
ConsoleLevel string
|
||||
EnableFile bool
|
||||
FileLevel string
|
||||
FileFormat string
|
||||
FileLocation string
|
||||
EnableWebhookDebugging bool
|
||||
}
|
||||
|
||||
type PasswordSettings struct {
|
||||
MinimumLength *int
|
||||
Lowercase *bool
|
||||
Number *bool
|
||||
Uppercase *bool
|
||||
Symbol *bool
|
||||
}
|
||||
|
||||
type FileSettings struct {
|
||||
@ -132,6 +144,7 @@ type EmailSettings struct {
|
||||
RequireEmailVerification bool
|
||||
FeedbackName string
|
||||
FeedbackEmail string
|
||||
FeedbackOrganization *string
|
||||
SMTPUsername string
|
||||
SMTPPassword string
|
||||
SMTPServer string
|
||||
@ -167,16 +180,19 @@ type SupportSettings struct {
|
||||
}
|
||||
|
||||
type TeamSettings struct {
|
||||
SiteName string
|
||||
MaxUsersPerTeam int
|
||||
EnableTeamCreation bool
|
||||
EnableUserCreation bool
|
||||
EnableOpenServer *bool
|
||||
RestrictCreationToDomains string
|
||||
RestrictTeamNames *bool
|
||||
EnableCustomBrand *bool
|
||||
CustomBrandText *string
|
||||
RestrictDirectMessage *string
|
||||
SiteName string
|
||||
MaxUsersPerTeam int
|
||||
EnableTeamCreation bool
|
||||
EnableUserCreation bool
|
||||
EnableOpenServer *bool
|
||||
RestrictCreationToDomains string
|
||||
RestrictTeamNames *bool
|
||||
EnableCustomBrand *bool
|
||||
CustomBrandText *string
|
||||
RestrictDirectMessage *string
|
||||
RestrictTeamInvite *string
|
||||
RestrictPublicChannelManagement *string
|
||||
RestrictPrivateChannelManagement *string
|
||||
}
|
||||
|
||||
type LdapSettings struct {
|
||||
@ -206,6 +222,7 @@ type LdapSettings struct {
|
||||
// Advanced
|
||||
SkipCertificateVerification *bool
|
||||
QueryTimeout *int
|
||||
MaxPageSize *int
|
||||
|
||||
// Customization
|
||||
LoginFieldName *string
|
||||
@ -223,11 +240,37 @@ type LocalizationSettings struct {
|
||||
AvailableLocales *string
|
||||
}
|
||||
|
||||
type SamlSettings struct {
|
||||
// Basic
|
||||
Enable *bool
|
||||
Verify *bool
|
||||
Encrypt *bool
|
||||
|
||||
IdpUrl *string
|
||||
IdpDescriptorUrl *string
|
||||
AssertionConsumerServiceURL *string
|
||||
|
||||
IdpCertificateFile *string
|
||||
PublicCertificateFile *string
|
||||
PrivateKeyFile *string
|
||||
|
||||
// User Mapping
|
||||
FirstNameAttribute *string
|
||||
LastNameAttribute *string
|
||||
EmailAttribute *string
|
||||
UsernameAttribute *string
|
||||
NicknameAttribute *string
|
||||
LocaleAttribute *string
|
||||
|
||||
LoginButtonText *string
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
ServiceSettings ServiceSettings
|
||||
TeamSettings TeamSettings
|
||||
SqlSettings SqlSettings
|
||||
LogSettings LogSettings
|
||||
PasswordSettings PasswordSettings
|
||||
FileSettings FileSettings
|
||||
EmailSettings EmailSettings
|
||||
RateLimitSettings RateLimitSettings
|
||||
@ -238,6 +281,7 @@ type Config struct {
|
||||
LdapSettings LdapSettings
|
||||
ComplianceSettings ComplianceSettings
|
||||
LocalizationSettings LocalizationSettings
|
||||
SamlSettings SamlSettings
|
||||
}
|
||||
|
||||
func (o *Config) ToJson() string {
|
||||
@ -324,6 +368,31 @@ func (o *Config) SetDefaults() {
|
||||
*o.ServiceSettings.EnableMultifactorAuthentication = false
|
||||
}
|
||||
|
||||
if o.PasswordSettings.MinimumLength == nil {
|
||||
o.PasswordSettings.MinimumLength = new(int)
|
||||
*o.PasswordSettings.MinimumLength = PASSWORD_MINIMUM_LENGTH
|
||||
}
|
||||
|
||||
if o.PasswordSettings.Lowercase == nil {
|
||||
o.PasswordSettings.Lowercase = new(bool)
|
||||
*o.PasswordSettings.Lowercase = false
|
||||
}
|
||||
|
||||
if o.PasswordSettings.Number == nil {
|
||||
o.PasswordSettings.Number = new(bool)
|
||||
*o.PasswordSettings.Number = false
|
||||
}
|
||||
|
||||
if o.PasswordSettings.Uppercase == nil {
|
||||
o.PasswordSettings.Uppercase = new(bool)
|
||||
*o.PasswordSettings.Uppercase = false
|
||||
}
|
||||
|
||||
if o.PasswordSettings.Symbol == nil {
|
||||
o.PasswordSettings.Symbol = new(bool)
|
||||
*o.PasswordSettings.Symbol = false
|
||||
}
|
||||
|
||||
if o.TeamSettings.RestrictTeamNames == nil {
|
||||
o.TeamSettings.RestrictTeamNames = new(bool)
|
||||
*o.TeamSettings.RestrictTeamNames = true
|
||||
@ -349,6 +418,21 @@ func (o *Config) SetDefaults() {
|
||||
*o.TeamSettings.RestrictDirectMessage = DIRECT_MESSAGE_ANY
|
||||
}
|
||||
|
||||
if o.TeamSettings.RestrictTeamInvite == nil {
|
||||
o.TeamSettings.RestrictTeamInvite = new(string)
|
||||
*o.TeamSettings.RestrictTeamInvite = PERMISSIONS_ALL
|
||||
}
|
||||
|
||||
if o.TeamSettings.RestrictPublicChannelManagement == nil {
|
||||
o.TeamSettings.RestrictPublicChannelManagement = new(string)
|
||||
*o.TeamSettings.RestrictPublicChannelManagement = PERMISSIONS_ALL
|
||||
}
|
||||
|
||||
if o.TeamSettings.RestrictPrivateChannelManagement == nil {
|
||||
o.TeamSettings.RestrictPrivateChannelManagement = new(string)
|
||||
*o.TeamSettings.RestrictPrivateChannelManagement = PERMISSIONS_ALL
|
||||
}
|
||||
|
||||
if o.EmailSettings.EnableSignInWithEmail == nil {
|
||||
o.EmailSettings.EnableSignInWithEmail = new(bool)
|
||||
|
||||
@ -379,6 +463,11 @@ func (o *Config) SetDefaults() {
|
||||
*o.EmailSettings.PushNotificationContents = GENERIC_NOTIFICATION
|
||||
}
|
||||
|
||||
if o.EmailSettings.FeedbackOrganization == nil {
|
||||
o.EmailSettings.FeedbackOrganization = new(string)
|
||||
*o.EmailSettings.FeedbackOrganization = ""
|
||||
}
|
||||
|
||||
if !IsSafeLink(o.SupportSettings.TermsOfServiceLink) {
|
||||
o.SupportSettings.TermsOfServiceLink = nil
|
||||
}
|
||||
@ -484,6 +573,11 @@ func (o *Config) SetDefaults() {
|
||||
*o.LdapSettings.EmailAttribute = ""
|
||||
}
|
||||
|
||||
if o.LdapSettings.UsernameAttribute == nil {
|
||||
o.LdapSettings.UsernameAttribute = new(string)
|
||||
*o.LdapSettings.UsernameAttribute = ""
|
||||
}
|
||||
|
||||
if o.LdapSettings.NicknameAttribute == nil {
|
||||
o.LdapSettings.NicknameAttribute = new(string)
|
||||
*o.LdapSettings.NicknameAttribute = ""
|
||||
@ -509,6 +603,11 @@ func (o *Config) SetDefaults() {
|
||||
*o.LdapSettings.QueryTimeout = 60
|
||||
}
|
||||
|
||||
if o.LdapSettings.MaxPageSize == nil {
|
||||
o.LdapSettings.MaxPageSize = new(int)
|
||||
*o.LdapSettings.MaxPageSize = 0
|
||||
}
|
||||
|
||||
if o.LdapSettings.LoginFieldName == nil {
|
||||
o.LdapSettings.LoginFieldName = new(string)
|
||||
*o.LdapSettings.LoginFieldName = ""
|
||||
@ -561,7 +660,19 @@ func (o *Config) SetDefaults() {
|
||||
|
||||
if o.ServiceSettings.WebserverMode == nil {
|
||||
o.ServiceSettings.WebserverMode = new(string)
|
||||
*o.ServiceSettings.WebserverMode = "regular"
|
||||
*o.ServiceSettings.WebserverMode = "gzip"
|
||||
} else if *o.ServiceSettings.WebserverMode == "regular" {
|
||||
*o.ServiceSettings.WebserverMode = "gzip"
|
||||
}
|
||||
|
||||
if o.ServiceSettings.EnableCustomEmoji == nil {
|
||||
o.ServiceSettings.EnableCustomEmoji = new(bool)
|
||||
*o.ServiceSettings.EnableCustomEmoji = true
|
||||
}
|
||||
|
||||
if o.ServiceSettings.RestrictCustomEmojiCreation == nil {
|
||||
o.ServiceSettings.RestrictCustomEmojiCreation = new(string)
|
||||
*o.ServiceSettings.RestrictCustomEmojiCreation = RESTRICT_EMOJI_CREATION_ALL
|
||||
}
|
||||
|
||||
if o.ComplianceSettings.Enable == nil {
|
||||
@ -591,7 +702,87 @@ func (o *Config) SetDefaults() {
|
||||
|
||||
if o.LocalizationSettings.AvailableLocales == nil {
|
||||
o.LocalizationSettings.AvailableLocales = new(string)
|
||||
*o.LocalizationSettings.AvailableLocales = strings.Join(LOCALES, ",")
|
||||
*o.LocalizationSettings.AvailableLocales = ""
|
||||
}
|
||||
|
||||
if o.SamlSettings.Enable == nil {
|
||||
o.SamlSettings.Enable = new(bool)
|
||||
*o.SamlSettings.Enable = false
|
||||
}
|
||||
|
||||
if o.SamlSettings.Verify == nil {
|
||||
o.SamlSettings.Verify = new(bool)
|
||||
*o.SamlSettings.Verify = false
|
||||
}
|
||||
|
||||
if o.SamlSettings.Encrypt == nil {
|
||||
o.SamlSettings.Encrypt = new(bool)
|
||||
*o.SamlSettings.Encrypt = false
|
||||
}
|
||||
|
||||
if o.SamlSettings.IdpUrl == nil {
|
||||
o.SamlSettings.IdpUrl = new(string)
|
||||
*o.SamlSettings.IdpUrl = ""
|
||||
}
|
||||
|
||||
if o.SamlSettings.IdpDescriptorUrl == nil {
|
||||
o.SamlSettings.IdpDescriptorUrl = new(string)
|
||||
*o.SamlSettings.IdpDescriptorUrl = ""
|
||||
}
|
||||
|
||||
if o.SamlSettings.IdpCertificateFile == nil {
|
||||
o.SamlSettings.IdpCertificateFile = new(string)
|
||||
*o.SamlSettings.IdpCertificateFile = ""
|
||||
}
|
||||
|
||||
if o.SamlSettings.PublicCertificateFile == nil {
|
||||
o.SamlSettings.PublicCertificateFile = new(string)
|
||||
*o.SamlSettings.PublicCertificateFile = ""
|
||||
}
|
||||
|
||||
if o.SamlSettings.PrivateKeyFile == nil {
|
||||
o.SamlSettings.PrivateKeyFile = new(string)
|
||||
*o.SamlSettings.PrivateKeyFile = ""
|
||||
}
|
||||
|
||||
if o.SamlSettings.AssertionConsumerServiceURL == nil {
|
||||
o.SamlSettings.AssertionConsumerServiceURL = new(string)
|
||||
*o.SamlSettings.AssertionConsumerServiceURL = ""
|
||||
}
|
||||
|
||||
if o.SamlSettings.LoginButtonText == nil || *o.SamlSettings.LoginButtonText == "" {
|
||||
o.SamlSettings.LoginButtonText = new(string)
|
||||
*o.SamlSettings.LoginButtonText = USER_AUTH_SERVICE_SAML_TEXT
|
||||
}
|
||||
|
||||
if o.SamlSettings.FirstNameAttribute == nil {
|
||||
o.SamlSettings.FirstNameAttribute = new(string)
|
||||
*o.SamlSettings.FirstNameAttribute = ""
|
||||
}
|
||||
|
||||
if o.SamlSettings.LastNameAttribute == nil {
|
||||
o.SamlSettings.LastNameAttribute = new(string)
|
||||
*o.SamlSettings.LastNameAttribute = ""
|
||||
}
|
||||
|
||||
if o.SamlSettings.EmailAttribute == nil {
|
||||
o.SamlSettings.EmailAttribute = new(string)
|
||||
*o.SamlSettings.EmailAttribute = ""
|
||||
}
|
||||
|
||||
if o.SamlSettings.UsernameAttribute == nil {
|
||||
o.SamlSettings.UsernameAttribute = new(string)
|
||||
*o.SamlSettings.UsernameAttribute = ""
|
||||
}
|
||||
|
||||
if o.SamlSettings.NicknameAttribute == nil {
|
||||
o.SamlSettings.NicknameAttribute = new(string)
|
||||
*o.SamlSettings.NicknameAttribute = ""
|
||||
}
|
||||
|
||||
if o.SamlSettings.LocaleAttribute == nil {
|
||||
o.SamlSettings.LocaleAttribute = new(string)
|
||||
*o.SamlSettings.LocaleAttribute = ""
|
||||
}
|
||||
}
|
||||
|
||||
@ -697,6 +888,78 @@ func (o *Config) IsValid() *AppError {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_sync_interval.app_error", nil, "")
|
||||
}
|
||||
|
||||
if *o.LdapSettings.MaxPageSize < 0 {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_max_page_size.app_error", nil, "")
|
||||
}
|
||||
|
||||
if *o.LdapSettings.Enable {
|
||||
if *o.LdapSettings.LdapServer == "" ||
|
||||
*o.LdapSettings.BaseDN == "" ||
|
||||
*o.LdapSettings.BindUsername == "" ||
|
||||
*o.LdapSettings.BindPassword == "" ||
|
||||
*o.LdapSettings.FirstNameAttribute == "" ||
|
||||
*o.LdapSettings.LastNameAttribute == "" ||
|
||||
*o.LdapSettings.EmailAttribute == "" ||
|
||||
*o.LdapSettings.UsernameAttribute == "" ||
|
||||
*o.LdapSettings.IdAttribute == "" {
|
||||
return NewLocAppError("Config.IsValid", "Required LDAP field missing", nil, "")
|
||||
}
|
||||
}
|
||||
|
||||
if *o.SamlSettings.Enable {
|
||||
if len(*o.SamlSettings.IdpUrl) == 0 {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_idp_url.app_error", nil, "")
|
||||
}
|
||||
|
||||
if len(*o.SamlSettings.IdpDescriptorUrl) == 0 || !IsValidHttpUrl(*o.SamlSettings.IdpDescriptorUrl) {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_idp_descriptor_url.app_error", nil, "")
|
||||
}
|
||||
|
||||
if len(*o.SamlSettings.IdpCertificateFile) == 0 {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_idp_cert.app_error", nil, "")
|
||||
}
|
||||
|
||||
if len(*o.SamlSettings.EmailAttribute) == 0 {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_email_attribute.app_error", nil, "")
|
||||
}
|
||||
|
||||
if len(*o.SamlSettings.UsernameAttribute) == 0 {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_username_attribute.app_error", nil, "")
|
||||
}
|
||||
|
||||
if len(*o.SamlSettings.FirstNameAttribute) == 0 {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_first_name_attribute.app_error", nil, "")
|
||||
}
|
||||
|
||||
if len(*o.SamlSettings.LastNameAttribute) == 0 {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_last_name_attribute.app_error", nil, "")
|
||||
}
|
||||
|
||||
if *o.SamlSettings.Verify {
|
||||
if len(*o.SamlSettings.AssertionConsumerServiceURL) == 0 || !IsValidHttpUrl(*o.SamlSettings.AssertionConsumerServiceURL) {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_assertion_consumer_service_url.app_error", nil, "")
|
||||
}
|
||||
}
|
||||
|
||||
if *o.SamlSettings.Encrypt {
|
||||
if len(*o.SamlSettings.PrivateKeyFile) == 0 {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_private_key.app_error", nil, "")
|
||||
}
|
||||
|
||||
if len(*o.SamlSettings.PublicCertificateFile) == 0 {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_public_cert.app_error", nil, "")
|
||||
}
|
||||
}
|
||||
|
||||
if len(*o.SamlSettings.EmailAttribute) == 0 {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_email_attribute.app_error", nil, "")
|
||||
}
|
||||
}
|
||||
|
||||
if *o.PasswordSettings.MinimumLength < PASSWORD_MINIMUM_LENGTH || *o.PasswordSettings.MinimumLength > PASSWORD_MAXIMUM_LENGTH {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.password_length.app_error", map[string]interface{}{"MinLength": PASSWORD_MINIMUM_LENGTH, "MaxLength": PASSWORD_MAXIMUM_LENGTH}, "")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
95
vendor/github.com/mattermost/platform/model/emoji.go
generated
vendored
Normal file
95
vendor/github.com/mattermost/platform/model/emoji.go
generated
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
)
|
||||
|
||||
type Emoji struct {
|
||||
Id string `json:"id"`
|
||||
CreateAt int64 `json:"create_at"`
|
||||
UpdateAt int64 `json:"update_at"`
|
||||
DeleteAt int64 `json:"delete_at"`
|
||||
CreatorId string `json:"creator_id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (emoji *Emoji) IsValid() *AppError {
|
||||
if len(emoji.Id) != 26 {
|
||||
return NewLocAppError("Emoji.IsValid", "model.emoji.id.app_error", nil, "")
|
||||
}
|
||||
|
||||
if emoji.CreateAt == 0 {
|
||||
return NewLocAppError("Emoji.IsValid", "model.emoji.create_at.app_error", nil, "id="+emoji.Id)
|
||||
}
|
||||
|
||||
if emoji.UpdateAt == 0 {
|
||||
return NewLocAppError("Emoji.IsValid", "model.emoji.update_at.app_error", nil, "id="+emoji.Id)
|
||||
}
|
||||
|
||||
if len(emoji.CreatorId) != 26 {
|
||||
return NewLocAppError("Emoji.IsValid", "model.emoji.user_id.app_error", nil, "")
|
||||
}
|
||||
|
||||
if len(emoji.Name) == 0 || len(emoji.Name) > 64 {
|
||||
return NewLocAppError("Emoji.IsValid", "model.emoji.name.app_error", nil, "")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (emoji *Emoji) PreSave() {
|
||||
if emoji.Id == "" {
|
||||
emoji.Id = NewId()
|
||||
}
|
||||
|
||||
emoji.CreateAt = GetMillis()
|
||||
emoji.UpdateAt = emoji.CreateAt
|
||||
}
|
||||
|
||||
func (emoji *Emoji) PreUpdate() {
|
||||
emoji.UpdateAt = GetMillis()
|
||||
}
|
||||
|
||||
func (emoji *Emoji) ToJson() string {
|
||||
b, err := json.Marshal(emoji)
|
||||
if err != nil {
|
||||
return ""
|
||||
} else {
|
||||
return string(b)
|
||||
}
|
||||
}
|
||||
|
||||
func EmojiFromJson(data io.Reader) *Emoji {
|
||||
decoder := json.NewDecoder(data)
|
||||
var emoji Emoji
|
||||
err := decoder.Decode(&emoji)
|
||||
if err == nil {
|
||||
return &emoji
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func EmojiListToJson(emojiList []*Emoji) string {
|
||||
b, err := json.Marshal(emojiList)
|
||||
if err != nil {
|
||||
return ""
|
||||
} else {
|
||||
return string(b)
|
||||
}
|
||||
}
|
||||
|
||||
func EmojiListFromJson(data io.Reader) []*Emoji {
|
||||
decoder := json.NewDecoder(data)
|
||||
var emojiList []*Emoji
|
||||
err := decoder.Decode(&emojiList)
|
||||
if err == nil {
|
||||
return emojiList
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
7
vendor/github.com/mattermost/platform/model/job.go
generated
vendored
7
vendor/github.com/mattermost/platform/model/job.go
generated
vendored
@ -28,8 +28,11 @@ func removeTaskByName(name string) {
|
||||
delete(tasks, name)
|
||||
}
|
||||
|
||||
func getTaskByName(name string) *ScheduledTask {
|
||||
return tasks[name]
|
||||
func GetTaskByName(name string) *ScheduledTask {
|
||||
if task, ok := tasks[name]; ok {
|
||||
return task
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetAllTasks() *map[string]*ScheduledTask {
|
||||
|
1
vendor/github.com/mattermost/platform/model/ldap.go
generated
vendored
1
vendor/github.com/mattermost/platform/model/ldap.go
generated
vendored
@ -5,4 +5,5 @@ package model
|
||||
|
||||
const (
|
||||
USER_AUTH_SERVICE_LDAP = "ldap"
|
||||
LDAP_SYNC_TASK_NAME = "LDAP Syncronization"
|
||||
)
|
||||
|
28
vendor/github.com/mattermost/platform/model/license.go
generated
vendored
28
vendor/github.com/mattermost/platform/model/license.go
generated
vendored
@ -32,14 +32,16 @@ type Customer struct {
|
||||
}
|
||||
|
||||
type Features struct {
|
||||
Users *int `json:"users"`
|
||||
LDAP *bool `json:"ldap"`
|
||||
MFA *bool `json:"mfa"`
|
||||
GoogleSSO *bool `json:"google_sso"`
|
||||
Compliance *bool `json:"compliance"`
|
||||
CustomBrand *bool `json:"custom_brand"`
|
||||
MHPNS *bool `json:"mhpns"`
|
||||
FutureFeatures *bool `json:"future_features"`
|
||||
Users *int `json:"users"`
|
||||
LDAP *bool `json:"ldap"`
|
||||
MFA *bool `json:"mfa"`
|
||||
GoogleSSO *bool `json:"google_sso"`
|
||||
Compliance *bool `json:"compliance"`
|
||||
CustomBrand *bool `json:"custom_brand"`
|
||||
MHPNS *bool `json:"mhpns"`
|
||||
SAML *bool `json:"saml"`
|
||||
PasswordRequirements *bool `json:"password_requirements"`
|
||||
FutureFeatures *bool `json:"future_features"`
|
||||
}
|
||||
|
||||
func (f *Features) SetDefaults() {
|
||||
@ -82,6 +84,16 @@ func (f *Features) SetDefaults() {
|
||||
f.MHPNS = new(bool)
|
||||
*f.MHPNS = *f.FutureFeatures
|
||||
}
|
||||
|
||||
if f.SAML == nil {
|
||||
f.SAML = new(bool)
|
||||
*f.SAML = *f.FutureFeatures
|
||||
}
|
||||
|
||||
if f.PasswordRequirements == nil {
|
||||
f.PasswordRequirements = new(bool)
|
||||
*f.PasswordRequirements = *f.FutureFeatures
|
||||
}
|
||||
}
|
||||
|
||||
func (l *License) IsExpired() bool {
|
||||
|
1
vendor/github.com/mattermost/platform/model/message.go
generated
vendored
1
vendor/github.com/mattermost/platform/model/message.go
generated
vendored
@ -17,6 +17,7 @@ const (
|
||||
ACTION_CHANNEL_VIEWED = "channel_viewed"
|
||||
ACTION_DIRECT_ADDED = "direct_added"
|
||||
ACTION_NEW_USER = "new_user"
|
||||
ACTION_LEAVE_TEAM = "leave_team"
|
||||
ACTION_USER_ADDED = "user_added"
|
||||
ACTION_USER_REMOVED = "user_removed"
|
||||
ACTION_PREFERENCE_CHANGED = "preference_changed"
|
||||
|
18
vendor/github.com/mattermost/platform/model/saml.go
generated
vendored
Normal file
18
vendor/github.com/mattermost/platform/model/saml.go
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
package model
|
||||
|
||||
const (
|
||||
USER_AUTH_SERVICE_SAML = "saml"
|
||||
USER_AUTH_SERVICE_SAML_TEXT = "With SAML"
|
||||
SAML_IDP_CERTIFICATE = 1
|
||||
SAML_PRIVATE_KEY = 2
|
||||
SAML_PUBLIC_CERT = 3
|
||||
)
|
||||
|
||||
type SamlAuthRequest struct {
|
||||
Base64AuthRequest string
|
||||
URL string
|
||||
RelayState string
|
||||
}
|
7
vendor/github.com/mattermost/platform/model/team_member.go
generated
vendored
7
vendor/github.com/mattermost/platform/model/team_member.go
generated
vendored
@ -14,9 +14,10 @@ const (
|
||||
)
|
||||
|
||||
type TeamMember struct {
|
||||
TeamId string `json:"team_id"`
|
||||
UserId string `json:"user_id"`
|
||||
Roles string `json:"roles"`
|
||||
TeamId string `json:"team_id"`
|
||||
UserId string `json:"user_id"`
|
||||
Roles string `json:"roles"`
|
||||
DeleteAt int64 `json:"delete_at"`
|
||||
}
|
||||
|
||||
func (o *TeamMember) ToJson() string {
|
||||
|
14
vendor/github.com/mattermost/platform/model/user.go
generated
vendored
14
vendor/github.com/mattermost/platform/model/user.go
generated
vendored
@ -27,7 +27,6 @@ const (
|
||||
DEFAULT_LOCALE = "en"
|
||||
USER_AUTH_SERVICE_EMAIL = "email"
|
||||
USER_AUTH_SERVICE_USERNAME = "username"
|
||||
MIN_PASSWORD_LENGTH = 5
|
||||
)
|
||||
|
||||
type User struct {
|
||||
@ -95,10 +94,6 @@ func (u *User) IsValid() *AppError {
|
||||
return NewLocAppError("User.IsValid", "model.user.is_valid.last_name.app_error", nil, "user_id="+u.Id)
|
||||
}
|
||||
|
||||
if len(u.Password) > 128 {
|
||||
return NewLocAppError("User.IsValid", "model.user.is_valid.pwd.app_error", nil, "user_id="+u.Id)
|
||||
}
|
||||
|
||||
if u.AuthData != nil && len(*u.AuthData) > 128 {
|
||||
return NewLocAppError("User.IsValid", "model.user.is_valid.auth_data.app_error", nil, "user_id="+u.Id)
|
||||
}
|
||||
@ -208,7 +203,6 @@ func (u *User) SetDefaultNotifications() {
|
||||
u.NotifyProps["desktop"] = USER_NOTIFY_ALL
|
||||
u.NotifyProps["desktop_sound"] = "true"
|
||||
u.NotifyProps["mention_keys"] = u.Username + ",@" + u.Username
|
||||
u.NotifyProps["all"] = "true"
|
||||
u.NotifyProps["channel"] = "true"
|
||||
|
||||
if u.FirstName == "" {
|
||||
@ -244,8 +238,8 @@ func (u *User) ToJson() string {
|
||||
}
|
||||
|
||||
// Generate a valid strong etag so the browser can cache the results
|
||||
func (u *User) Etag() string {
|
||||
return Etag(u.Id, u.UpdateAt)
|
||||
func (u *User) Etag(showFullName, showEmail bool) string {
|
||||
return Etag(u.Id, u.UpdateAt, showFullName, showEmail)
|
||||
}
|
||||
|
||||
func (u *User) IsOffline() bool {
|
||||
@ -363,13 +357,13 @@ func isValidRole(role string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Make sure you acually want to use this function. In context.go there are functions to check permssions
|
||||
// Make sure you acually want to use this function. In context.go there are functions to check permissions
|
||||
// This function should not be used to check permissions.
|
||||
func (u *User) IsInRole(inRole string) bool {
|
||||
return IsInRole(u.Roles, inRole)
|
||||
}
|
||||
|
||||
// Make sure you acually want to use this function. In context.go there are functions to check permssions
|
||||
// Make sure you acually want to use this function. In context.go there are functions to check permissions
|
||||
// This function should not be used to check permissions.
|
||||
func IsInRole(userRoles string, inRole string) bool {
|
||||
roles := strings.Split(userRoles, " ")
|
||||
|
7
vendor/github.com/mattermost/platform/model/utils.go
generated
vendored
7
vendor/github.com/mattermost/platform/model/utils.go
generated
vendored
@ -20,6 +20,13 @@ import (
|
||||
"github.com/pborman/uuid"
|
||||
)
|
||||
|
||||
const (
|
||||
LOWERCASE_LETTERS = "abcdefghijklmnopqrstuvwxyz"
|
||||
UPPERCASE_LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
NUMBERS = "0123456789"
|
||||
SYMBOLS = " !\"\\#$%&'()*+,-./:;<=>?@[]^_`|~"
|
||||
)
|
||||
|
||||
type StringInterface map[string]interface{}
|
||||
type StringMap map[string]string
|
||||
type StringArray []string
|
||||
|
1
vendor/github.com/mattermost/platform/model/version.go
generated
vendored
1
vendor/github.com/mattermost/platform/model/version.go
generated
vendored
@ -13,6 +13,7 @@ import (
|
||||
// It should be maitained in chronological order with most current
|
||||
// release at the front of the list.
|
||||
var versions = []string{
|
||||
"3.2.0",
|
||||
"3.1.0",
|
||||
"3.0.0",
|
||||
"2.2.0",
|
||||
|
20
vendor/github.com/thoj/go-ircevent/irc.go
generated
vendored
20
vendor/github.com/thoj/go-ircevent/irc.go
generated
vendored
@ -439,6 +439,25 @@ func (irc *Connection) Connect(server string) error {
|
||||
if len(irc.Password) > 0 {
|
||||
irc.pwrite <- fmt.Sprintf("PASS %s\r\n", irc.Password)
|
||||
}
|
||||
|
||||
resChan := make(chan *SASLResult)
|
||||
if irc.UseSASL {
|
||||
irc.setupSASLCallbacks(resChan)
|
||||
irc.pwrite <- fmt.Sprintf("CAP LS\r\n")
|
||||
// request SASL
|
||||
irc.pwrite <- fmt.Sprintf("CAP REQ :sasl\r\n")
|
||||
// if sasl request doesn't complete in 15 seconds, close chan and timeout
|
||||
select {
|
||||
case res := <-resChan:
|
||||
if res.Failed {
|
||||
close(resChan)
|
||||
return res.Err
|
||||
}
|
||||
case <-time.After(time.Second * 15):
|
||||
close(resChan)
|
||||
return errors.New("SASL setup timed out. This shouldn't happen.")
|
||||
}
|
||||
}
|
||||
irc.pwrite <- fmt.Sprintf("NICK %s\r\n", irc.nick)
|
||||
irc.pwrite <- fmt.Sprintf("USER %s 0.0.0.0 0.0.0.0 :%s\r\n", irc.user, irc.user)
|
||||
return nil
|
||||
@ -466,6 +485,7 @@ func IRC(nick, user string) *Connection {
|
||||
KeepAlive: 4 * time.Minute,
|
||||
Timeout: 1 * time.Minute,
|
||||
PingFreq: 15 * time.Minute,
|
||||
SASLMech: "PLAIN",
|
||||
QuitMessage: "",
|
||||
}
|
||||
irc.setupCallbacks()
|
||||
|
24
vendor/github.com/thoj/go-ircevent/irc_struct.go
generated
vendored
24
vendor/github.com/thoj/go-ircevent/irc_struct.go
generated
vendored
@ -14,16 +14,20 @@ import (
|
||||
|
||||
type Connection struct {
|
||||
sync.WaitGroup
|
||||
Debug bool
|
||||
Error chan error
|
||||
Password string
|
||||
UseTLS bool
|
||||
TLSConfig *tls.Config
|
||||
Version string
|
||||
Timeout time.Duration
|
||||
PingFreq time.Duration
|
||||
KeepAlive time.Duration
|
||||
Server string
|
||||
Debug bool
|
||||
Error chan error
|
||||
Password string
|
||||
UseTLS bool
|
||||
UseSASL bool
|
||||
SASLLogin string
|
||||
SASLPassword string
|
||||
SASLMech string
|
||||
TLSConfig *tls.Config
|
||||
Version string
|
||||
Timeout time.Duration
|
||||
PingFreq time.Duration
|
||||
KeepAlive time.Duration
|
||||
Server string
|
||||
|
||||
socket net.Conn
|
||||
pwrite chan string
|
||||
|
54
vendor/github.com/thoj/go-ircevent/sasl.go
generated
vendored
Normal file
54
vendor/github.com/thoj/go-ircevent/sasl.go
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
package irc
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type SASLResult struct {
|
||||
Failed bool
|
||||
Err error
|
||||
}
|
||||
|
||||
func (irc *Connection) setupSASLCallbacks(result chan<- *SASLResult) {
|
||||
irc.AddCallback("CAP", func(e *Event) {
|
||||
if len(e.Arguments) == 3 {
|
||||
if e.Arguments[1] == "LS" {
|
||||
if !strings.Contains(e.Arguments[2], "sasl") {
|
||||
result <- &SASLResult{true, errors.New("no SASL capability " + e.Arguments[2])}
|
||||
}
|
||||
}
|
||||
if e.Arguments[1] == "ACK" {
|
||||
if irc.SASLMech != "PLAIN" {
|
||||
result <- &SASLResult{true, errors.New("only PLAIN is supported")}
|
||||
}
|
||||
irc.SendRaw("AUTHENTICATE " + irc.SASLMech)
|
||||
}
|
||||
}
|
||||
})
|
||||
irc.AddCallback("AUTHENTICATE", func(e *Event) {
|
||||
str := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s\x00%s\x00%s", irc.SASLLogin, irc.SASLLogin, irc.SASLPassword)))
|
||||
irc.SendRaw("AUTHENTICATE " + str)
|
||||
})
|
||||
irc.AddCallback("901", func(e *Event) {
|
||||
irc.SendRaw("CAP END")
|
||||
irc.SendRaw("QUIT")
|
||||
result <- &SASLResult{true, errors.New(e.Arguments[1])}
|
||||
})
|
||||
irc.AddCallback("902", func(e *Event) {
|
||||
irc.SendRaw("CAP END")
|
||||
irc.SendRaw("QUIT")
|
||||
result <- &SASLResult{true, errors.New(e.Arguments[1])}
|
||||
})
|
||||
irc.AddCallback("903", func(e *Event) {
|
||||
irc.SendRaw("CAP END")
|
||||
result <- &SASLResult{false, nil}
|
||||
})
|
||||
irc.AddCallback("904", func(e *Event) {
|
||||
irc.SendRaw("CAP END")
|
||||
irc.SendRaw("QUIT")
|
||||
result <- &SASLResult{true, errors.New(e.Arguments[1])}
|
||||
})
|
||||
}
|
12
vendor/manifest
vendored
12
vendor/manifest
vendored
@ -63,8 +63,8 @@
|
||||
"importpath": "github.com/mattermost/platform/einterfaces",
|
||||
"repository": "https://github.com/mattermost/platform",
|
||||
"vcs": "git",
|
||||
"revision": "974238231b9cdbd39a825ec8e9299fbb0b51f6b8",
|
||||
"branch": "release-3.1",
|
||||
"revision": "ab52700aaa76a5623de23cd0156f5dbd9a24e264",
|
||||
"branch": "release-3.2",
|
||||
"path": "/einterfaces",
|
||||
"notests": true
|
||||
},
|
||||
@ -72,8 +72,8 @@
|
||||
"importpath": "github.com/mattermost/platform/model",
|
||||
"repository": "https://github.com/mattermost/platform",
|
||||
"vcs": "git",
|
||||
"revision": "974238231b9cdbd39a825ec8e9299fbb0b51f6b8",
|
||||
"branch": "release-3.1",
|
||||
"revision": "ab52700aaa76a5623de23cd0156f5dbd9a24e264",
|
||||
"branch": "release-3.2",
|
||||
"path": "/model",
|
||||
"notests": true
|
||||
},
|
||||
@ -113,8 +113,8 @@
|
||||
{
|
||||
"importpath": "github.com/thoj/go-ircevent",
|
||||
"repository": "https://github.com/thoj/go-ircevent",
|
||||
"vcs": "",
|
||||
"revision": "da78ed515c0f0833e7a92c7cc52898176198e2c1",
|
||||
"vcs": "git",
|
||||
"revision": "98c1902dd2097f38142384167e60206ba26f1585",
|
||||
"branch": "master",
|
||||
"notests": true
|
||||
},
|
||||
|
Reference in New Issue
Block a user