mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
Change megolm session max_age to milliseconds
This commit is contained in:
parent
7e7e805814
commit
cea59a6781
2 changed files with 7 additions and 2 deletions
|
|
@ -14,6 +14,7 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
|
||||
|
|
@ -400,7 +401,7 @@ func (store *SQLCryptoStore) AddOutboundGroupSession(session *OutboundGroupSessi
|
|||
max_messages=excluded.max_messages, message_count=excluded.message_count, max_age=excluded.max_age,
|
||||
created_at=excluded.created_at, last_used=excluded.last_used, account_id=excluded.account_id
|
||||
`, session.RoomID, session.ID(), sessionBytes, session.Shared, session.MaxMessages, session.MessageCount,
|
||||
session.MaxAge, session.CreationTime, session.LastEncryptedTime, store.AccountID)
|
||||
session.MaxAge.Milliseconds(), session.CreationTime, session.LastEncryptedTime, store.AccountID)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
@ -416,11 +417,12 @@ func (store *SQLCryptoStore) UpdateOutboundGroupSession(session *OutboundGroupSe
|
|||
func (store *SQLCryptoStore) GetOutboundGroupSession(roomID id.RoomID) (*OutboundGroupSession, error) {
|
||||
var ogs OutboundGroupSession
|
||||
var sessionBytes []byte
|
||||
var maxAgeMS int64
|
||||
err := store.DB.QueryRow(`
|
||||
SELECT session, shared, max_messages, message_count, max_age, created_at, last_used
|
||||
FROM crypto_megolm_outbound_session WHERE room_id=$1 AND account_id=$2`,
|
||||
roomID, store.AccountID,
|
||||
).Scan(&sessionBytes, &ogs.Shared, &ogs.MaxMessages, &ogs.MessageCount, &ogs.MaxAge, &ogs.CreationTime, &ogs.LastEncryptedTime)
|
||||
).Scan(&sessionBytes, &ogs.Shared, &ogs.MaxMessages, &ogs.MessageCount, &maxAgeMS, &ogs.CreationTime, &ogs.LastEncryptedTime)
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, nil
|
||||
} else if err != nil {
|
||||
|
|
@ -433,6 +435,7 @@ func (store *SQLCryptoStore) GetOutboundGroupSession(roomID id.RoomID) (*Outboun
|
|||
}
|
||||
ogs.Internal = *intOGS
|
||||
ogs.RoomID = roomID
|
||||
ogs.MaxAge = time.Duration(maxAgeMS) * time.Millisecond
|
||||
return &ogs, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
2
crypto/sql_store_upgrade/09-max-age-ms.sql
Normal file
2
crypto/sql_store_upgrade/09-max-age-ms.sql
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
-- v9: Change outbound megolm session max_age column to milliseconds
|
||||
UPDATE crypto_megolm_outbound_session SET max_age=max_age/1000000;
|
||||
Loading…
Add table
Add a link
Reference in a new issue