fix_: loading hash_ratchet_encryption from database checks group_id

This commit is contained in:
Igor Sirotin 2024-05-08 17:00:15 +01:00 committed by Vit∀ly Vlasov
parent 292070a854
commit da12c52596
1 changed files with 5 additions and 1 deletions

View File

@ -764,7 +764,11 @@ func (s *sqlitePersistence) GetHashRatchetCache(ratchet *HashRatchetKeyCompatibi
}
}
err = tx.QueryRow("SELECT key FROM hash_ratchet_encryption WHERE key_id = ? OR deprecated_key_id = ?", keyID, ratchet.DeprecatedKeyID()).Scan(&key)
err = tx.QueryRow("SELECT key FROM hash_ratchet_encryption WHERE key_id = ? OR (deprecated_key_id = ? AND group_id = ?)",
keyID,
ratchet.DeprecatedKeyID(),
ratchet.GroupID,
).Scan(&key)
if err == sql.ErrNoRows {
return nil, nil
}