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

View file

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

View file

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

View file

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

View file

@ -18,8 +18,8 @@ import (
"git.deuxfleurs.fr/Deuxfleurs/easybridge/appservice"
"git.deuxfleurs.fr/Deuxfleurs/easybridge/connector"
"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/xmpp"
"git.deuxfleurs.fr/Deuxfleurs/easybridge/mxlib"
)

View file

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

View file

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