Using new groupme-lib with fayec websocket client
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
b067459739
commit
8797e96b22
@ -27,7 +27,7 @@ import (
|
|||||||
"maunium.net/go/mautrix/event"
|
"maunium.net/go/mautrix/event"
|
||||||
"maunium.net/go/mautrix/id"
|
"maunium.net/go/mautrix/id"
|
||||||
|
|
||||||
"github.com/beeper/groupme-lib"
|
"gitea.watsonlabs.net/watsonb8/groupme-lib"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DeferredConfig struct {
|
type DeferredConfig struct {
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
log "maunium.net/go/maulogger/v2"
|
log "maunium.net/go/maulogger/v2"
|
||||||
"maunium.net/go/mautrix/id"
|
"maunium.net/go/mautrix/id"
|
||||||
|
|
||||||
"github.com/beeper/groupme-lib"
|
"gitea.watsonlabs.net/watsonb8/groupme-lib"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MessageQuery struct {
|
type MessageQuery struct {
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
log "maunium.net/go/maulogger/v2"
|
log "maunium.net/go/maulogger/v2"
|
||||||
"maunium.net/go/mautrix/id"
|
"maunium.net/go/mautrix/id"
|
||||||
|
|
||||||
"github.com/beeper/groupme-lib"
|
"gitea.watsonlabs.net/watsonb8/groupme-lib"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GMID is the puppet or the group
|
// GMID is the puppet or the group
|
||||||
|
@ -24,7 +24,7 @@ import (
|
|||||||
|
|
||||||
"maunium.net/go/mautrix/id"
|
"maunium.net/go/mautrix/id"
|
||||||
|
|
||||||
"github.com/beeper/groupme-lib"
|
"gitea.watsonlabs.net/watsonb8/groupme-lib"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PuppetQuery struct {
|
type PuppetQuery struct {
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"go.mau.fi/util/dbutil"
|
"go.mau.fi/util/dbutil"
|
||||||
|
|
||||||
"github.com/beeper/groupme-lib"
|
"gitea.watsonlabs.net/watsonb8/groupme-lib"
|
||||||
log "maunium.net/go/maulogger/v2"
|
log "maunium.net/go/maulogger/v2"
|
||||||
"maunium.net/go/mautrix/id"
|
"maunium.net/go/mautrix/id"
|
||||||
)
|
)
|
||||||
|
@ -25,7 +25,7 @@ import (
|
|||||||
|
|
||||||
log "maunium.net/go/maulogger/v2"
|
log "maunium.net/go/maulogger/v2"
|
||||||
|
|
||||||
"github.com/beeper/groupme-lib"
|
"gitea.watsonlabs.net/watsonb8/groupme-lib"
|
||||||
"maunium.net/go/mautrix/id"
|
"maunium.net/go/mautrix/id"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
13
go.mod
13
go.mod
@ -3,10 +3,7 @@ module github.com/beeper/groupme
|
|||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/beeper/groupme-lib v0.2.1-0.20221021205945-8f23e04eea71
|
github.com/gabriel-vasile/mimetype v0.3.23
|
||||||
//github.com/beeper/groupme-lib v0.2.1-0.20221021205945-8f23e04eea71 => "../groupme-lib"
|
|
||||||
github.com/gabriel-vasile/mimetype v1.1.2
|
|
||||||
github.com/karmanyaahm/wray v0.0.0-20210303233435-756d58657c14
|
|
||||||
github.com/lib/pq v1.10.9
|
github.com/lib/pq v1.10.9
|
||||||
github.com/mattn/go-sqlite3 v1.14.17
|
github.com/mattn/go-sqlite3 v1.14.17
|
||||||
github.com/prometheus/client_golang v1.11.1
|
github.com/prometheus/client_golang v1.11.1
|
||||||
@ -14,15 +11,19 @@ require (
|
|||||||
maunium.net/go/mautrix v0.16.1-0.20230821105106-ac5c2c22102c
|
maunium.net/go/mautrix v0.16.1-0.20230821105106-ac5c2c22102c
|
||||||
)
|
)
|
||||||
|
|
||||||
require go.mau.fi/util v0.0.0-20230805171708-199bf3eec776
|
require (
|
||||||
|
gitea.watsonlabs.net/watsonb8/groupme-lib v0.3.0
|
||||||
|
go.mau.fi/util v0.0.0-20230805171708-199bf3eec776
|
||||||
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
gitea.watsonlabs.net/watsonb8/fayec v0.0.0-20230919151904-5ca9ade6f946 // indirect
|
||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.1.1 // indirect
|
github.com/cespare/xxhash/v2 v2.1.1 // indirect
|
||||||
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
|
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
|
||||||
github.com/golang/protobuf v1.4.3 // indirect
|
github.com/golang/protobuf v1.4.3 // indirect
|
||||||
github.com/google/go-cmp v0.5.8 // indirect
|
github.com/google/go-cmp v0.5.8 // indirect
|
||||||
github.com/google/uuid v1.2.0 // indirect
|
github.com/google/uuid v1.3.1 // indirect
|
||||||
github.com/gorilla/mux v1.8.0 // indirect
|
github.com/gorilla/mux v1.8.0 // indirect
|
||||||
github.com/gorilla/websocket v1.5.0 // indirect
|
github.com/gorilla/websocket v1.5.0 // indirect
|
||||||
github.com/mattn/go-colorable v0.1.12 // indirect
|
github.com/mattn/go-colorable v0.1.12 // indirect
|
||||||
|
12
go.sum
12
go.sum
@ -1,4 +1,12 @@
|
|||||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
|
gitea.watsonlabs.net/watsonb8/fayec v0.0.0-20230919020138-8f0db7048755 h1:FEhNSjSNvZ+nVg5Z3ds6X8ys3qjM+mmyLTSqKhCUHuQ=
|
||||||
|
gitea.watsonlabs.net/watsonb8/fayec v0.0.0-20230919020138-8f0db7048755/go.mod h1:gv8CWMq6dFJQhH30u8bO3u4k2irKlclZktLNYDebQ/0=
|
||||||
|
gitea.watsonlabs.net/watsonb8/fayec v0.0.0-20230919151904-5ca9ade6f946 h1:loc70tiaFs1U4sqn+lKMSBlo5OfvVfClYnWjfGLXaSg=
|
||||||
|
gitea.watsonlabs.net/watsonb8/fayec v0.0.0-20230919151904-5ca9ade6f946/go.mod h1:gv8CWMq6dFJQhH30u8bO3u4k2irKlclZktLNYDebQ/0=
|
||||||
|
gitea.watsonlabs.net/watsonb8/groupme-lib v0.2.1-0.20230919023741-5727a20506fa h1:dFNaDeztJzo26t7URiOvaWNUDxve80tAAEHTKpi5JEk=
|
||||||
|
gitea.watsonlabs.net/watsonb8/groupme-lib v0.2.1-0.20230919023741-5727a20506fa/go.mod h1:QRCibl6Tpr/uBtXD46qXqEkxqR5tQa5vdw+0j7hn+Mw=
|
||||||
|
gitea.watsonlabs.net/watsonb8/groupme-lib v0.3.0 h1:Uz5TIIF9tFf0LYEbCJqP8axufdBfsVorAYOaal2NmPw=
|
||||||
|
gitea.watsonlabs.net/watsonb8/groupme-lib v0.3.0/go.mod h1:vddDne/D5rrUUQkiIXveB7R3rONGEy4wtAIpGL+yFXA=
|
||||||
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
|
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
|
||||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||||
@ -22,6 +30,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
|
|||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/densestvoid/groupme v0.2.0/go.mod h1:i+bzB18n8RntitrMbr65boSHU0HfjDcbEUEIPPAV+QU=
|
github.com/densestvoid/groupme v0.2.0/go.mod h1:i+bzB18n8RntitrMbr65boSHU0HfjDcbEUEIPPAV+QU=
|
||||||
|
github.com/gabriel-vasile/mimetype v0.3.23 h1:4qH4dGPSe+MBFBkWDag41c+5YFasJjyP4KwI+t6Ukz8=
|
||||||
|
github.com/gabriel-vasile/mimetype v0.3.23/go.mod h1:6CDPel/o/3/s4+bp6kIbsWATq8pmgOisOPG40CJa6To=
|
||||||
github.com/gabriel-vasile/mimetype v1.1.2 h1:gaPnPcNor5aZSVCJVSGipcpbgMWiAAj9z182ocSGbHU=
|
github.com/gabriel-vasile/mimetype v1.1.2 h1:gaPnPcNor5aZSVCJVSGipcpbgMWiAAj9z182ocSGbHU=
|
||||||
github.com/gabriel-vasile/mimetype v1.1.2/go.mod h1:6CDPel/o/3/s4+bp6kIbsWATq8pmgOisOPG40CJa6To=
|
github.com/gabriel-vasile/mimetype v1.1.2/go.mod h1:6CDPel/o/3/s4+bp6kIbsWATq8pmgOisOPG40CJa6To=
|
||||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||||
@ -54,6 +64,8 @@ github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
|
|||||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs=
|
github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs=
|
||||||
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
|
||||||
|
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
|
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
|
||||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||||
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
|
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
|
||||||
|
@ -3,7 +3,7 @@ package groupmeext
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/beeper/groupme-lib"
|
"gitea.watsonlabs.net/watsonb8/groupme-lib"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/beeper/groupme-lib"
|
"gitea.watsonlabs.net/watsonb8/groupme-lib"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Message struct{ groupme.Message }
|
type Message struct{ groupme.Message }
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
package groupmeext
|
|
||||||
|
|
||||||
import (
|
|
||||||
log "maunium.net/go/maulogger/v2"
|
|
||||||
|
|
||||||
"github.com/karmanyaahm/wray"
|
|
||||||
|
|
||||||
"github.com/beeper/groupme-lib"
|
|
||||||
)
|
|
||||||
|
|
||||||
type fayeLogger struct {
|
|
||||||
log.Logger
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f fayeLogger) Debugf(i string, a ...interface{}) {
|
|
||||||
f.Logger.Debugfln(i, a...)
|
|
||||||
}
|
|
||||||
func (f fayeLogger) Errorf(i string, a ...interface{}) {
|
|
||||||
f.Logger.Errorfln(i, a...)
|
|
||||||
}
|
|
||||||
func (f fayeLogger) Warnf(i string, a ...interface{}) {
|
|
||||||
f.Logger.Warnfln(i, a...)
|
|
||||||
}
|
|
||||||
func (f fayeLogger) Infof(i string, a ...interface{}) {
|
|
||||||
f.Logger.Infofln(i, a...)
|
|
||||||
}
|
|
||||||
|
|
||||||
type FayeClient struct {
|
|
||||||
*wray.FayeClient
|
|
||||||
}
|
|
||||||
|
|
||||||
func (fc FayeClient) WaitSubscribe(channel string, msgChannel chan groupme.PushMessage) {
|
|
||||||
c_new := make(chan wray.Message)
|
|
||||||
fc.FayeClient.WaitSubscribe(channel, c_new)
|
|
||||||
//converting between types because channels don't support interfaces well
|
|
||||||
go func() {
|
|
||||||
for i := range c_new {
|
|
||||||
msgChannel <- i
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
|
|
||||||
// for authentication, specific implementation will vary based on faye library
|
|
||||||
type AuthExt struct{}
|
|
||||||
|
|
||||||
func (a *AuthExt) In(wray.Message) {}
|
|
||||||
func (a *AuthExt) Out(m wray.Message) {
|
|
||||||
groupme.OutMsgProc(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewFayeClient(logger log.Logger) *FayeClient {
|
|
||||||
|
|
||||||
fc := &FayeClient{wray.NewFayeClient(groupme.PushServer)}
|
|
||||||
fc.SetLogger(fayeLogger{logger.Sub("FayeClient")})
|
|
||||||
fc.AddExtension(&AuthExt{})
|
|
||||||
//fc.AddExtension(fc.FayeClient)
|
|
||||||
|
|
||||||
return fc
|
|
||||||
}
|
|
2
main.go
2
main.go
@ -19,7 +19,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/beeper/groupme-lib"
|
"gitea.watsonlabs.net/watsonb8/groupme-lib"
|
||||||
"go.mau.fi/util/configupgrade"
|
"go.mau.fi/util/configupgrade"
|
||||||
"maunium.net/go/mautrix/bridge/bridgeconfig"
|
"maunium.net/go/mautrix/bridge/bridgeconfig"
|
||||||
"maunium.net/go/mautrix/event"
|
"maunium.net/go/mautrix/event"
|
||||||
|
@ -27,7 +27,7 @@ import (
|
|||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
log "maunium.net/go/maulogger/v2"
|
log "maunium.net/go/maulogger/v2"
|
||||||
|
|
||||||
"github.com/beeper/groupme-lib"
|
"gitea.watsonlabs.net/watsonb8/groupme-lib"
|
||||||
|
|
||||||
"maunium.net/go/mautrix/event"
|
"maunium.net/go/mautrix/event"
|
||||||
"maunium.net/go/mautrix/id"
|
"maunium.net/go/mautrix/id"
|
||||||
|
10
portal.go
10
portal.go
@ -38,7 +38,7 @@ import (
|
|||||||
"maunium.net/go/mautrix/bridge/bridgeconfig"
|
"maunium.net/go/mautrix/bridge/bridgeconfig"
|
||||||
"maunium.net/go/mautrix/crypto/attachment"
|
"maunium.net/go/mautrix/crypto/attachment"
|
||||||
|
|
||||||
"github.com/beeper/groupme-lib"
|
"gitea.watsonlabs.net/watsonb8/groupme-lib"
|
||||||
|
|
||||||
"maunium.net/go/mautrix"
|
"maunium.net/go/mautrix"
|
||||||
"maunium.net/go/mautrix/appservice"
|
"maunium.net/go/mautrix/appservice"
|
||||||
@ -143,7 +143,7 @@ func (portal *Portal) SyncDM(user *User, dm *groupme.Chat) {
|
|||||||
}
|
}
|
||||||
portal.log.Infoln("Syncing portal for", user.MXID)
|
portal.log.Infoln("Syncing portal for", user.MXID)
|
||||||
|
|
||||||
err := user.Conn.SubscribeToDM(context.TODO(), dm.LastMessage.ConversationID, user.Token)
|
err := user.Conn.SubscribeToDM(context.TODO(), dm.LastMessage.ConversationID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
portal.log.Errorln("Subscribing failed, live metadata updates won't work", err)
|
portal.log.Errorln("Subscribing failed, live metadata updates won't work", err)
|
||||||
}
|
}
|
||||||
@ -204,7 +204,7 @@ func (portal *Portal) SyncGroup(user *User, group *groupme.Group) {
|
|||||||
}
|
}
|
||||||
portal.log.Infoln("Syncing portal for", user.MXID)
|
portal.log.Infoln("Syncing portal for", user.MXID)
|
||||||
|
|
||||||
err := user.Conn.SubscribeToGroup(context.TODO(), portal.Key.GMID, user.Token)
|
err := user.Conn.SubscribeToGroup(context.TODO(), portal.Key.GMID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
portal.log.Errorln("Subscribing failed, live metadata updates won't work", err)
|
portal.log.Errorln("Subscribing failed, live metadata updates won't work", err)
|
||||||
}
|
}
|
||||||
@ -678,7 +678,7 @@ func (portal *Portal) handleAttachment(intent *appservice.IntentAPI, attachment
|
|||||||
case "video":
|
case "video":
|
||||||
vidContents, mime := groupmeext.DownloadVideo(attachment.VideoPreviewURL, attachment.URL, source.Token)
|
vidContents, mime := groupmeext.DownloadVideo(attachment.VideoPreviewURL, attachment.URL, source.Token)
|
||||||
if mime == "" {
|
if mime == "" {
|
||||||
mime = mimetype.Detect(vidContents).String()
|
mime, _ = mimetype.Detect(vidContents)
|
||||||
}
|
}
|
||||||
|
|
||||||
data, uploadMimeType, file := portal.encryptFile(vidContents, mime)
|
data, uploadMimeType, file := portal.encryptFile(vidContents, mime)
|
||||||
@ -715,7 +715,7 @@ func (portal *Portal) handleAttachment(intent *appservice.IntentAPI, attachment
|
|||||||
case "file":
|
case "file":
|
||||||
fileData, fname, fmime := groupmeext.DownloadFile(portal.Key.GMID, attachment.FileID, source.Token)
|
fileData, fname, fmime := groupmeext.DownloadFile(portal.Key.GMID, attachment.FileID, source.Token)
|
||||||
if fmime == "" {
|
if fmime == "" {
|
||||||
fmime = mimetype.Detect(fileData).String()
|
fmime, _ = mimetype.Detect(fileData)
|
||||||
}
|
}
|
||||||
data, uploadMimeType, file := portal.encryptFile(fileData, fmime)
|
data, uploadMimeType, file := portal.encryptFile(fileData, fmime)
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ import (
|
|||||||
|
|
||||||
log "maunium.net/go/maulogger/v2"
|
log "maunium.net/go/maulogger/v2"
|
||||||
|
|
||||||
"github.com/beeper/groupme-lib"
|
"gitea.watsonlabs.net/watsonb8/groupme-lib"
|
||||||
|
|
||||||
"maunium.net/go/mautrix/appservice"
|
"maunium.net/go/mautrix/appservice"
|
||||||
"maunium.net/go/mautrix/id"
|
"maunium.net/go/mautrix/id"
|
||||||
|
25
user.go
25
user.go
@ -35,7 +35,7 @@ import (
|
|||||||
"maunium.net/go/mautrix/format"
|
"maunium.net/go/mautrix/format"
|
||||||
"maunium.net/go/mautrix/id"
|
"maunium.net/go/mautrix/id"
|
||||||
|
|
||||||
"github.com/beeper/groupme-lib"
|
"gitea.watsonlabs.net/watsonb8/groupme-lib"
|
||||||
|
|
||||||
"github.com/beeper/groupme/database"
|
"github.com/beeper/groupme/database"
|
||||||
"github.com/beeper/groupme/groupmeext"
|
"github.com/beeper/groupme/groupmeext"
|
||||||
@ -119,7 +119,7 @@ func (user *User) GetMXID() id.UserID {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (user *User) GetGMID() groupme.ID {
|
func (user *User) GetGMID() groupme.ID {
|
||||||
if len(user.GMID) == 0 {
|
if user.GMID == "" {
|
||||||
u, err := user.Client.MyUser(context.TODO())
|
u, err := user.Client.MyUser(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
user.log.Errorln("Failed to get own GroupMe ID:", err)
|
user.log.Errorln("Failed to get own GroupMe ID:", err)
|
||||||
@ -143,7 +143,7 @@ func (user *User) GetIDoublePuppet() bridge.DoublePuppet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (user *User) GetIGhost() bridge.Ghost {
|
func (user *User) GetIGhost() bridge.Ghost {
|
||||||
if user.GMID.String() == "" {
|
if user.GMID == "" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
p := user.bridge.GetPuppetByGMID(user.GMID)
|
p := user.bridge.GetPuppetByGMID(user.GMID)
|
||||||
@ -224,6 +224,7 @@ func (user *User) GetPortalByGMID(gmid groupme.ID) *Portal {
|
|||||||
|
|
||||||
func (user *User) Login(token string) error {
|
func (user *User) Login(token string) error {
|
||||||
user.Token = token
|
user.Token = token
|
||||||
|
user.Update()
|
||||||
|
|
||||||
user.addToGMIDMap()
|
user.addToGMIDMap()
|
||||||
if user.Connect() {
|
if user.Connect() {
|
||||||
@ -259,9 +260,9 @@ func (user *User) Connect() bool {
|
|||||||
|
|
||||||
conn := groupme.NewPushSubscription(context.Background())
|
conn := groupme.NewPushSubscription(context.Background())
|
||||||
user.Conn = &conn
|
user.Conn = &conn
|
||||||
user.Conn.StartListening(context.Background(), groupmeext.NewFayeClient(user.log))
|
user.Conn.Connect(context.Background(), user.Token)
|
||||||
user.Client = groupmeext.NewClient(user.Token)
|
user.Client = groupmeext.NewClient(user.Token)
|
||||||
if len(user.GMID) == 0 {
|
if user.GMID == "" {
|
||||||
myuser, err := user.Client.MyUser(context.TODO())
|
myuser, err := user.Client.MyUser(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err) //TODO
|
log.Fatal(err) //TODO
|
||||||
@ -277,7 +278,7 @@ func (user *User) Connect() bool {
|
|||||||
|
|
||||||
func (user *User) RestoreSession() bool {
|
func (user *User) RestoreSession() bool {
|
||||||
if len(user.Token) > 0 {
|
if len(user.Token) > 0 {
|
||||||
err := user.Conn.SubscribeToUser(context.TODO(), user.GMID, user.Token)
|
err := user.Conn.SubscribeToUser(context.TODO(), user.GMID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
@ -451,6 +452,7 @@ func (user *User) HandleChatList() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
user.log.Errorln("Error syncing user list, continuing sync", err)
|
user.log.Errorln("Error syncing user list, continuing sync", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, u := range users {
|
for _, u := range users {
|
||||||
puppet := user.bridge.GetPuppetByGMID(u.ID)
|
puppet := user.bridge.GetPuppetByGMID(u.ID)
|
||||||
// "" for overall user not related to one group
|
// "" for overall user not related to one group
|
||||||
@ -461,6 +463,17 @@ func (user *User) HandleChatList() {
|
|||||||
}, false, false)
|
}, false, false)
|
||||||
userMap[u.ID] = u
|
userMap[u.ID] = u
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, dm := range dms {
|
||||||
|
puppet := user.bridge.GetPuppetByGMID(dm.OtherUser.ID)
|
||||||
|
|
||||||
|
puppet.Sync(user, &groupme.Member{
|
||||||
|
UserID: dm.OtherUser.ID,
|
||||||
|
Nickname: dm.OtherUser.Name,
|
||||||
|
ImageURL: dm.OtherUser.AvatarURL,
|
||||||
|
}, false, false)
|
||||||
|
userMap[dm.OtherUser.ID] = &dm.OtherUser
|
||||||
|
}
|
||||||
user.RelationList = userMap
|
user.RelationList = userMap
|
||||||
|
|
||||||
user.log.Infoln("Chat list received")
|
user.log.Infoln("Chat list received")
|
||||||
|
Loading…
Reference in New Issue
Block a user