forked from MirrorHub/mautrix-whatsapp
Fix replacing outbound group session in db
This commit is contained in:
parent
c9adb3aba3
commit
fc6f8df4d3
2 changed files with 19 additions and 5 deletions
|
@ -249,11 +249,25 @@ func (store *SQLCryptoStore) GetGroupSession(roomID id.RoomID, senderKey id.Send
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (store *SQLCryptoStore) AddOutboundGroupSession(session *crypto.OutboundGroupSession) error {
|
func (store *SQLCryptoStore) AddOutboundGroupSession(session *crypto.OutboundGroupSession) (err error) {
|
||||||
sessionBytes := session.Internal.Pickle(store.PickleKey)
|
sessionBytes := session.Internal.Pickle(store.PickleKey)
|
||||||
_, err := store.db.Exec("INSERT INTO crypto_megolm_outbound_session (room_id, session_id, session, shared, max_messages, message_count, max_age, created_at, last_used) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
if store.db.dialect == "postgres" {
|
||||||
|
_, err = store.db.Exec(`
|
||||||
|
INSERT INTO crypto_megolm_outbound_session (
|
||||||
|
room_id, session_id, session, shared, max_messages, message_count, max_age, created_at, last_used
|
||||||
|
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
|
||||||
|
ON CONFLICT (room_id) DO UPDATE SET session_id=$2, session=$3, shared=$4, max_messages=$5, message_count=$6, max_age=$7, created_at=$8, last_used=$9`,
|
||||||
session.RoomID, session.ID(), sessionBytes, session.Shared, session.MaxMessages, session.MessageCount, session.MaxAge, session.CreationTime, session.UseTime)
|
session.RoomID, session.ID(), sessionBytes, session.Shared, session.MaxMessages, session.MessageCount, session.MaxAge, session.CreationTime, session.UseTime)
|
||||||
return err
|
} else if store.db.dialect == "sqlite" {
|
||||||
|
_, err = store.db.Exec(`
|
||||||
|
INSERT OR REPLACE INTO crypto_megolm_outbound_session (
|
||||||
|
room_id, session_id, session, shared, max_messages, message_count, max_age, created_at, last_used
|
||||||
|
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)`,
|
||||||
|
session.RoomID, session.ID(), sessionBytes, session.Shared, session.MaxMessages, session.MessageCount, session.MaxAge, session.CreationTime, session.UseTime)
|
||||||
|
} else {
|
||||||
|
err = fmt.Errorf("unsupported dialect %s", store.db.dialect)
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (store *SQLCryptoStore) UpdateOutboundGroupSession(session *crypto.OutboundGroupSession) error {
|
func (store *SQLCryptoStore) UpdateOutboundGroupSession(session *crypto.OutboundGroupSession) error {
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -15,7 +15,7 @@ require (
|
||||||
gopkg.in/yaml.v2 v2.2.8
|
gopkg.in/yaml.v2 v2.2.8
|
||||||
maunium.net/go/mauflag v1.0.0
|
maunium.net/go/mauflag v1.0.0
|
||||||
maunium.net/go/maulogger/v2 v2.1.1
|
maunium.net/go/maulogger/v2 v2.1.1
|
||||||
maunium.net/go/mautrix v0.4.4
|
maunium.net/go/mautrix v0.4.5
|
||||||
)
|
)
|
||||||
|
|
||||||
replace github.com/Rhymen/go-whatsapp => github.com/tulir/go-whatsapp v0.2.6
|
replace github.com/Rhymen/go-whatsapp => github.com/tulir/go-whatsapp v0.2.6
|
||||||
|
|
Loading…
Reference in a new issue