merged from gramsrv upstream

This commit is contained in:
onysd 2026-09-01 12:06:31 +03:00
parent 79c64ee916
commit 21a0856587
651 changed files with 54774 additions and 4590 deletions

View file

@ -11,7 +11,7 @@ import (
"telesrv/internal/store/postgres/sqlcgen"
)
// EncryptedQueueStore 是 store.EncryptedQueueStore 的 PostgreSQL 实现(迁移 0138
// EncryptedQueueStore 是 store.EncryptedQueueStore 的 PostgreSQL 实现
// 盲中继 qts 投递队列qts 分配secret_qts_watermarks.reserved_qts 自增)+ 写队列行
// 在单事务内完成,保证设备 qts 无空洞。bytes 原样 BYTEA 存储,永不解密。
type EncryptedQueueStore struct {
@ -135,7 +135,8 @@ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)`,
}
func (s *EncryptedQueueStore) ListEncryptedMessagesSince(ctx context.Context, receiverAuthKeyID int64, sinceQts, limit int) ([]domain.SecretChatMessage, error) {
if limit <= 0 || limit > 1000 {
// RPC difference 以 1000 条为一页,并额外读取 1 条探测 hasMore。
if limit <= 0 || limit > 1001 {
limit = 1000
}
rows, err := s.db.Query(ctx,
@ -206,7 +207,8 @@ RETURNING id`,
}
func (s *EncryptedQueueStore) ListUndeliveredStateEvents(ctx context.Context, targetUserID, deviceAuthKeyID int64, limit int) ([]domain.EncryptedStateEvent, error) {
if limit <= 0 || limit > 1000 {
// RPC difference 以 1000 条为一页,并额外读取 1 条探测 hasMore。
if limit <= 0 || limit > 1001 {
limit = 1000
}
rows, err := s.db.Query(ctx, `