Skip to content

Commit 959eb7e

Browse files
committed
Update mautrix-go
1 parent fee5cf2 commit 959eb7e

19 files changed

+75
-80
lines changed

commands.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ func fnSyncSpace(ce *WrappedCommandEvent) {
260260
if portal.IsPrivateChat() {
261261
continue
262262
}
263-
if ce.Bridge.StateStore.IsInRoom(portal.MXID, ce.User.MXID) && portal.addToPersonalSpace(ctx, ce.User) {
263+
if ce.Bridge.StateStore.IsInRoom(ctx, portal.MXID, ce.User.MXID) && portal.addToPersonalSpace(ctx, ce.User) {
264264
count++
265265
}
266266
}

custompuppet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (puppet *Puppet) ClearCustomMXID() {
5858
}
5959

6060
func (puppet *Puppet) StartCustomMXID(reloginOnFail bool) error {
61-
newIntent, newAccessToken, err := puppet.bridge.DoublePuppet.Setup(puppet.CustomMXID, puppet.AccessToken, reloginOnFail)
61+
newIntent, newAccessToken, err := puppet.bridge.DoublePuppet.Setup(context.TODO(), puppet.CustomMXID, puppet.AccessToken, reloginOnFail)
6262
if err != nil {
6363
puppet.ClearCustomMXID()
6464
return err

database/portal.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@ func (pq *PortalQuery) GetAllWithMXID(ctx context.Context) ([]*Portal, error) {
130130
}
131131

132132
func (pq *PortalQuery) FindPrivateChatsNotInSpace(ctx context.Context, receiver uuid.UUID) ([]PortalKey, error) {
133-
rows, err := pq.GetDB().QueryContext(ctx, getChatsNotInSpaceQuery, receiver)
133+
rows, err := pq.GetDB().Query(ctx, getChatsNotInSpaceQuery, receiver)
134134
if err != nil {
135135
return nil, err
136136
}
137-
return dbutil.NewRowIter(rows, func(rows dbutil.Rows) (key PortalKey, err error) {
137+
return dbutil.NewRowIter(rows, func(rows dbutil.Scannable) (key PortalKey, err error) {
138138
err = rows.Scan(&key.ChatID)
139139
key.Receiver = receiver
140140
return

database/upgrades/upgrades.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package upgrades
1818

1919
import (
20+
"context"
2021
"embed"
2122
"errors"
2223

@@ -29,10 +30,10 @@ var Table dbutil.UpgradeTable
2930
var rawUpgrades embed.FS
3031

3132
func init() {
32-
Table.Register(-1, 12, 0, "Unsupported version", false, func(tx dbutil.Execable, database *dbutil.Database) error {
33+
Table.Register(-1, 12, 0, "Unsupported version", false, func(ctx context.Context, database *dbutil.Database) error {
3334
return errors.New("please upgrade to mautrix-signal v0.4.3 before upgrading to a newer version")
3435
})
35-
Table.Register(1, 13, 0, "Jump to version 13", false, func(tx dbutil.Execable, database *dbutil.Database) error {
36+
Table.Register(1, 13, 0, "Jump to version 13", false, func(ctx context.Context, database *dbutil.Database) error {
3637
return nil
3738
})
3839
Table.RegisterFS(rawUpgrades)

database/userportal.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func (u *User) GetLastReadTS(ctx context.Context, portal PortalKey) uint64 {
4545
return cached
4646
}
4747
var ts int64
48-
err := u.qh.GetDB().QueryRowContext(ctx, getLastReadTSQuery, u.MXID, portal.ChatID, portal.Receiver).Scan(&ts)
48+
err := u.qh.GetDB().QueryRow(ctx, getLastReadTSQuery, u.MXID, portal.ChatID, portal.Receiver).Scan(&ts)
4949
if err != nil && !errors.Is(err, sql.ErrNoRows) {
5050
zerolog.Ctx(ctx).Err(err).
5151
Str("user_id", u.MXID.String()).
@@ -83,7 +83,7 @@ func (u *User) IsInSpace(ctx context.Context, portal PortalKey) bool {
8383
return cached
8484
}
8585
var inSpace bool
86-
err := u.qh.GetDB().QueryRowContext(ctx, getIsInSpaceQuery, u.MXID, portal.ChatID, portal.Receiver).Scan(&inSpace)
86+
err := u.qh.GetDB().QueryRow(ctx, getIsInSpaceQuery, u.MXID, portal.ChatID, portal.Receiver).Scan(&inSpace)
8787
if err != nil && !errors.Is(err, sql.ErrNoRows) {
8888
zerolog.Ctx(ctx).Err(err).
8989
Str("user_id", u.MXID.String()).

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ require (
1414
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
1515
github.com/stretchr/testify v1.8.4
1616
github.com/tidwall/gjson v1.17.0
17-
go.mau.fi/util v0.2.2-0.20240107131103-852f29430a02
17+
go.mau.fi/util v0.2.2-0.20240107143939-48dfc4dc3894
1818
golang.org/x/crypto v0.17.0
1919
golang.org/x/exp v0.0.0-20231226003508-02704c960a9b
2020
golang.org/x/net v0.19.0
2121
google.golang.org/protobuf v1.32.0
2222
maunium.net/go/maulogger/v2 v2.4.1
23-
maunium.net/go/mautrix v0.16.3-0.20240104125737-88631708a41b
23+
maunium.net/go/mautrix v0.16.3-0.20240107204502-25bc36bc7ae7
2424
nhooyr.io/websocket v1.8.10
2525
)
2626

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
6565
github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
6666
github.com/yuin/goldmark v1.6.0 h1:boZcn2GTjpsynOsC0iJHnBWa4Bi0qzfJjthwauItG68=
6767
github.com/yuin/goldmark v1.6.0/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
68-
go.mau.fi/util v0.2.2-0.20240107131103-852f29430a02 h1:jREUBe6TF4a2HCGowTLzcvOFg44QDZ0xgoo+YJK3ugc=
69-
go.mau.fi/util v0.2.2-0.20240107131103-852f29430a02/go.mod h1:9dGsBCCbZJstx16YgnVMVi3O2bOizELoKpugLD4FoGs=
68+
go.mau.fi/util v0.2.2-0.20240107143939-48dfc4dc3894 h1:CuR5LDSxBQLETorfwJ9vRtySeLHjMvJ7//lnCMw7Dy8=
69+
go.mau.fi/util v0.2.2-0.20240107143939-48dfc4dc3894/go.mod h1:9dGsBCCbZJstx16YgnVMVi3O2bOizELoKpugLD4FoGs=
7070
go.mau.fi/zeroconfig v0.1.2 h1:DKOydWnhPMn65GbXZOafgkPm11BvFashZWLct0dGFto=
7171
go.mau.fi/zeroconfig v0.1.2/go.mod h1:NcSJkf180JT+1IId76PcMuLTNa1CzsFFZ0nBygIQM70=
7272
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
@@ -92,7 +92,7 @@ maunium.net/go/mauflag v1.0.0 h1:YiaRc0tEI3toYtJMRIfjP+jklH45uDHtT80nUamyD4M=
9292
maunium.net/go/mauflag v1.0.0/go.mod h1:nLivPOpTpHnpzEh8jEdSL9UqO9+/KBJFmNRlwKfkPeA=
9393
maunium.net/go/maulogger/v2 v2.4.1 h1:N7zSdd0mZkB2m2JtFUsiGTQQAdP0YeFWT7YMc80yAL8=
9494
maunium.net/go/maulogger/v2 v2.4.1/go.mod h1:omPuYwYBILeVQobz8uO3XC8DIRuEb5rXYlQSuqrbCho=
95-
maunium.net/go/mautrix v0.16.3-0.20240104125737-88631708a41b h1:WWCD0vaAztVrrTRWcTXeOHq9U7HRcP2a1hs+0+guPPg=
96-
maunium.net/go/mautrix v0.16.3-0.20240104125737-88631708a41b/go.mod h1:lI43hRW+/92FCqHLD5bINSPqsWrviZ5MpLl7J3hjvW4=
95+
maunium.net/go/mautrix v0.16.3-0.20240107204502-25bc36bc7ae7 h1:Yo1S3mSazHoT/MHNheRMuRPH74rU6/ZyVaJqTEsmaN0=
96+
maunium.net/go/mautrix v0.16.3-0.20240107204502-25bc36bc7ae7/go.mod h1:eRQu5ED1ODsP+xq1K9l1AOD+O9FMkAhodd/RVc3Bkqg=
9797
nhooyr.io/websocket v1.8.10 h1:mv4p+MnGrLDcPlBoWsvPP7XCzTYMXP9F9eIGoKbgx7Q=
9898
nhooyr.io/websocket v1.8.10/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=

main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func (br *SignalBridge) logLostPortals(ctx context.Context) {
172172

173173
func (br *SignalBridge) Start() {
174174
go br.logLostPortals(context.TODO())
175-
err := br.MeowStore.Upgrade()
175+
err := br.MeowStore.Upgrade(context.TODO())
176176
if err != nil {
177177
br.Log.Fatalln("Failed to upgrade signalmeow database: %v", err)
178178
os.Exit(15)
@@ -298,9 +298,9 @@ func (br *SignalBridge) createPrivatePortalFromInvite(ctx context.Context, roomI
298298
log.Err(err).Msg("Failed to enable e2be")
299299
}
300300
}
301-
br.AS.StateStore.SetMembership(roomID, inviter.MXID, event.MembershipJoin)
302-
br.AS.StateStore.SetMembership(roomID, puppet.MXID, event.MembershipJoin)
303-
br.AS.StateStore.SetMembership(roomID, br.Bot.UserID, event.MembershipJoin)
301+
br.AS.StateStore.SetMembership(ctx, roomID, inviter.MXID, event.MembershipJoin)
302+
br.AS.StateStore.SetMembership(ctx, roomID, puppet.MXID, event.MembershipJoin)
303+
br.AS.StateStore.SetMembership(ctx, roomID, br.Bot.UserID, event.MembershipJoin)
304304
portal.Encrypted = true
305305
}
306306
portal.UpdateDMInfo(ctx, true)

metrics.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,23 +229,23 @@ func (mh *MetricsHandler) TrackConnectionState(signalID string, connected bool)
229229
func (mh *MetricsHandler) updateStats() {
230230
start := time.Now()
231231
var puppetCount int
232-
err := mh.db.QueryRowContext(mh.ctx, "SELECT COUNT(*) FROM puppet").Scan(&puppetCount)
232+
err := mh.db.QueryRow(mh.ctx, "SELECT COUNT(*) FROM puppet").Scan(&puppetCount)
233233
if err != nil {
234234
mh.log.Warnln("Failed to scan number of puppets:", err)
235235
} else {
236236
mh.puppetCount.Set(float64(puppetCount))
237237
}
238238

239239
var userCount int
240-
err = mh.db.QueryRowContext(mh.ctx, `SELECT COUNT(*) FROM "user"`).Scan(&userCount)
240+
err = mh.db.QueryRow(mh.ctx, `SELECT COUNT(*) FROM "user"`).Scan(&userCount)
241241
if err != nil {
242242
mh.log.Warnln("Failed to scan number of users:", err)
243243
} else {
244244
mh.userCount.Set(float64(userCount))
245245
}
246246

247247
var messageCount int
248-
err = mh.db.QueryRowContext(mh.ctx, "SELECT COUNT(*) FROM message").Scan(&messageCount)
248+
err = mh.db.QueryRow(mh.ctx, "SELECT COUNT(*) FROM message").Scan(&messageCount)
249249
if err != nil {
250250
mh.log.Warnln("Failed to scan number of messages:", err)
251251
} else {
@@ -255,7 +255,7 @@ func (mh *MetricsHandler) updateStats() {
255255
var encryptedGroupCount, encryptedPrivateCount, unencryptedGroupCount, unencryptedPrivateCount int
256256
// TODO Use a more precise way to check if a chat_id is a UUID.
257257
// It should also be compatible with both SQLite & Postgres.
258-
err = mh.db.QueryRowContext(mh.ctx, `
258+
err = mh.db.QueryRow(mh.ctx, `
259259
SELECT
260260
COUNT(CASE WHEN chat_id NOT LIKE '%-%-%-%-%' AND encrypted THEN 1 END) AS encrypted_group_portals,
261261
COUNT(CASE WHEN chat_id LIKE '%-%-%-%-%' AND encrypted THEN 1 END) AS encrypted_private_portals,

pkg/signalmeow/store/contact_store.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,25 +111,23 @@ func scanContact(row dbutil.Scannable) (*types.Contact, error) {
111111
}
112112

113113
func (s *SQLStore) LoadContact(ctx context.Context, theirUUID uuid.UUID) (*types.Contact, error) {
114-
return scanContact(s.db.Conn(ctx).QueryRowContext(ctx, getContactByUUIDQuery, s.ACI, theirUUID))
114+
return scanContact(s.db.QueryRow(ctx, getContactByUUIDQuery, s.ACI, theirUUID))
115115
}
116116

117117
func (s *SQLStore) LoadContactByE164(ctx context.Context, e164 string) (*types.Contact, error) {
118-
return scanContact(s.db.Conn(ctx).QueryRowContext(ctx, getContactByPhoneQuery, s.ACI, e164))
118+
return scanContact(s.db.QueryRow(ctx, getContactByPhoneQuery, s.ACI, e164))
119119
}
120120

121121
func (s *SQLStore) AllContacts(ctx context.Context) ([]*types.Contact, error) {
122-
rows, err := s.db.Conn(ctx).QueryContext(ctx, getAllContactsOfUserQuery, s.ACI)
122+
rows, err := s.db.Query(ctx, getAllContactsOfUserQuery, s.ACI)
123123
if err != nil {
124124
return nil, err
125125
}
126-
return dbutil.NewRowIter(rows, func(rows dbutil.Rows) (*types.Contact, error) {
127-
return scanContact(rows)
128-
}).AsList()
126+
return dbutil.NewRowIter(rows, scanContact).AsList()
129127
}
130128

131129
func (s *SQLStore) StoreContact(ctx context.Context, contact types.Contact) error {
132-
_, err := s.db.Conn(ctx).ExecContext(
130+
_, err := s.db.Exec(
133131
ctx,
134132
upsertContactQuery,
135133
s.ACI,

0 commit comments

Comments
 (0)