绑定设备身份并分发一次性 MLS 密钥包

This commit is contained in:
xhgit committed 2026-11-13 18:27:10 +08:00
1 parent f30f01b699
commit 0b17dd07c5
11 files changed
+286 -11

No files matched your search

+6 -6
View File
@@ -67,11 +67,7 @@ func (s *Store) Send(ctx context.Context, sender, recipient, message string, cip
// This direct-message endpoint only connects accepted contacts.
// A separate authorization flow is needed for same-account device transfers.
var friends bool
err = tx.QueryRow(ctx, `
SELECT EXISTS (SELECT 1 FROM contact_relationships
WHERE first_user=LEAST($1::uuid,$2::uuid) AND second_user=GREATEST($1::uuid,$2::uuid)
AND status='accepted')
`, senderUser, recipientUser).Scan(&friends)
err = tx.QueryRow(ctx, "SELECT "+acceptedContact, senderUser, recipientUser).Scan(&friends)
if err != nil {
return "", err
}
@@ -126,6 +122,10 @@ func (s *Store) Inbox(ctx context.Context, recipient string, after int64) ([]Env
}
func (s *Store) Cleanup(ctx context.Context, retention time.Duration) error {
_, err := s.db.Exec(ctx, "DELETE FROM device_envelopes WHERE created_at < $1", time.Now().Add(-retention))
if _, err := s.db.Exec(ctx, "DELETE FROM device_envelopes WHERE created_at < $1", time.Now().Add(-retention)); err != nil {
return err
}
// Keep issued package hashes past the validity window of an individual upload.
_, err := s.db.Exec(ctx, "DELETE FROM device_key_packages WHERE created_at < now() - interval '90 days'")
return err
}