This commit is contained in:
Alex 2020-02-23 20:24:50 +01:00
parent 0f6be9663e
commit ec9bc9b752
10 changed files with 95 additions and 96 deletions

View file

@ -286,14 +286,14 @@ func (a *Account) eventInternal(event *Event) error {
if err != nil { if err != nil {
return err return err
} }
content := map[string]interface{} { content := map[string]interface{}{
"body": mxfile.Filename(), "body": mxfile.Filename(),
"filename": mxfile.Filename(), "filename": mxfile.Filename(),
"url": fmt.Sprintf("mxc://%s/%s", mxfile.MxcServer, mxfile.MxcMediaId), "url": fmt.Sprintf("mxc://%s/%s", mxfile.MxcServer, mxfile.MxcMediaId),
} }
if sz := mxfile.ImageSize(); sz != nil { if sz := mxfile.ImageSize(); sz != nil {
content["msgtype"] = "m.image" content["msgtype"] = "m.image"
content["info"] = map[string]interface{} { content["info"] = map[string]interface{}{
"mimetype": mxfile.Mimetype(), "mimetype": mxfile.Mimetype(),
"size": mxfile.Size(), "size": mxfile.Size(),
"w": sz.Width, "w": sz.Width,
@ -301,7 +301,7 @@ func (a *Account) eventInternal(event *Event) error {
} }
} else { } else {
content["msgtype"] = "m.file" content["msgtype"] = "m.file"
content["info"] = map[string]interface{} { content["info"] = map[string]interface{}{
"mimetype": mxfile.Mimetype(), "mimetype": mxfile.Mimetype(),
"size": mxfile.Size(), "size": mxfile.Size(),
} }

View file

@ -1,16 +1,16 @@
package mattermost package mattermost
import ( import (
"net/http" "encoding/json"
"fmt" "fmt"
"io/ioutil"
"net/http"
_ "os" _ "os"
"strings" "strings"
"time" "time"
"io/ioutil"
"encoding/json"
"github.com/mattermost/mattermost-server/model"
"github.com/42wim/matterbridge/matterclient" "github.com/42wim/matterbridge/matterclient"
"github.com/mattermost/mattermost-server/model"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
. "git.deuxfleurs.fr/Deuxfleurs/easybridge/connector" . "git.deuxfleurs.fr/Deuxfleurs/easybridge/connector"
@ -34,7 +34,6 @@ type Mattermost struct {
userdisplaynamemap map[UserID]string // map username to last displayname userdisplaynamemap map[UserID]string // map username to last displayname
} }
func (mm *Mattermost) SetHandler(h Handler) { func (mm *Mattermost) SetHandler(h Handler) {
mm.handler = h mm.handler = h
} }

View file

@ -129,6 +129,7 @@ func (m *BlobMediaObject) URL() string {
type nullCloseReader struct { type nullCloseReader struct {
io.Reader io.Reader
} }
func (ncr nullCloseReader) Close() error { func (ncr nullCloseReader) Close() error {
return nil return nil
} }

View file

@ -3,12 +3,12 @@ package xmpp
import ( import (
"time" "time"
//"os" //"os"
"strings"
"fmt"
"crypto/tls" "crypto/tls"
"fmt"
"strings"
log "github.com/sirupsen/logrus"
gxmpp "github.com/mattn/go-xmpp" gxmpp "github.com/mattn/go-xmpp"
log "github.com/sirupsen/logrus"
. "git.deuxfleurs.fr/Deuxfleurs/easybridge/connector" . "git.deuxfleurs.fr/Deuxfleurs/easybridge/connector"
) )
@ -42,7 +42,7 @@ func (xm *XMPP) SetHandler(h Handler) {
xm.handler = h xm.handler = h
} }
func(xm *XMPP) Protocol() string { func (xm *XMPP) Protocol() string {
return "xmpp" return "xmpp"
} }
@ -97,7 +97,7 @@ func (xm *XMPP) Configure(c Configuration) error {
go xm.connectLoop(xm.connectorLoopNum) go xm.connectLoop(xm.connectorLoopNum)
for i := 0; i < 42; i++ { for i := 0; i < 42; i++ {
time.Sleep(time.Duration(1)*time.Second) time.Sleep(time.Duration(1) * time.Second)
if xm.connected { if xm.connected {
return nil return nil
} }
@ -346,4 +346,3 @@ func (xm *XMPP) Close() {
xm.conn = nil xm.conn = nil
xm.connectorLoopNum += 1 xm.connectorLoopNum += 1
} }

View file

@ -18,8 +18,8 @@ import (
"git.deuxfleurs.fr/Deuxfleurs/easybridge/appservice" "git.deuxfleurs.fr/Deuxfleurs/easybridge/appservice"
"git.deuxfleurs.fr/Deuxfleurs/easybridge/connector" "git.deuxfleurs.fr/Deuxfleurs/easybridge/connector"
"git.deuxfleurs.fr/Deuxfleurs/easybridge/connector/irc" "git.deuxfleurs.fr/Deuxfleurs/easybridge/connector/irc"
"git.deuxfleurs.fr/Deuxfleurs/easybridge/connector/xmpp"
"git.deuxfleurs.fr/Deuxfleurs/easybridge/connector/mattermost" "git.deuxfleurs.fr/Deuxfleurs/easybridge/connector/mattermost"
"git.deuxfleurs.fr/Deuxfleurs/easybridge/connector/xmpp"
"git.deuxfleurs.fr/Deuxfleurs/easybridge/mxlib" "git.deuxfleurs.fr/Deuxfleurs/easybridge/mxlib"
) )

View file

@ -1,12 +1,12 @@
package mxlib package mxlib
import ( import (
"strings"
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"net/http" "net/http"
"net/url" "net/url"
"strings"
"time" "time"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"

View file

@ -1,10 +1,10 @@
package mxlib package mxlib
import ( import (
"io"
"fmt" "fmt"
"net/url" "io"
"net/http" "net/http"
"net/url"
"git.deuxfleurs.fr/Deuxfleurs/easybridge/connector" "git.deuxfleurs.fr/Deuxfleurs/easybridge/connector"
) )