自动补充 MLS 一次性密钥包
This commit is contained in:
1 parent
6b728a0996
commit
cf8129f4aa
8 files changed
+69
-11
No files matched your search
@@ -29,6 +29,16 @@ type KeyPackage struct {
|
||||
var ErrSignature = errors.New("invalid key package device signature")
|
||||
var ErrPackageLimit = errors.New("device key package limit reached")
|
||||
|
||||
func (s *Store) AvailablePackages(ctx context.Context, device string) (int, error) {
|
||||
var available int
|
||||
err := s.db.QueryRow(ctx, `
|
||||
SELECT count(*) FROM device_key_packages k JOIN devices d ON d.id=k.device_id
|
||||
WHERE d.id=$1 AND d.revoked_at IS NULL AND k.claimed_at IS NULL
|
||||
AND k.created_at > now() - interval '24 hours'
|
||||
`, device).Scan(&available)
|
||||
return available, err
|
||||
}
|
||||
|
||||
func (s *Store) LocalIdentityKey(ctx context.Context, device string) ([]byte, error) {
|
||||
var key []byte
|
||||
err := s.db.QueryRow(ctx, "SELECT public_key FROM devices WHERE id=$1 AND revoked_at IS NULL", device).Scan(&key)
|
||||
|
||||
Reference in new issue
Block a user