Update mautrix-go
This commit is contained in:
@ -35,9 +35,9 @@ type SQLCryptoStore struct {
|
||||
|
||||
var _ crypto.Store = (*SQLCryptoStore)(nil)
|
||||
|
||||
func NewSQLCryptoStore(db *Database, deviceID id.DeviceID, userID id.UserID, ghostIDFormat string) *SQLCryptoStore {
|
||||
func NewSQLCryptoStore(db *Database, userID id.UserID, ghostIDFormat string) *SQLCryptoStore {
|
||||
return &SQLCryptoStore{
|
||||
SQLCryptoStore: crypto.NewSQLCryptoStore(db.DB, db.dialect, deviceID,
|
||||
SQLCryptoStore: crypto.NewSQLCryptoStore(db.DB, db.dialect, "", "",
|
||||
[]byte("maunium.net/go/mautrix-whatsapp"),
|
||||
&cryptoLogger{db.log.Sub("CryptoStore")}),
|
||||
UserID: userID,
|
||||
@ -45,10 +45,10 @@ func NewSQLCryptoStore(db *Database, deviceID id.DeviceID, userID id.UserID, gho
|
||||
}
|
||||
}
|
||||
|
||||
func (db *Database) FindDeviceID() (deviceID id.DeviceID) {
|
||||
err := db.QueryRow("SELECT device_id FROM crypto_account LIMIT 1").Scan(&deviceID)
|
||||
func (store *SQLCryptoStore) FindDeviceID() (deviceID id.DeviceID) {
|
||||
err := store.DB.QueryRow("SELECT device_id FROM crypto_account WHERE account_id=$1", store.AccountID).Scan(&deviceID)
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
db.log.Warnln("Failed to scan device ID:", err)
|
||||
store.Log.Warn("Failed to scan device ID: %v", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
13
database/upgrades/2020-07-10-update-crypto-store.go
Normal file
13
database/upgrades/2020-07-10-update-crypto-store.go
Normal file
@ -0,0 +1,13 @@
|
||||
package upgrades
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
|
||||
"maunium.net/go/mautrix/crypto"
|
||||
)
|
||||
|
||||
func init() {
|
||||
upgrades[16] = upgrade{"Add account_id to crypto store", func(tx *sql.Tx, c context) error {
|
||||
return crypto.SQLStoreMigrations[1](tx, c.dialect.String())
|
||||
}}
|
||||
}
|
@ -15,6 +15,17 @@ const (
|
||||
SQLite
|
||||
)
|
||||
|
||||
func (dialect Dialect) String() string {
|
||||
switch dialect {
|
||||
case Postgres:
|
||||
return "postgres"
|
||||
case SQLite:
|
||||
return "sqlite3"
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
type upgradeFunc func(*sql.Tx, context) error
|
||||
|
||||
type context struct {
|
||||
@ -28,7 +39,7 @@ type upgrade struct {
|
||||
fn upgradeFunc
|
||||
}
|
||||
|
||||
const NumberOfUpgrades = 16
|
||||
const NumberOfUpgrades = 17
|
||||
|
||||
var upgrades [NumberOfUpgrades]upgrade
|
||||
|
||||
|
Reference in New Issue
Block a user