Double puppet support
This commit is contained in:
@@ -43,8 +43,9 @@ type Bridge struct {
|
|||||||
portalsByID map[database.PortalKey]*Portal
|
portalsByID map[database.PortalKey]*Portal
|
||||||
portalsLock sync.Mutex
|
portalsLock sync.Mutex
|
||||||
|
|
||||||
puppets map[string]*Puppet
|
puppets map[string]*Puppet
|
||||||
puppetsLock sync.Mutex
|
puppetsByCustomMXID map[id.UserID]*Puppet
|
||||||
|
puppetsLock sync.Mutex
|
||||||
|
|
||||||
StateStore *database.SQLStateStore
|
StateStore *database.SQLStateStore
|
||||||
}
|
}
|
||||||
@@ -97,7 +98,8 @@ func New(cfg *config.Config) (*Bridge, error) {
|
|||||||
portalsByMXID: make(map[id.RoomID]*Portal),
|
portalsByMXID: make(map[id.RoomID]*Portal),
|
||||||
portalsByID: make(map[database.PortalKey]*Portal),
|
portalsByID: make(map[database.PortalKey]*Portal),
|
||||||
|
|
||||||
puppets: make(map[string]*Puppet),
|
puppets: make(map[string]*Puppet),
|
||||||
|
puppetsByCustomMXID: make(map[id.UserID]*Puppet),
|
||||||
|
|
||||||
StateStore: stateStore,
|
StateStore: stateStore,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ func (h *commandHandler) handle(roomID id.RoomID, user *User, message string, re
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
h.log.Warnf("Failed to parse command %q: %v", message, err)
|
h.log.Warnf("Failed to parse command %q: %v", message, err)
|
||||||
|
|
||||||
cmd.globals.reply("failed to process the command")
|
cmd.globals.reply(fmt.Sprintf("failed to process the command: %v", err))
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,8 +52,15 @@ type commands struct {
|
|||||||
Logout logoutCmd `kong:"cmd,help='Log out of Discord.'"`
|
Logout logoutCmd `kong:"cmd,help='Log out of Discord.'"`
|
||||||
Reconnect reconnectCmd `kong:"cmd,help='Reconnect to Discord'"`
|
Reconnect reconnectCmd `kong:"cmd,help='Reconnect to Discord'"`
|
||||||
Version versionCmd `kong:"cmd,help='Displays the version of the bridge.'"`
|
Version versionCmd `kong:"cmd,help='Displays the version of the bridge.'"`
|
||||||
|
|
||||||
|
LoginMatrix loginMatrixCmd `kong:"cmd,help='Replace the puppet for your Discord account with your real Matrix account.'"`
|
||||||
|
LogoutMatrix logoutMatrixCmd `kong:"cmd,help='Switch the puppet for your Discord account back to the default one.'"`
|
||||||
|
PingMatrix pingMatrixCmd `kong:"cmd,help='check if your double puppet is working properly'"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Help Command
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
type helpCmd struct {
|
type helpCmd struct {
|
||||||
Command []string `kong:"arg,optional,help='The command to get help on.'"`
|
Command []string `kong:"arg,optional,help='The command to get help on.'"`
|
||||||
}
|
}
|
||||||
@@ -78,6 +85,9 @@ func (c *helpCmd) Run(g *globals) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Version Command
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
type versionCmd struct{}
|
type versionCmd struct{}
|
||||||
|
|
||||||
func (c *versionCmd) Run(g *globals) error {
|
func (c *versionCmd) Run(g *globals) error {
|
||||||
@@ -86,6 +96,9 @@ func (c *versionCmd) Run(g *globals) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Login Command
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
type loginCmd struct{}
|
type loginCmd struct{}
|
||||||
|
|
||||||
func (l *loginCmd) Run(g *globals) error {
|
func (l *loginCmd) Run(g *globals) error {
|
||||||
@@ -108,7 +121,7 @@ func (l *loginCmd) Run(g *globals) error {
|
|||||||
|
|
||||||
_, err := g.user.sendQRCode(g.bot, g.roomID, code)
|
_, err := g.user.sendQRCode(g.bot, g.roomID, code)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(g.context.Stdout, "failed to generate the qrcode")
|
fmt.Fprintln(g.context.Stdout, "Failed to generate the qrcode")
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -127,23 +140,30 @@ func (l *loginCmd) Run(g *globals) error {
|
|||||||
|
|
||||||
user, err := client.Result()
|
user, err := client.Result()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(g.context.Stdout, "failed to log in")
|
fmt.Fprintln(g.context.Stdout, "Failed to log in")
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := g.user.Login(user.Token); err != nil {
|
if err := g.user.Login(user.Token); err != nil {
|
||||||
fmt.Println(g.context.Stdout, "failed to login", err)
|
fmt.Fprintln(g.context.Stdout, "Failed to login", err)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g.user.Lock()
|
||||||
g.user.ID = user.UserID
|
g.user.ID = user.UserID
|
||||||
g.user.Update()
|
g.user.Update()
|
||||||
|
g.user.Unlock()
|
||||||
|
|
||||||
|
fmt.Fprintln(g.context.Stdout, "Successfully logged in")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Logout Command
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
type logoutCmd struct{}
|
type logoutCmd struct{}
|
||||||
|
|
||||||
func (l *logoutCmd) Run(g *globals) error {
|
func (l *logoutCmd) Run(g *globals) error {
|
||||||
@@ -165,6 +185,9 @@ func (l *logoutCmd) Run(g *globals) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Disconnect Command
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
type disconnectCmd struct{}
|
type disconnectCmd struct{}
|
||||||
|
|
||||||
func (d *disconnectCmd) Run(g *globals) error {
|
func (d *disconnectCmd) Run(g *globals) error {
|
||||||
@@ -185,6 +208,9 @@ func (d *disconnectCmd) Run(g *globals) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Reconnect Command
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
type reconnectCmd struct{}
|
type reconnectCmd struct{}
|
||||||
|
|
||||||
func (r *reconnectCmd) Run(g *globals) error {
|
func (r *reconnectCmd) Run(g *globals) error {
|
||||||
@@ -204,3 +230,59 @@ func (r *reconnectCmd) Run(g *globals) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// LoginMatrix Command
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
type loginMatrixCmd struct {
|
||||||
|
AccessToken string `kong:"arg,help='The shared secret to use the bridge'"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *loginMatrixCmd) Run(g *globals) error {
|
||||||
|
puppet := g.bridge.GetPuppetByID(g.user.ID)
|
||||||
|
|
||||||
|
err := puppet.SwitchCustomMXID(m.AccessToken, g.user.MXID)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(g.context.Stdout, "Failed to switch puppet: %v", err)
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Fprintf(g.context.Stdout, "Successfully switched puppet")
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// LogoutMatrix Command
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
type logoutMatrixCmd struct{}
|
||||||
|
|
||||||
|
func (m *logoutMatrixCmd) Run(g *globals) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// PingMatrix Command
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
type pingMatrixCmd struct{}
|
||||||
|
|
||||||
|
func (m *pingMatrixCmd) Run(g *globals) error {
|
||||||
|
puppet := g.bridge.GetPuppetByCustomMXID(g.user.MXID)
|
||||||
|
if puppet == nil || puppet.CustomIntent() == nil {
|
||||||
|
fmt.Fprintf(g.context.Stdout, "You have not changed your Discord account's Matrix puppet.")
|
||||||
|
|
||||||
|
return fmt.Errorf("double puppet not configured")
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := puppet.CustomIntent().Whoami()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(g.context.Stdout, "Failed to validate Matrix login: %v", err)
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Fprintf(g.context.Stdout, "Confirmed valid access token for %s / %s", resp.UserID, resp.DeviceID)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
337
bridge/custompuppet.go
Normal file
337
bridge/custompuppet.go
Normal file
@@ -0,0 +1,337 @@
|
|||||||
|
package bridge
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/hmac"
|
||||||
|
"crypto/sha512"
|
||||||
|
"encoding/hex"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"maunium.net/go/mautrix"
|
||||||
|
"maunium.net/go/mautrix/appservice"
|
||||||
|
"maunium.net/go/mautrix/event"
|
||||||
|
"maunium.net/go/mautrix/id"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ErrNoCustomMXID = errors.New("no custom mxid set")
|
||||||
|
ErrMismatchingMXID = errors.New("whoami result does not match custom mxid")
|
||||||
|
)
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// additional bridge api
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
func (b *Bridge) newDoublePuppetClient(mxid id.UserID, accessToken string) (*mautrix.Client, error) {
|
||||||
|
_, homeserver, err := mxid.Parse()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
homeserverURL, found := b.Config.Bridge.DoublePuppetServerMap[homeserver]
|
||||||
|
if !found {
|
||||||
|
if homeserver == b.as.HomeserverDomain {
|
||||||
|
homeserverURL = b.as.HomeserverURL
|
||||||
|
} else if b.Config.Bridge.DoublePuppetAllowDiscovery {
|
||||||
|
resp, err := mautrix.DiscoverClientAPI(homeserver)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to find homeserver URL for %s: %v", homeserver, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
homeserverURL = resp.Homeserver.BaseURL
|
||||||
|
b.log.Debugfln("Discovered URL %s for %s to enable double puppeting for %s", homeserverURL, homeserver, mxid)
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("double puppeting from %s is not allowed", homeserver)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
client, err := mautrix.NewClient(homeserverURL, mxid, accessToken)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
client.Logger = b.as.Log.Sub(mxid.String())
|
||||||
|
client.Client = b.as.HTTPClient
|
||||||
|
client.DefaultHTTPRetries = b.as.DefaultHTTPRetries
|
||||||
|
|
||||||
|
return client, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// mautrix.Syncer implementation
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
func (p *Puppet) GetFilterJSON(_ id.UserID) *mautrix.Filter {
|
||||||
|
everything := []event.Type{{Type: "*"}}
|
||||||
|
return &mautrix.Filter{
|
||||||
|
Presence: mautrix.FilterPart{
|
||||||
|
Senders: []id.UserID{p.CustomMXID},
|
||||||
|
Types: []event.Type{event.EphemeralEventPresence},
|
||||||
|
},
|
||||||
|
AccountData: mautrix.FilterPart{NotTypes: everything},
|
||||||
|
Room: mautrix.RoomFilter{
|
||||||
|
Ephemeral: mautrix.FilterPart{Types: []event.Type{event.EphemeralEventTyping, event.EphemeralEventReceipt}},
|
||||||
|
IncludeLeave: false,
|
||||||
|
AccountData: mautrix.FilterPart{NotTypes: everything},
|
||||||
|
State: mautrix.FilterPart{NotTypes: everything},
|
||||||
|
Timeline: mautrix.FilterPart{NotTypes: everything},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Puppet) OnFailedSync(_ *mautrix.RespSync, err error) (time.Duration, error) {
|
||||||
|
p.log.Warnln("Sync error:", err)
|
||||||
|
if errors.Is(err, mautrix.MUnknownToken) {
|
||||||
|
if !p.tryRelogin(err, "syncing") {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
p.customIntent.AccessToken = p.AccessToken
|
||||||
|
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return 10 * time.Second, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Puppet) ProcessResponse(resp *mautrix.RespSync, _ string) error {
|
||||||
|
if !p.customUser.LoggedIn() {
|
||||||
|
p.log.Debugln("Skipping sync processing: custom user not connected to discord")
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// for roomID, events := range resp.Rooms.Join {
|
||||||
|
// for _, evt := range events.Ephemeral.Events {
|
||||||
|
// evt.RoomID = roomID
|
||||||
|
// err := evt.Content.ParseRaw(evt.Type)
|
||||||
|
// if err != nil {
|
||||||
|
// continue
|
||||||
|
// }
|
||||||
|
|
||||||
|
// switch evt.Type {
|
||||||
|
// case event.EphemeralEventReceipt:
|
||||||
|
// if p.EnableReceipts {
|
||||||
|
// go p.bridge.matrixHandler.HandleReceipt(evt)
|
||||||
|
// }
|
||||||
|
// case event.EphemeralEventTyping:
|
||||||
|
// go p.bridge.matrixHandler.HandleTyping(evt)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if p.EnablePresence {
|
||||||
|
// for _, evt := range resp.Presence.Events {
|
||||||
|
// if evt.Sender != p.CustomMXID {
|
||||||
|
// continue
|
||||||
|
// }
|
||||||
|
|
||||||
|
// err := evt.Content.ParseRaw(evt.Type)
|
||||||
|
// if err != nil {
|
||||||
|
// continue
|
||||||
|
// }
|
||||||
|
|
||||||
|
// go p.bridge.matrixHandler.HandlePresence(evt)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// mautrix.Storer implementation
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
func (p *Puppet) SaveFilterID(_ id.UserID, _ string) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Puppet) SaveNextBatch(_ id.UserID, nbt string) {
|
||||||
|
p.NextBatch = nbt
|
||||||
|
p.Update()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Puppet) SaveRoom(_ *mautrix.Room) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Puppet) LoadFilterID(_ id.UserID) string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Puppet) LoadNextBatch(_ id.UserID) string {
|
||||||
|
return p.NextBatch
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Puppet) LoadRoom(_ id.RoomID) *mautrix.Room {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// additional puppet api
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
func (p *Puppet) clearCustomMXID() {
|
||||||
|
p.CustomMXID = ""
|
||||||
|
p.AccessToken = ""
|
||||||
|
p.customIntent = nil
|
||||||
|
p.customUser = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Puppet) newCustomIntent() (*appservice.IntentAPI, error) {
|
||||||
|
if p.CustomMXID == "" {
|
||||||
|
return nil, ErrNoCustomMXID
|
||||||
|
}
|
||||||
|
|
||||||
|
client, err := p.bridge.newDoublePuppetClient(p.CustomMXID, p.AccessToken)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
client.Syncer = p
|
||||||
|
client.Store = p
|
||||||
|
|
||||||
|
ia := p.bridge.as.NewIntentAPI("custom")
|
||||||
|
ia.Client = client
|
||||||
|
ia.Localpart, _, _ = p.CustomMXID.Parse()
|
||||||
|
ia.UserID = p.CustomMXID
|
||||||
|
ia.IsCustomPuppet = true
|
||||||
|
|
||||||
|
return ia, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Puppet) StartCustomMXID(reloginOnFail bool) error {
|
||||||
|
if p.CustomMXID == "" {
|
||||||
|
p.clearCustomMXID()
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
intent, err := p.newCustomIntent()
|
||||||
|
if err != nil {
|
||||||
|
p.clearCustomMXID()
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := intent.Whoami()
|
||||||
|
if err != nil {
|
||||||
|
if !reloginOnFail || (errors.Is(err, mautrix.MUnknownToken) && !p.tryRelogin(err, "initializing double puppeting")) {
|
||||||
|
p.clearCustomMXID()
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
intent.AccessToken = p.AccessToken
|
||||||
|
} else if resp.UserID != p.CustomMXID {
|
||||||
|
p.clearCustomMXID()
|
||||||
|
|
||||||
|
return ErrMismatchingMXID
|
||||||
|
}
|
||||||
|
|
||||||
|
p.customIntent = intent
|
||||||
|
p.customUser = p.bridge.GetUserByMXID(p.CustomMXID)
|
||||||
|
p.startSyncing()
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Puppet) tryRelogin(cause error, action string) bool {
|
||||||
|
if !p.bridge.Config.CanAutoDoublePuppet(p.CustomMXID) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
p.log.Debugfln("Trying to relogin after '%v' while %s", cause, action)
|
||||||
|
|
||||||
|
accessToken, err := p.loginWithSharedSecret(p.CustomMXID)
|
||||||
|
if err != nil {
|
||||||
|
p.log.Errorfln("Failed to relogin after '%v' while %s: %v", cause, action, err)
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
p.log.Infofln("Successfully relogined after '%v' while %s", cause, action)
|
||||||
|
p.AccessToken = accessToken
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Puppet) startSyncing() {
|
||||||
|
if !p.bridge.Config.Bridge.SyncWithCustomPuppets {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
p.log.Debugln("Starting syncing...")
|
||||||
|
p.customIntent.SyncPresence = "offline"
|
||||||
|
|
||||||
|
err := p.customIntent.Sync()
|
||||||
|
if err != nil {
|
||||||
|
p.log.Errorln("Fatal error syncing:", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Puppet) stopSyncing() {
|
||||||
|
if !p.bridge.Config.Bridge.SyncWithCustomPuppets {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
p.customIntent.StopSync()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Puppet) loginWithSharedSecret(mxid id.UserID) (string, error) {
|
||||||
|
_, homeserver, _ := mxid.Parse()
|
||||||
|
|
||||||
|
p.log.Debugfln("Logging into %s with shared secret", mxid)
|
||||||
|
|
||||||
|
mac := hmac.New(sha512.New, []byte(p.bridge.Config.Bridge.LoginSharedSecretMap[homeserver]))
|
||||||
|
mac.Write([]byte(mxid))
|
||||||
|
|
||||||
|
client, err := p.bridge.newDoublePuppetClient(mxid, "")
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("failed to create mautrix client to log in: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.Login(&mautrix.ReqLogin{
|
||||||
|
Type: mautrix.AuthTypePassword,
|
||||||
|
Identifier: mautrix.UserIdentifier{Type: mautrix.IdentifierTypeUser, User: string(mxid)},
|
||||||
|
Password: hex.EncodeToString(mac.Sum(nil)),
|
||||||
|
DeviceID: "Discord Bridge",
|
||||||
|
InitialDeviceDisplayName: "Discord Bridge",
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp.AccessToken, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Puppet) SwitchCustomMXID(accessToken string, mxid id.UserID) error {
|
||||||
|
prevCustomMXID := p.CustomMXID
|
||||||
|
if p.customIntent != nil {
|
||||||
|
p.stopSyncing()
|
||||||
|
}
|
||||||
|
|
||||||
|
p.CustomMXID = mxid
|
||||||
|
p.AccessToken = accessToken
|
||||||
|
|
||||||
|
err := p.StartCustomMXID(false)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if prevCustomMXID != "" {
|
||||||
|
delete(p.bridge.puppetsByCustomMXID, prevCustomMXID)
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.CustomMXID != "" {
|
||||||
|
p.bridge.puppetsByCustomMXID[p.CustomMXID] = p
|
||||||
|
}
|
||||||
|
|
||||||
|
p.EnablePresence = p.bridge.Config.Bridge.DefaultBridgePresence
|
||||||
|
p.EnableReceipts = p.bridge.Config.Bridge.DefaultBridgeReceipts
|
||||||
|
|
||||||
|
p.bridge.as.StateStore.MarkRegistered(p.CustomMXID)
|
||||||
|
|
||||||
|
p.Update()
|
||||||
|
|
||||||
|
// TODO leave rooms with default puppet
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -232,11 +232,16 @@ func (p *Portal) createMatrixRoom(user *User, channel *discordgo.Channel) error
|
|||||||
p.bridge.portalsByMXID[p.MXID] = p
|
p.bridge.portalsByMXID[p.MXID] = p
|
||||||
p.bridge.portalsLock.Unlock()
|
p.bridge.portalsLock.Unlock()
|
||||||
|
|
||||||
p.log.Debugln("inviting user", user)
|
|
||||||
p.ensureUserInvited(user)
|
p.ensureUserInvited(user)
|
||||||
|
user.syncChatDoublePuppetDetails(p, true)
|
||||||
|
|
||||||
|
p.syncParticipants(user, channel.Recipients)
|
||||||
|
|
||||||
if p.IsPrivateChat() {
|
if p.IsPrivateChat() {
|
||||||
p.syncParticipants(user, channel.Recipients)
|
puppet := user.bridge.GetPuppetByID(p.Key.Receiver)
|
||||||
|
|
||||||
|
chats := map[id.UserID][]id.RoomID{puppet.MXID: {p.MXID}}
|
||||||
|
user.updateDirectChats(chats)
|
||||||
}
|
}
|
||||||
|
|
||||||
firstEventResp, err := p.MainIntent().SendMessageEvent(p.MXID, portalCreationDummyEvent, struct{}{})
|
firstEventResp, err := p.MainIntent().SendMessageEvent(p.MXID, portalCreationDummyEvent, struct{}{})
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ type Puppet struct {
|
|||||||
|
|
||||||
MXID id.UserID
|
MXID id.UserID
|
||||||
|
|
||||||
|
customIntent *appservice.IntentAPI
|
||||||
|
customUser *User
|
||||||
|
|
||||||
syncLock sync.Mutex
|
syncLock sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,6 +88,59 @@ func (b *Bridge) GetPuppetByID(id string) *Puppet {
|
|||||||
return puppet
|
return puppet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *Bridge) GetPuppetByCustomMXID(mxid id.UserID) *Puppet {
|
||||||
|
b.puppetsLock.Lock()
|
||||||
|
defer b.puppetsLock.Unlock()
|
||||||
|
|
||||||
|
puppet, ok := b.puppetsByCustomMXID[mxid]
|
||||||
|
if !ok {
|
||||||
|
dbPuppet := b.db.Puppet.GetByCustomMXID(mxid)
|
||||||
|
if dbPuppet == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
puppet = b.NewPuppet(dbPuppet)
|
||||||
|
b.puppets[puppet.ID] = puppet
|
||||||
|
b.puppetsByCustomMXID[puppet.CustomMXID] = puppet
|
||||||
|
}
|
||||||
|
|
||||||
|
return puppet
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Bridge) GetAllPuppetsWithCustomMXID() []*Puppet {
|
||||||
|
return b.dbPuppetsToPuppets(b.db.Puppet.GetAllWithCustomMXID())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Bridge) GetAllPuppets() []*Puppet {
|
||||||
|
return b.dbPuppetsToPuppets(b.db.Puppet.GetAll())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Bridge) dbPuppetsToPuppets(dbPuppets []*database.Puppet) []*Puppet {
|
||||||
|
b.puppetsLock.Lock()
|
||||||
|
defer b.puppetsLock.Unlock()
|
||||||
|
|
||||||
|
output := make([]*Puppet, len(dbPuppets))
|
||||||
|
for index, dbPuppet := range dbPuppets {
|
||||||
|
if dbPuppet == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
puppet, ok := b.puppets[dbPuppet.ID]
|
||||||
|
if !ok {
|
||||||
|
puppet = b.NewPuppet(dbPuppet)
|
||||||
|
b.puppets[dbPuppet.ID] = puppet
|
||||||
|
|
||||||
|
if dbPuppet.CustomMXID != "" {
|
||||||
|
b.puppetsByCustomMXID[dbPuppet.CustomMXID] = puppet
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
output[index] = puppet
|
||||||
|
}
|
||||||
|
|
||||||
|
return output
|
||||||
|
}
|
||||||
|
|
||||||
func (b *Bridge) FormatPuppetMXID(did string) id.UserID {
|
func (b *Bridge) FormatPuppetMXID(did string) id.UserID {
|
||||||
return id.NewUserID(
|
return id.NewUserID(
|
||||||
b.Config.Bridge.FormatUsername(did),
|
b.Config.Bridge.FormatUsername(did),
|
||||||
@@ -97,8 +153,15 @@ func (p *Puppet) DefaultIntent() *appservice.IntentAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *Puppet) IntentFor(portal *Portal) *appservice.IntentAPI {
|
func (p *Puppet) IntentFor(portal *Portal) *appservice.IntentAPI {
|
||||||
// TODO: when we add double puppeting we need to adjust this.
|
if p.customIntent == nil || portal.Key.Receiver == p.ID {
|
||||||
return p.DefaultIntent()
|
return p.DefaultIntent()
|
||||||
|
}
|
||||||
|
|
||||||
|
return p.customIntent
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Puppet) CustomIntent() *appservice.IntentAPI {
|
||||||
|
return p.customIntent
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Puppet) updatePortalMeta(meta func(portal *Portal)) {
|
func (p *Puppet) updatePortalMeta(meta func(portal *Portal)) {
|
||||||
|
|||||||
163
bridge/user.go
163
bridge/user.go
@@ -3,6 +3,7 @@ package bridge
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
@@ -123,12 +124,19 @@ func (b *Bridge) startUsers() {
|
|||||||
b.log.Debugln("Starting users")
|
b.log.Debugln("Starting users")
|
||||||
|
|
||||||
for _, user := range b.getAllUsers() {
|
for _, user := range b.getAllUsers() {
|
||||||
// if user.ID != "" {
|
|
||||||
// haveSessions = true
|
|
||||||
// }
|
|
||||||
|
|
||||||
go user.Connect()
|
go user.Connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
b.log.Debugln("Starting custom puppets")
|
||||||
|
for _, customPuppet := range b.GetAllPuppetsWithCustomMXID() {
|
||||||
|
go func(puppet *Puppet) {
|
||||||
|
b.log.Debugln("Starting custom puppet", puppet.CustomMXID)
|
||||||
|
|
||||||
|
if err := puppet.StartCustomMXID(true); err != nil {
|
||||||
|
puppet.log.Errorln("Failed to start custom puppet:", err)
|
||||||
|
}
|
||||||
|
}(customPuppet)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) SetManagementRoom(roomID id.RoomID) {
|
func (u *User) SetManagementRoom(roomID id.RoomID) {
|
||||||
@@ -190,6 +198,53 @@ func (u *User) uploadQRCode(code string) (id.ContentURI, error) {
|
|||||||
return resp.ContentURI, nil
|
return resp.ContentURI, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *User) tryAutomaticDoublePuppeting() {
|
||||||
|
u.Lock()
|
||||||
|
defer u.Unlock()
|
||||||
|
|
||||||
|
if !u.bridge.Config.CanAutoDoublePuppet(u.MXID) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
u.log.Debugln("Checking if double puppeting needs to be enabled")
|
||||||
|
|
||||||
|
puppet := u.bridge.GetPuppetByID(u.ID)
|
||||||
|
if puppet.CustomMXID != "" {
|
||||||
|
u.log.Debugln("User already has double-puppeting enabled")
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
accessToken, err := puppet.loginWithSharedSecret(u.MXID)
|
||||||
|
if err != nil {
|
||||||
|
u.log.Warnln("Failed to login with shared secret:", err)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = puppet.SwitchCustomMXID(accessToken, u.MXID)
|
||||||
|
if err != nil {
|
||||||
|
puppet.log.Warnln("Failed to switch to auto-logined custom puppet:", err)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
u.log.Infoln("Successfully automatically enabled custom puppet")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *User) syncChatDoublePuppetDetails(portal *Portal, justCreated bool) {
|
||||||
|
doublePuppet := portal.bridge.GetPuppetByCustomMXID(u.MXID)
|
||||||
|
if doublePuppet == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if doublePuppet == nil || doublePuppet.CustomIntent() == nil || portal.MXID == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO sync mute status
|
||||||
|
}
|
||||||
|
|
||||||
func (u *User) Login(token string) error {
|
func (u *User) Login(token string) error {
|
||||||
if token == "" {
|
if token == "" {
|
||||||
return fmt.Errorf("No token specified")
|
return fmt.Errorf("No token specified")
|
||||||
@@ -216,6 +271,14 @@ func (u *User) Logout() error {
|
|||||||
return ErrNotLoggedIn
|
return ErrNotLoggedIn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
puppet := u.bridge.GetPuppetByID(u.ID)
|
||||||
|
if puppet.CustomMXID != "" {
|
||||||
|
err := puppet.SwitchCustomMXID("", "")
|
||||||
|
if err != nil {
|
||||||
|
u.log.Warnln("Failed to logout-matrix while logging out of Discord:", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err := u.Session.Close(); err != nil {
|
if err := u.Session.Close(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -299,6 +362,8 @@ func (u *User) Disconnect() error {
|
|||||||
|
|
||||||
func (u *User) connectedHandler(s *discordgo.Session, c *discordgo.Connect) {
|
func (u *User) connectedHandler(s *discordgo.Session, c *discordgo.Connect) {
|
||||||
u.log.Debugln("connected to discord")
|
u.log.Debugln("connected to discord")
|
||||||
|
|
||||||
|
u.tryAutomaticDoublePuppeting()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) disconnectedHandler(s *discordgo.Session, d *discordgo.Disconnect) {
|
func (u *User) disconnectedHandler(s *discordgo.Session, d *discordgo.Disconnect) {
|
||||||
@@ -447,6 +512,11 @@ func (u *User) ensureInvited(intent *appservice.IntentAPI, roomID id.RoomID, isD
|
|||||||
Raw: map[string]interface{}{},
|
Raw: map[string]interface{}{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
customPuppet := u.bridge.GetPuppetByCustomMXID(u.MXID)
|
||||||
|
if customPuppet != nil && customPuppet.CustomIntent() != nil {
|
||||||
|
inviteContent.Raw["fi.mau.will_auto_accept"] = true
|
||||||
|
}
|
||||||
|
|
||||||
_, err := intent.SendStateEvent(roomID, event.StateMember, u.MXID.String(), &inviteContent)
|
_, err := intent.SendStateEvent(roomID, event.StateMember, u.MXID.String(), &inviteContent)
|
||||||
|
|
||||||
var httpErr mautrix.HTTPError
|
var httpErr mautrix.HTTPError
|
||||||
@@ -459,5 +529,90 @@ func (u *User) ensureInvited(intent *appservice.IntentAPI, roomID id.RoomID, isD
|
|||||||
ret = true
|
ret = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if customPuppet != nil && customPuppet.CustomIntent() != nil {
|
||||||
|
err = customPuppet.CustomIntent().EnsureJoined(roomID, appservice.EnsureJoinedParams{IgnoreCache: true})
|
||||||
|
if err != nil {
|
||||||
|
u.log.Warnfln("Failed to auto-join %s: %v", roomID, err)
|
||||||
|
ret = false
|
||||||
|
} else {
|
||||||
|
ret = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *User) getDirectChats() map[id.UserID][]id.RoomID {
|
||||||
|
chats := map[id.UserID][]id.RoomID{}
|
||||||
|
|
||||||
|
privateChats := u.bridge.db.Portal.FindPrivateChats(u.ID)
|
||||||
|
for _, portal := range privateChats {
|
||||||
|
if portal.MXID != "" {
|
||||||
|
puppetMXID := u.bridge.FormatPuppetMXID(portal.Key.Receiver)
|
||||||
|
|
||||||
|
chats[puppetMXID] = []id.RoomID{portal.MXID}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return chats
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *User) updateDirectChats(chats map[id.UserID][]id.RoomID) {
|
||||||
|
if !u.bridge.Config.Bridge.SyncDirectChatList {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
puppet := u.bridge.GetPuppetByMXID(u.MXID)
|
||||||
|
if puppet == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
intent := puppet.CustomIntent()
|
||||||
|
if intent == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
method := http.MethodPatch
|
||||||
|
if chats == nil {
|
||||||
|
chats = u.getDirectChats()
|
||||||
|
method = http.MethodPut
|
||||||
|
}
|
||||||
|
|
||||||
|
u.log.Debugln("Updating m.direct list on homeserver")
|
||||||
|
|
||||||
|
var err error
|
||||||
|
if u.bridge.Config.Homeserver.Asmux {
|
||||||
|
urlPath := intent.BuildBaseURL("_matrix", "client", "unstable", "com.beeper.asmux", "dms")
|
||||||
|
_, err = intent.MakeFullRequest(mautrix.FullRequest{
|
||||||
|
Method: method,
|
||||||
|
URL: urlPath,
|
||||||
|
Headers: http.Header{"X-Asmux-Auth": {u.bridge.as.Registration.AppToken}},
|
||||||
|
RequestJSON: chats,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
existingChats := map[id.UserID][]id.RoomID{}
|
||||||
|
|
||||||
|
err = intent.GetAccountData(event.AccountDataDirectChats.Type, &existingChats)
|
||||||
|
if err != nil {
|
||||||
|
u.log.Warnln("Failed to get m.direct list to update it:", err)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for userID, rooms := range existingChats {
|
||||||
|
if _, ok := u.bridge.ParsePuppetMXID(userID); !ok {
|
||||||
|
// This is not a ghost user, include it in the new list
|
||||||
|
chats[userID] = rooms
|
||||||
|
} else if _, ok := chats[userID]; !ok && method == http.MethodPatch {
|
||||||
|
// This is a ghost user, but we're not replacing the whole list, so include it too
|
||||||
|
chats[userID] = rooms
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err = intent.SetAccountData(event.AccountDataDirectChats.Type, &chats)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
u.log.Warnln("Failed to update m.direct list:", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
|
"maunium.net/go/mautrix/id"
|
||||||
|
|
||||||
"github.com/bwmarrin/discordgo"
|
"github.com/bwmarrin/discordgo"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -17,10 +19,26 @@ type bridge struct {
|
|||||||
|
|
||||||
PortalMessageBuffer int `yaml:"portal_message_buffer"`
|
PortalMessageBuffer int `yaml:"portal_message_buffer"`
|
||||||
|
|
||||||
|
SyncWithCustomPuppets bool `yaml:"sync_with_custom_puppets"`
|
||||||
|
SyncDirectChatList bool `yaml:"sync_direct_chat_list"`
|
||||||
|
DefaultBridgeReceipts bool `yaml:"default_bridge_receipts"`
|
||||||
|
DefaultBridgePresence bool `yaml:"default_bridge_presence"`
|
||||||
|
|
||||||
|
DoublePuppetServerMap map[string]string `yaml:"double_puppet_server_map"`
|
||||||
|
DoublePuppetAllowDiscovery bool `yaml:"double_puppet_allow_discovery"`
|
||||||
|
LoginSharedSecretMap map[string]string `yaml:"login_shared_secret_map"`
|
||||||
|
|
||||||
usernameTemplate *template.Template `yaml:"-"`
|
usernameTemplate *template.Template `yaml:"-"`
|
||||||
displaynameTemplate *template.Template `yaml:"-"`
|
displaynameTemplate *template.Template `yaml:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (config *Config) CanAutoDoublePuppet(userID id.UserID) bool {
|
||||||
|
_, homeserver, _ := userID.Parse()
|
||||||
|
_, hasSecret := config.Bridge.LoginSharedSecretMap[homeserver]
|
||||||
|
|
||||||
|
return hasSecret
|
||||||
|
}
|
||||||
|
|
||||||
func (b *bridge) validate() error {
|
func (b *bridge) validate() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
@@ -60,7 +78,12 @@ func (b *bridge) validate() error {
|
|||||||
func (b *bridge) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
func (b *bridge) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||||
type rawBridge bridge
|
type rawBridge bridge
|
||||||
|
|
||||||
raw := rawBridge{}
|
// Set our defaults that aren't zero values.
|
||||||
|
raw := rawBridge{
|
||||||
|
SyncWithCustomPuppets: true,
|
||||||
|
DefaultBridgeReceipts: true,
|
||||||
|
DefaultBridgePresence: true,
|
||||||
|
}
|
||||||
|
|
||||||
err := unmarshal(&raw)
|
err := unmarshal(&raw)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ var (
|
|||||||
type homeserver struct {
|
type homeserver struct {
|
||||||
Address string `yaml:"address"`
|
Address string `yaml:"address"`
|
||||||
Domain string `yaml:"domain"`
|
Domain string `yaml:"domain"`
|
||||||
|
Asmux bool `yaml:"asmux"`
|
||||||
StatusEndpoint string `yaml:"status_endpoint"`
|
StatusEndpoint string `yaml:"status_endpoint"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
database/migrations/05-additional-puppet-fields.sql
Normal file
2
database/migrations/05-additional-puppet-fields.sql
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE puppet ADD COLUMN next_batch TEXT;
|
||||||
|
ALTER TABLE puppet ADD COLUMN enable_receipts BOOLEAN NOT NULL DEFAULT true;
|
||||||
@@ -43,6 +43,7 @@ func Run(db *sql.DB, baseLog log.Logger) error {
|
|||||||
migrationFromFile("02-attachments.sql"),
|
migrationFromFile("02-attachments.sql"),
|
||||||
migrationFromFile("03-emoji.sql"),
|
migrationFromFile("03-emoji.sql"),
|
||||||
migrationFromFile("04-custom-puppet.sql"),
|
migrationFromFile("04-custom-puppet.sql"),
|
||||||
|
migrationFromFile("05-additional-puppet-fields.sql"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package database
|
package database
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/bwmarrin/discordgo"
|
||||||
log "maunium.net/go/maulogger/v2"
|
log "maunium.net/go/maulogger/v2"
|
||||||
"maunium.net/go/mautrix/id"
|
"maunium.net/go/mautrix/id"
|
||||||
)
|
)
|
||||||
@@ -33,6 +34,12 @@ func (pq *PortalQuery) GetAllByID(id string) []*Portal {
|
|||||||
return pq.getAll("SELECT * FROM portal WHERE receiver=$1", id)
|
return pq.getAll("SELECT * FROM portal WHERE receiver=$1", id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pq *PortalQuery) FindPrivateChats(receiver string) []*Portal {
|
||||||
|
query := "SELECT * FROM portal WHERE receiver=$1 AND type=$2;"
|
||||||
|
|
||||||
|
return pq.getAll(query, receiver, discordgo.ChannelTypeDM)
|
||||||
|
}
|
||||||
|
|
||||||
func (pq *PortalQuery) getAll(query string, args ...interface{}) []*Portal {
|
func (pq *PortalQuery) getAll(query string, args ...interface{}) []*Portal {
|
||||||
rows, err := pq.db.Query(query, args...)
|
rows, err := pq.db.Query(query, args...)
|
||||||
if err != nil || rows == nil {
|
if err != nil || rows == nil {
|
||||||
|
|||||||
@@ -8,8 +8,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
puppetSelect = "SELECT id, display_name, avatar, avatar_url, " +
|
puppetSelect = "SELECT id, display_name, avatar, avatar_url," +
|
||||||
" enable_presence, custom_mxid, access_token" +
|
" enable_presence, custom_mxid, access_token, next_batch," +
|
||||||
|
" enable_receipts" +
|
||||||
" FROM puppet "
|
" FROM puppet "
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -25,16 +26,22 @@ type Puppet struct {
|
|||||||
|
|
||||||
EnablePresence bool
|
EnablePresence bool
|
||||||
|
|
||||||
CustomMXID string
|
CustomMXID id.UserID
|
||||||
AccessToken string
|
AccessToken string
|
||||||
|
|
||||||
|
NextBatch string
|
||||||
|
|
||||||
|
EnableReceipts bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Puppet) Scan(row Scannable) *Puppet {
|
func (p *Puppet) Scan(row Scannable) *Puppet {
|
||||||
var did, displayName, avatar, avatarURL sql.NullString
|
var did, displayName, avatar, avatarURL sql.NullString
|
||||||
var enablePresence sql.NullBool
|
var enablePresence sql.NullBool
|
||||||
var customMXID, accessToken sql.NullString
|
var customMXID, accessToken, nextBatch sql.NullString
|
||||||
|
|
||||||
|
err := row.Scan(&did, &displayName, &avatar, &avatarURL, &enablePresence,
|
||||||
|
&customMXID, &accessToken, &nextBatch, &p.EnableReceipts)
|
||||||
|
|
||||||
err := row.Scan(&did, &displayName, &avatar, &avatarURL, &enablePresence, &customMXID, &accessToken)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != sql.ErrNoRows {
|
if err != sql.ErrNoRows {
|
||||||
p.log.Errorln("Database scan failed:", err)
|
p.log.Errorln("Database scan failed:", err)
|
||||||
@@ -48,8 +55,9 @@ func (p *Puppet) Scan(row Scannable) *Puppet {
|
|||||||
p.Avatar = avatar.String
|
p.Avatar = avatar.String
|
||||||
p.AvatarURL, _ = id.ParseContentURI(avatarURL.String)
|
p.AvatarURL, _ = id.ParseContentURI(avatarURL.String)
|
||||||
p.EnablePresence = enablePresence.Bool
|
p.EnablePresence = enablePresence.Bool
|
||||||
p.CustomMXID = customMXID.String
|
p.CustomMXID = id.UserID(customMXID.String)
|
||||||
p.AccessToken = accessToken.String
|
p.AccessToken = accessToken.String
|
||||||
|
p.NextBatch = nextBatch.String
|
||||||
|
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
@@ -57,11 +65,12 @@ func (p *Puppet) Scan(row Scannable) *Puppet {
|
|||||||
func (p *Puppet) Insert() {
|
func (p *Puppet) Insert() {
|
||||||
query := "INSERT INTO puppet" +
|
query := "INSERT INTO puppet" +
|
||||||
" (id, display_name, avatar, avatar_url, enable_presence," +
|
" (id, display_name, avatar, avatar_url, enable_presence," +
|
||||||
" custom_mxid, access_token)" +
|
" custom_mxid, access_token, next_batch, enable_receipts)" +
|
||||||
" VALUES ($1, $2, $3, $4, $5, $6, $7)"
|
" VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)"
|
||||||
|
|
||||||
_, err := p.db.Exec(query, p.ID, p.DisplayName, p.Avatar,
|
_, err := p.db.Exec(query, p.ID, p.DisplayName, p.Avatar,
|
||||||
p.AvatarURL.String(), p.EnablePresence, p.CustomMXID, p.AccessToken)
|
p.AvatarURL.String(), p.EnablePresence, p.CustomMXID, p.AccessToken,
|
||||||
|
p.NextBatch, p.EnableReceipts)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.log.Warnfln("Failed to insert %s: %v", p.ID, err)
|
p.log.Warnfln("Failed to insert %s: %v", p.ID, err)
|
||||||
@@ -70,12 +79,14 @@ func (p *Puppet) Insert() {
|
|||||||
|
|
||||||
func (p *Puppet) Update() {
|
func (p *Puppet) Update() {
|
||||||
query := "UPDATE puppet" +
|
query := "UPDATE puppet" +
|
||||||
" SET display_name=$1, avatar=$2, avatar_url=$3, enable_presence=$4" +
|
" SET display_name=$1, avatar=$2, avatar_url=$3, enable_presence=$4," +
|
||||||
" custom_mxid=$5, access_token=$6" +
|
" custom_mxid=$5, access_token=$6, next_batch=$7," +
|
||||||
" WHERE id=$7"
|
" enable_receipts=$8" +
|
||||||
|
" WHERE id=$9"
|
||||||
|
|
||||||
_, err := p.db.Exec(query, p.DisplayName, p.Avatar, p.AvatarURL.String(),
|
_, err := p.db.Exec(query, p.DisplayName, p.Avatar, p.AvatarURL.String(),
|
||||||
p.EnablePresence, p.CustomMXID, p.AccessToken, p.ID)
|
p.EnablePresence, p.CustomMXID, p.AccessToken, p.NextBatch,
|
||||||
|
p.EnableReceipts, p.ID)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.log.Warnfln("Failed to update %s: %v", p.ID, err)
|
p.log.Warnfln("Failed to update %s: %v", p.ID, err)
|
||||||
|
|||||||
5
go.mod
5
go.mod
@@ -9,15 +9,14 @@ require (
|
|||||||
github.com/gorilla/websocket v1.5.0
|
github.com/gorilla/websocket v1.5.0
|
||||||
github.com/lib/pq v1.9.0
|
github.com/lib/pq v1.9.0
|
||||||
github.com/lopezator/migrator v0.3.0
|
github.com/lopezator/migrator v0.3.0
|
||||||
github.com/mattn/go-sqlite3 v1.14.10
|
github.com/mattn/go-sqlite3 v1.14.11
|
||||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
||||||
gopkg.in/yaml.v2 v2.4.0
|
gopkg.in/yaml.v2 v2.4.0
|
||||||
maunium.net/go/maulogger/v2 v2.3.2
|
maunium.net/go/maulogger/v2 v2.3.2
|
||||||
maunium.net/go/mautrix v0.10.10
|
maunium.net/go/mautrix v0.10.11
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/btcsuite/btcutil v1.0.2 // indirect
|
|
||||||
github.com/gorilla/mux v1.8.0 // indirect
|
github.com/gorilla/mux v1.8.0 // indirect
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||||
|
|||||||
53
go.sum
53
go.sum
@@ -1,21 +1,8 @@
|
|||||||
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
|
|
||||||
github.com/alecthomas/kong v0.2.18 h1:H05f55eRO5f9gusObxgjpqKtozJNvniqMTuOPnf+2SQ=
|
github.com/alecthomas/kong v0.2.18 h1:H05f55eRO5f9gusObxgjpqKtozJNvniqMTuOPnf+2SQ=
|
||||||
github.com/alecthomas/kong v0.2.18/go.mod h1:ka3VZ8GZNPXv9Ov+j4YNLkI8mTuhXyr/0ktSlqIydQQ=
|
github.com/alecthomas/kong v0.2.18/go.mod h1:ka3VZ8GZNPXv9Ov+j4YNLkI8mTuhXyr/0ktSlqIydQQ=
|
||||||
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
|
|
||||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
|
|
||||||
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
|
|
||||||
github.com/btcsuite/btcutil v1.0.2 h1:9iZ1Terx9fMIOtq1VrwdqfsATL9MC2l8ZrUY6YZ2uts=
|
|
||||||
github.com/btcsuite/btcutil v1.0.2/go.mod h1:j9HUFwoQRsZL3V4n+qG+CUnEGHOarIxfC3Le2Yhbcts=
|
|
||||||
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg=
|
|
||||||
github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY=
|
|
||||||
github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc=
|
|
||||||
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY=
|
|
||||||
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
|
|
||||||
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
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/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
|
||||||
github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA=
|
github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA=
|
||||||
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
@@ -24,24 +11,16 @@ github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3
|
|||||||
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
|
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
|
||||||
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
|
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
|
||||||
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
|
||||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
||||||
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
|
||||||
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
|
||||||
github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
|
|
||||||
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
|
|
||||||
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||||
github.com/lib/pq v1.9.0 h1:L8nSXQQzAYByakOFMTwpjRoHsMJklur4Gi59b6VivR8=
|
github.com/lib/pq v1.9.0 h1:L8nSXQQzAYByakOFMTwpjRoHsMJklur4Gi59b6VivR8=
|
||||||
github.com/lib/pq v1.9.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
github.com/lib/pq v1.9.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||||
github.com/lopezator/migrator v0.3.0 h1:VW/rR+J8NYwPdkBxjrFdjwejpgvP59LbmANJxXuNbuk=
|
github.com/lopezator/migrator v0.3.0 h1:VW/rR+J8NYwPdkBxjrFdjwejpgvP59LbmANJxXuNbuk=
|
||||||
github.com/lopezator/migrator v0.3.0/go.mod h1:bpVAVPkWSvTw8ya2Pk7E/KiNAyDWNImgivQY79o8/8I=
|
github.com/lopezator/migrator v0.3.0/go.mod h1:bpVAVPkWSvTw8ya2Pk7E/KiNAyDWNImgivQY79o8/8I=
|
||||||
github.com/mattn/go-sqlite3 v1.14.10 h1:MLn+5bFRlWMGoSRmJour3CL1w/qL96mvipqpwQW/Sfk=
|
github.com/mattn/go-sqlite3 v1.14.11 h1:gt+cp9c0XGqe9S/wAHTL3n/7MqY+siPWgWJgqdsFrzQ=
|
||||||
github.com/mattn/go-sqlite3 v1.14.10/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
github.com/mattn/go-sqlite3 v1.14.11/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
|
||||||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
|
||||||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
|
||||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
@@ -53,34 +32,21 @@ github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDq
|
|||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/tidwall/gjson v1.10.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
github.com/tidwall/gjson v1.12.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||||
|
github.com/tidwall/gjson v1.14.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||||
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||||
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||||
github.com/tidwall/sjson v1.2.3/go.mod h1:5WdjKx3AQMvCJ4RG6/2UYT7dLrGvJUV1x4jdTAyGvZs=
|
github.com/tidwall/sjson v1.2.4/go.mod h1:098SZ494YoMWPmMO6ct4dcFnqxwj9r/gF0Etp19pSNM=
|
||||||
gitlab.com/beeper/discordgo v0.23.3-0.20220210113317-784a5c1cfaa2 h1:CK9faDZlCY4rbxpqPArNdMy1kOsIrVHDEAVJcgarnrg=
|
|
||||||
gitlab.com/beeper/discordgo v0.23.3-0.20220210113317-784a5c1cfaa2/go.mod h1:Hwfv4M8yP/MDh47BN+4Z1WItJ1umLKUyplCH5KcQPgE=
|
|
||||||
gitlab.com/beeper/discordgo v0.23.3-0.20220219094025-13ff4cc63da7 h1:8ieR27GadHnShqhsvPrDzL1/ZOntavGGt4TXqafncYE=
|
gitlab.com/beeper/discordgo v0.23.3-0.20220219094025-13ff4cc63da7 h1:8ieR27GadHnShqhsvPrDzL1/ZOntavGGt4TXqafncYE=
|
||||||
gitlab.com/beeper/discordgo v0.23.3-0.20220219094025-13ff4cc63da7/go.mod h1:Hwfv4M8yP/MDh47BN+4Z1WItJ1umLKUyplCH5KcQPgE=
|
gitlab.com/beeper/discordgo v0.23.3-0.20220219094025-13ff4cc63da7/go.mod h1:Hwfv4M8yP/MDh47BN+4Z1WItJ1umLKUyplCH5KcQPgE=
|
||||||
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
|
||||||
golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20220213190939-1e6e3497d506/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
|
||||||
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
|
||||||
golang.org/x/crypto v0.0.0-20220209195652-db638375bc3a h1:atOEWVSedO4ksXBe/UrlbSLVxQQ9RxM/tT2Jy10IaHo=
|
|
||||||
golang.org/x/crypto v0.0.0-20220209195652-db638375bc3a/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
|
||||||
golang.org/x/crypto v0.0.0-20220214200702-86341886e292 h1:f+lwQ+GtmgoY+A2YaQxlSOnDjXcQ7ZRLWOHbC6HtRqE=
|
golang.org/x/crypto v0.0.0-20220214200702-86341886e292 h1:f+lwQ+GtmgoY+A2YaQxlSOnDjXcQ7ZRLWOHbC6HtRqE=
|
||||||
golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
|
||||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
|
||||||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk=
|
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk=
|
||||||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
@@ -97,9 +63,6 @@ google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO50
|
|||||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
|
||||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
|
||||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
@@ -107,5 +70,5 @@ gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v
|
|||||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
maunium.net/go/maulogger/v2 v2.3.2 h1:1XmIYmMd3PoQfp9J+PaHhpt80zpfmMqaShzUTC7FwY0=
|
maunium.net/go/maulogger/v2 v2.3.2 h1:1XmIYmMd3PoQfp9J+PaHhpt80zpfmMqaShzUTC7FwY0=
|
||||||
maunium.net/go/maulogger/v2 v2.3.2/go.mod h1:TYWy7wKwz/tIXTpsx8G3mZseIRiC5DoMxSZazOHy68A=
|
maunium.net/go/maulogger/v2 v2.3.2/go.mod h1:TYWy7wKwz/tIXTpsx8G3mZseIRiC5DoMxSZazOHy68A=
|
||||||
maunium.net/go/mautrix v0.10.10 h1:aaEuVopM3rkgOxL8Ldn2E8vcIIfKDE+tBfX/uPCRFWs=
|
maunium.net/go/mautrix v0.10.11 h1:u3D5+Ko7Pk0ruVFUAgjfk5E6U5Ys9VVObEGrytr0Hk4=
|
||||||
maunium.net/go/mautrix v0.10.10/go.mod h1:4XljZZGZiIlpfbQ+Tt2ykjapskJ8a7Z2i9y/+YaceF8=
|
maunium.net/go/mautrix v0.10.11/go.mod h1:Ynac6y32yvdJC8YiYvWjWp6u1WjVTNq+JssC+07ZZWw=
|
||||||
|
|||||||
Reference in New Issue
Block a user