feat: sync AI compose and ChatBot features
This commit is contained in:
parent
35e5d38f4d
commit
b7269b135f
75 changed files with 5426 additions and 123 deletions
223
internal/store/postgres/ai.go
Normal file
223
internal/store/postgres/ai.go
Normal file
|
|
@ -0,0 +1,223 @@
|
|||
package postgres
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
|
||||
"telesrv/internal/domain"
|
||||
"telesrv/internal/store/postgres/sqlcgen"
|
||||
)
|
||||
|
||||
// AIComposeStore 用 PostgreSQL 实现 store.AIComposeStore。
|
||||
type AIComposeStore struct {
|
||||
db sqlcgen.DBTX
|
||||
}
|
||||
|
||||
func NewAIComposeStore(db sqlcgen.DBTX) *AIComposeStore {
|
||||
return &AIComposeStore{db: db}
|
||||
}
|
||||
|
||||
const aiComposeToneColumns = `id, access_hash, owner_user_id, slug, title, emoji_id, prompt, display_author, installs_count, created_at, updated_at`
|
||||
|
||||
func (s *AIComposeStore) CreateAIComposeTone(ctx context.Context, tone domain.AIComposeTone) error {
|
||||
if tone.ID == 0 || tone.AccessHash == 0 || tone.OwnerUserID == 0 || tone.Slug == "" {
|
||||
return domain.ErrAIComposeToneInvalid
|
||||
}
|
||||
createdAt := time.Now()
|
||||
if tone.CreatedAt > 0 {
|
||||
createdAt = time.Unix(tone.CreatedAt, 0)
|
||||
}
|
||||
updatedAt := createdAt
|
||||
if tone.UpdatedAt > 0 {
|
||||
updatedAt = time.Unix(tone.UpdatedAt, 0)
|
||||
}
|
||||
_, err := s.db.Exec(ctx, `
|
||||
INSERT INTO ai_compose_tones (
|
||||
id, access_hash, owner_user_id, slug, title, emoji_id, prompt, display_author, installs_count, created_at, updated_at
|
||||
) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11)`,
|
||||
tone.ID, tone.AccessHash, tone.OwnerUserID, tone.Slug, tone.Title, tone.EmojiID,
|
||||
tone.Prompt, tone.DisplayAuthor, tone.InstallsCount, createdAt, updatedAt)
|
||||
if err != nil {
|
||||
if isUniqueViolation(err) {
|
||||
return domain.ErrAIComposeToneInvalid
|
||||
}
|
||||
return fmt.Errorf("insert ai compose tone: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *AIComposeStore) UpdateAIComposeTone(ctx context.Context, tone domain.AIComposeTone) error {
|
||||
updatedAt := time.Now()
|
||||
if tone.UpdatedAt > 0 {
|
||||
updatedAt = time.Unix(tone.UpdatedAt, 0)
|
||||
}
|
||||
tag, err := s.db.Exec(ctx, `
|
||||
UPDATE ai_compose_tones
|
||||
SET title = $3, emoji_id = $4, prompt = $5, display_author = $6, updated_at = $7
|
||||
WHERE id = $1 AND owner_user_id = $2`,
|
||||
tone.ID, tone.OwnerUserID, tone.Title, tone.EmojiID, tone.Prompt, tone.DisplayAuthor, updatedAt)
|
||||
if err != nil {
|
||||
return fmt.Errorf("update ai compose tone: %w", err)
|
||||
}
|
||||
if tag.RowsAffected() == 0 {
|
||||
return domain.ErrAIComposeToneNotFound
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *AIComposeStore) DeleteAIComposeTone(ctx context.Context, ownerUserID, toneID int64) error {
|
||||
tag, err := s.db.Exec(ctx, `DELETE FROM ai_compose_tones WHERE id = $1 AND owner_user_id = $2`, toneID, ownerUserID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("delete ai compose tone: %w", err)
|
||||
}
|
||||
if tag.RowsAffected() == 0 {
|
||||
return domain.ErrAIComposeToneNotFound
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *AIComposeStore) GetAIComposeToneByID(ctx context.Context, id, accessHash int64) (domain.AIComposeTone, bool, error) {
|
||||
row := s.db.QueryRow(ctx, `SELECT `+aiComposeToneColumns+` FROM ai_compose_tones WHERE id = $1 AND access_hash = $2`, id, accessHash)
|
||||
tone, err := scanAIComposeTone(row)
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return domain.AIComposeTone{}, false, nil
|
||||
}
|
||||
return domain.AIComposeTone{}, false, fmt.Errorf("get ai compose tone by id: %w", err)
|
||||
}
|
||||
return tone, true, nil
|
||||
}
|
||||
|
||||
func (s *AIComposeStore) GetAIComposeToneBySlug(ctx context.Context, slug string) (domain.AIComposeTone, bool, error) {
|
||||
row := s.db.QueryRow(ctx, `SELECT `+aiComposeToneColumns+` FROM ai_compose_tones WHERE slug = $1`, slug)
|
||||
tone, err := scanAIComposeTone(row)
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return domain.AIComposeTone{}, false, nil
|
||||
}
|
||||
return domain.AIComposeTone{}, false, fmt.Errorf("get ai compose tone by slug: %w", err)
|
||||
}
|
||||
return tone, true, nil
|
||||
}
|
||||
|
||||
func (s *AIComposeStore) ListAIComposeTonesForUser(ctx context.Context, userID int64) ([]domain.AIComposeTone, error) {
|
||||
rows, err := s.db.Query(ctx, `
|
||||
SELECT `+aiComposeToneColumns+`, (owner_user_id = $1) AS creator, true AS saved
|
||||
FROM ai_compose_tones
|
||||
WHERE owner_user_id = $1
|
||||
UNION ALL
|
||||
SELECT `+prefixAIComposeToneColumns("t")+`, false AS creator, true AS saved
|
||||
FROM ai_compose_tones t
|
||||
JOIN ai_compose_tone_saves s ON s.tone_id = t.id
|
||||
WHERE s.user_id = $1 AND t.owner_user_id <> $1
|
||||
ORDER BY creator DESC, updated_at DESC, id ASC`, userID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("list ai compose tones: %w", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
out := make([]domain.AIComposeTone, 0)
|
||||
for rows.Next() {
|
||||
tone, err := scanAIComposeToneWithFlags(rows)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("scan ai compose tone: %w", err)
|
||||
}
|
||||
out = append(out, tone)
|
||||
}
|
||||
return out, rows.Err()
|
||||
}
|
||||
|
||||
func (s *AIComposeStore) SaveAIComposeTone(ctx context.Context, userID, toneID int64) error {
|
||||
return withTx(ctx, s.db, "save ai compose tone", func(tx pgx.Tx) error {
|
||||
var ownerUserID int64
|
||||
if err := tx.QueryRow(ctx, `SELECT owner_user_id FROM ai_compose_tones WHERE id = $1`, toneID).Scan(&ownerUserID); err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return domain.ErrAIComposeToneNotFound
|
||||
}
|
||||
return fmt.Errorf("select ai compose tone owner: %w", err)
|
||||
}
|
||||
if ownerUserID == userID {
|
||||
return nil
|
||||
}
|
||||
tag, err := tx.Exec(ctx, `
|
||||
INSERT INTO ai_compose_tone_saves (user_id, tone_id, saved_at)
|
||||
VALUES ($1,$2,now())
|
||||
ON CONFLICT (user_id, tone_id) DO NOTHING`, userID, toneID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("save ai compose tone: %w", err)
|
||||
}
|
||||
if tag.RowsAffected() > 0 {
|
||||
if _, err := tx.Exec(ctx, `UPDATE ai_compose_tones SET installs_count = installs_count + 1 WHERE id = $1`, toneID); err != nil {
|
||||
return fmt.Errorf("increment ai compose tone installs: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (s *AIComposeStore) UnsaveAIComposeTone(ctx context.Context, userID, toneID int64) error {
|
||||
_, err := s.db.Exec(ctx, `DELETE FROM ai_compose_tone_saves WHERE user_id = $1 AND tone_id = $2`, userID, toneID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unsave ai compose tone: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *AIComposeStore) SavedAIComposeToneCount(ctx context.Context, userID int64) (int, error) {
|
||||
var count int
|
||||
if err := s.db.QueryRow(ctx, `
|
||||
SELECT COUNT(*)::int FROM (
|
||||
SELECT id FROM ai_compose_tones WHERE owner_user_id = $1
|
||||
UNION
|
||||
SELECT tone_id FROM ai_compose_tone_saves WHERE user_id = $1
|
||||
) x`, userID).Scan(&count); err != nil {
|
||||
return 0, fmt.Errorf("count ai compose tones: %w", err)
|
||||
}
|
||||
return count, nil
|
||||
}
|
||||
|
||||
func scanAIComposeTone(row pgx.Row) (domain.AIComposeTone, error) {
|
||||
var (
|
||||
tone domain.AIComposeTone
|
||||
createdAt time.Time
|
||||
updatedAt time.Time
|
||||
)
|
||||
if err := row.Scan(&tone.ID, &tone.AccessHash, &tone.OwnerUserID, &tone.Slug, &tone.Title,
|
||||
&tone.EmojiID, &tone.Prompt, &tone.DisplayAuthor, &tone.InstallsCount, &createdAt, &updatedAt); err != nil {
|
||||
return domain.AIComposeTone{}, err
|
||||
}
|
||||
tone.CreatedAt = createdAt.Unix()
|
||||
tone.UpdatedAt = updatedAt.Unix()
|
||||
if tone.DisplayAuthor {
|
||||
tone.AuthorID = tone.OwnerUserID
|
||||
}
|
||||
return tone, nil
|
||||
}
|
||||
|
||||
func scanAIComposeToneWithFlags(row pgx.Row) (domain.AIComposeTone, error) {
|
||||
var (
|
||||
tone domain.AIComposeTone
|
||||
createdAt time.Time
|
||||
updatedAt time.Time
|
||||
)
|
||||
if err := row.Scan(&tone.ID, &tone.AccessHash, &tone.OwnerUserID, &tone.Slug, &tone.Title,
|
||||
&tone.EmojiID, &tone.Prompt, &tone.DisplayAuthor, &tone.InstallsCount, &createdAt, &updatedAt,
|
||||
&tone.Creator, &tone.Saved); err != nil {
|
||||
return domain.AIComposeTone{}, err
|
||||
}
|
||||
tone.CreatedAt = createdAt.Unix()
|
||||
tone.UpdatedAt = updatedAt.Unix()
|
||||
if tone.DisplayAuthor {
|
||||
tone.AuthorID = tone.OwnerUserID
|
||||
}
|
||||
return tone, nil
|
||||
}
|
||||
|
||||
func prefixAIComposeToneColumns(prefix string) string {
|
||||
return prefix + `.id, ` + prefix + `.access_hash, ` + prefix + `.owner_user_id, ` +
|
||||
prefix + `.slug, ` + prefix + `.title, ` + prefix + `.emoji_id, ` + prefix + `.prompt, ` +
|
||||
prefix + `.display_author, ` + prefix + `.installs_count, ` + prefix + `.created_at, ` + prefix + `.updated_at`
|
||||
}
|
||||
86
internal/store/postgres/ai_integration_test.go
Normal file
86
internal/store/postgres/ai_integration_test.go
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
package postgres
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/binary"
|
||||
"testing"
|
||||
|
||||
"telesrv/internal/domain"
|
||||
)
|
||||
|
||||
// TestAIComposeStoreRoundTripPostgres 验证自定义 AI tone 与保存列表持久化,
|
||||
// 含 creator/saved 视角、slug/id 解析和删除级联。
|
||||
func TestAIComposeStoreRoundTripPostgres(t *testing.T) {
|
||||
pool := testPool(t)
|
||||
ctx := context.Background()
|
||||
store := NewAIComposeStore(pool)
|
||||
users := NewUserStore(pool)
|
||||
suffix := randomSuffix(t)
|
||||
|
||||
owner, err := users.Create(ctx, domain.User{AccessHash: randomAIComposeID(), Phone: "+1771" + suffix + "01", FirstName: "AIOwner"})
|
||||
if err != nil {
|
||||
t.Fatalf("create owner: %v", err)
|
||||
}
|
||||
other, err := users.Create(ctx, domain.User{AccessHash: randomAIComposeID(), Phone: "+1771" + suffix + "02", FirstName: "AISaver"})
|
||||
if err != nil {
|
||||
t.Fatalf("create other: %v", err)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
_, _ = pool.Exec(ctx, "DELETE FROM users WHERE id = ANY($1)", []int64{owner.ID, other.ID})
|
||||
})
|
||||
|
||||
tone := domain.AIComposeTone{
|
||||
ID: randomAIComposeID(),
|
||||
AccessHash: randomAIComposeID(),
|
||||
OwnerUserID: owner.ID,
|
||||
Slug: "ai-pg-" + suffix,
|
||||
Title: "Sharp",
|
||||
Prompt: "Make it direct and crisp.",
|
||||
DisplayAuthor: true,
|
||||
CreatedAt: 1700000000,
|
||||
UpdatedAt: 1700000000,
|
||||
}
|
||||
if err := store.CreateAIComposeTone(ctx, tone); err != nil {
|
||||
t.Fatalf("create tone: %v", err)
|
||||
}
|
||||
if got, ok, err := store.GetAIComposeToneByID(ctx, tone.ID, tone.AccessHash); err != nil || !ok || got.Slug != tone.Slug || got.AuthorID != owner.ID {
|
||||
t.Fatalf("get by id = ok %v tone %#v err %v", ok, got, err)
|
||||
}
|
||||
if err := store.SaveAIComposeTone(ctx, other.ID, tone.ID); err != nil {
|
||||
t.Fatalf("save tone: %v", err)
|
||||
}
|
||||
list, err := store.ListAIComposeTonesForUser(ctx, other.ID)
|
||||
if err != nil || len(list) != 1 {
|
||||
t.Fatalf("list saved = %d err %v, want 1", len(list), err)
|
||||
}
|
||||
if list[0].ID != tone.ID || !list[0].Saved || list[0].Creator {
|
||||
t.Fatalf("saved view = %#v, want saved non-creator", list[0])
|
||||
}
|
||||
if got, ok, err := store.GetAIComposeToneBySlug(ctx, tone.Slug); err != nil || !ok || got.InstallsCount != 1 {
|
||||
t.Fatalf("get by slug installs = ok %v tone %#v err %v, want installs=1", ok, got, err)
|
||||
}
|
||||
if count, err := store.SavedAIComposeToneCount(ctx, other.ID); err != nil || count != 1 {
|
||||
t.Fatalf("saved count = %d err %v, want 1", count, err)
|
||||
}
|
||||
if err := store.DeleteAIComposeTone(ctx, owner.ID, tone.ID); err != nil {
|
||||
t.Fatalf("delete tone: %v", err)
|
||||
}
|
||||
if _, ok, err := store.GetAIComposeToneBySlug(ctx, tone.Slug); err != nil || ok {
|
||||
t.Fatalf("get after delete = ok %v err %v, want missing", ok, err)
|
||||
}
|
||||
if list, err := store.ListAIComposeTonesForUser(ctx, other.ID); err != nil || len(list) != 0 {
|
||||
t.Fatalf("list after delete = %d err %v, want empty", len(list), err)
|
||||
}
|
||||
}
|
||||
|
||||
func randomAIComposeID() int64 {
|
||||
for {
|
||||
var b [8]byte
|
||||
_, _ = rand.Read(b[:])
|
||||
v := int64(binary.BigEndian.Uint64(b[:]) & 0x7fffffffffffffff)
|
||||
if v != 0 {
|
||||
return v
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -219,6 +219,7 @@ func (s *DialogStore) ListByUser(ctx context.Context, userID int64, filter domai
|
|||
From: domain.Peer{Type: domain.PeerTypeUser, ID: row.MessageFromUserID},
|
||||
Date: int(row.MessageDate),
|
||||
EditDate: int(row.MessageEditDate),
|
||||
HideEdited: row.MessageHideEdited,
|
||||
Out: row.MessageOutgoing,
|
||||
Silent: silent,
|
||||
NoForwards: noforwards,
|
||||
|
|
@ -371,6 +372,7 @@ func (s *DialogStore) ListByPeers(ctx context.Context, userID int64, peers []dom
|
|||
From: domain.Peer{Type: domain.PeerTypeUser, ID: row.MessageFromUserID},
|
||||
Date: int(row.MessageDate),
|
||||
EditDate: int(row.MessageEditDate),
|
||||
HideEdited: row.MessageHideEdited,
|
||||
Out: row.MessageOutgoing,
|
||||
Silent: silent,
|
||||
NoForwards: noforwards,
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ func (s *MessageStore) EditMessage(ctx context.Context, req domain.EditMessageRe
|
|||
if !authorEdit && !viaBotEdit && !req.WebPageResolve && !validTodoParticipantEdit(req, target, oldEntities) {
|
||||
return res, domain.ErrMessageAuthorRequired
|
||||
}
|
||||
if req.Media == nil && !req.SetReplyMarkup && target.Body == req.Message && sameMessageEntities(oldEntities, req.Entities) {
|
||||
if req.Media == nil && !req.SetReplyMarkup && target.Body == req.Message && target.HideEdited == req.HideEdited && sameMessageEntities(oldEntities, req.Entities) {
|
||||
return res, domain.ErrMessageNotModified
|
||||
}
|
||||
replyMarkupJSON, err := encodeReplyMarkup(req.ReplyMarkup)
|
||||
|
|
@ -170,6 +170,7 @@ WHERE owner_user_id = $1 AND box_id = $2`, box.OwnerUserID, box.BoxID, int32(pts
|
|||
Body: req.Message,
|
||||
EntitiesJson: entities,
|
||||
EditDate: int32(req.EditDate),
|
||||
HideEdited: req.HideEdited,
|
||||
SetReplyMarkup: req.SetReplyMarkup,
|
||||
ReplyMarkupJson: replyMarkupJSON,
|
||||
}); err != nil {
|
||||
|
|
@ -205,6 +206,7 @@ WHERE message_sender_id = $1 AND private_message_id = $2`, messageSenderID, targ
|
|||
Body: req.Message,
|
||||
EntitiesJson: entities,
|
||||
EditDate: int32(req.EditDate),
|
||||
HideEdited: req.HideEdited,
|
||||
Pts: int32(pts),
|
||||
SetReplyMarkup: req.SetReplyMarkup,
|
||||
ReplyMarkupJson: replyMarkupJSON,
|
||||
|
|
|
|||
|
|
@ -149,6 +149,7 @@ func messageFromForwardRow(row sqlcgen.GetMessageBoxesForForwardRow) (domain.Mes
|
|||
From: domain.Peer{Type: domain.PeerTypeUser, ID: row.FromUserID},
|
||||
Date: int(row.MessageDate),
|
||||
EditDate: int(row.EditDate),
|
||||
HideEdited: row.HideEdited,
|
||||
Out: row.Outgoing,
|
||||
Silent: silent,
|
||||
NoForwards: noforwards,
|
||||
|
|
|
|||
|
|
@ -206,6 +206,7 @@ func (s *MessageStore) ListByUser(ctx context.Context, userID int64, filter doma
|
|||
From: domain.Peer{Type: domain.PeerTypeUser, ID: row.FromUserID},
|
||||
Date: int(row.MessageDate),
|
||||
EditDate: int(row.EditDate),
|
||||
HideEdited: row.HideEdited,
|
||||
Out: row.Outgoing,
|
||||
Silent: silent,
|
||||
NoForwards: noforwards,
|
||||
|
|
@ -585,6 +586,7 @@ func messageFromBoxRow(row sqlcgen.CreateMessageBoxRow) domain.Message {
|
|||
From: domain.Peer{Type: domain.PeerTypeUser, ID: row.FromUserID},
|
||||
Date: int(row.MessageDate),
|
||||
EditDate: int(row.EditDate),
|
||||
HideEdited: row.HideEdited,
|
||||
Out: row.Outgoing,
|
||||
Silent: silent,
|
||||
NoForwards: noforwards,
|
||||
|
|
@ -640,6 +642,7 @@ func messageFromGetBoxRow(row sqlcgen.GetMessageBoxByPrivateMessageRow) domain.M
|
|||
From: domain.Peer{Type: domain.PeerTypeUser, ID: row.FromUserID},
|
||||
Date: int(row.MessageDate),
|
||||
EditDate: int(row.EditDate),
|
||||
HideEdited: row.HideEdited,
|
||||
Out: row.Outgoing,
|
||||
Silent: silent,
|
||||
NoForwards: noforwards,
|
||||
|
|
@ -710,6 +713,7 @@ func messageFromVisibleBoxRow(row sqlcgen.ListVisibleMessageBoxesByPrivateMessag
|
|||
From: domain.Peer{Type: domain.PeerTypeUser, ID: row.FromUserID},
|
||||
Date: int(row.MessageDate),
|
||||
EditDate: int(row.EditDate),
|
||||
HideEdited: row.HideEdited,
|
||||
Out: row.Outgoing,
|
||||
Silent: silent,
|
||||
NoForwards: noforwards,
|
||||
|
|
@ -780,6 +784,7 @@ func messageFromUpdateEditRow(row sqlcgen.UpdateMessageBoxEditRow) (domain.Messa
|
|||
From: domain.Peer{Type: domain.PeerTypeUser, ID: row.FromUserID},
|
||||
Date: int(row.MessageDate),
|
||||
EditDate: int(row.EditDate),
|
||||
HideEdited: row.HideEdited,
|
||||
Out: row.Outgoing,
|
||||
Silent: silent,
|
||||
NoForwards: noforwards,
|
||||
|
|
@ -850,6 +855,7 @@ func messageFromIDRow(row sqlcgen.GetMessageBoxesByIDsRow) (domain.Message, erro
|
|||
From: domain.Peer{Type: domain.PeerTypeUser, ID: row.FromUserID},
|
||||
Date: int(row.MessageDate),
|
||||
EditDate: int(row.EditDate),
|
||||
HideEdited: row.HideEdited,
|
||||
Out: row.Outgoing,
|
||||
Silent: silent,
|
||||
NoForwards: noforwards,
|
||||
|
|
@ -896,6 +902,7 @@ func backwardRowToByUserRow(r sqlcgen.ListMessagesBackwardRow) sqlcgen.ListMessa
|
|||
TtlPeriod: r.TtlPeriod,
|
||||
ExpiresAt: r.ExpiresAt,
|
||||
EditDate: r.EditDate,
|
||||
HideEdited: r.HideEdited,
|
||||
Outgoing: r.Outgoing,
|
||||
Body: r.Body,
|
||||
EntitiesJson: r.EntitiesJson,
|
||||
|
|
|
|||
|
|
@ -107,6 +107,79 @@ func TestMessageStoreReadAndEditEmitDurableEvents(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestMessageStoreEditCanHideEditedBadge(t *testing.T) {
|
||||
pool := testPool(t)
|
||||
ctx := context.Background()
|
||||
suffix := randomSuffix(t)
|
||||
|
||||
users := NewUserStore(pool)
|
||||
sender, err := users.Create(ctx, domain.User{
|
||||
AccessHash: 331,
|
||||
Phone: "+1666" + suffix + "31",
|
||||
FirstName: "HiddenEditSender",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("create sender: %v", err)
|
||||
}
|
||||
recipient, err := users.Create(ctx, domain.User{
|
||||
AccessHash: 332,
|
||||
Phone: "+1666" + suffix + "32",
|
||||
FirstName: "HiddenEditRecipient",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("create recipient: %v", err)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
_, _ = pool.Exec(ctx, "DELETE FROM users WHERE id = ANY($1::bigint[])", []int64{sender.ID, recipient.ID})
|
||||
})
|
||||
|
||||
messages := NewMessageStore(pool)
|
||||
sent, err := messages.SendPrivateText(ctx, domain.SendPrivateTextRequest{
|
||||
SenderUserID: sender.ID,
|
||||
RecipientUserID: recipient.ID,
|
||||
RandomID: 223399,
|
||||
Message: "...",
|
||||
Date: 1700000400,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("SendPrivateText: %v", err)
|
||||
}
|
||||
edited, err := messages.EditMessage(ctx, domain.EditMessageRequest{
|
||||
OwnerUserID: sender.ID,
|
||||
Peer: domain.Peer{Type: domain.PeerTypeUser, ID: recipient.ID},
|
||||
ID: sent.SenderMessage.ID,
|
||||
Message: "streamed answer",
|
||||
EditDate: 1700000405,
|
||||
HideEdited: true,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("EditMessage: %v", err)
|
||||
}
|
||||
if self := edited.Self(); self.Message.Body != "streamed answer" || !self.Message.HideEdited {
|
||||
t.Fatalf("self hidden edit = %+v, want hidden edited message", self)
|
||||
}
|
||||
|
||||
history, err := messages.ListByUser(ctx, recipient.ID, domain.MessageFilter{
|
||||
HasPeer: true,
|
||||
Peer: domain.Peer{Type: domain.PeerTypeUser, ID: sender.ID},
|
||||
Limit: 10,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("recipient history: %v", err)
|
||||
}
|
||||
if len(history.Messages) != 1 || history.Messages[0].Body != "streamed answer" || !history.Messages[0].HideEdited {
|
||||
t.Fatalf("recipient history = %+v, want hidden edited message", history.Messages)
|
||||
}
|
||||
|
||||
events, err := NewUpdateEventStore(pool).ListAfter(ctx, recipient.ID, 0, 10)
|
||||
if err != nil {
|
||||
t.Fatalf("recipient events: %v", err)
|
||||
}
|
||||
if len(events) != 2 || events[1].Type != domain.UpdateEventEditMessage || !events[1].Message.HideEdited {
|
||||
t.Fatalf("recipient events = %+v, want hidden edit event", events)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMessageStoreReadHistoryStaleUnreadRepairDoesNotAppendPts(t *testing.T) {
|
||||
pool := testPool(t)
|
||||
ctx := context.Background()
|
||||
|
|
|
|||
|
|
@ -642,6 +642,7 @@ func messageFromCreateRow(row sqlcgen.CreateMessageRow) (domain.Message, error)
|
|||
From: domain.Peer{Type: domain.PeerTypeUser, ID: row.FromUserID},
|
||||
Date: int(row.MessageDate),
|
||||
EditDate: int(row.EditDate),
|
||||
HideEdited: row.HideEdited,
|
||||
Out: row.Outgoing,
|
||||
Body: row.Body,
|
||||
Entities: entities,
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ WITH base AS (
|
|||
COALESCE(m.ttl_period, 0)::int AS message_ttl_period,
|
||||
COALESCE(m.expires_at, 0)::int AS message_expires_at,
|
||||
COALESCE(m.edit_date, 0)::int AS message_edit_date,
|
||||
COALESCE(m.hide_edited, false)::boolean AS message_hide_edited,
|
||||
COALESCE(m.silent, false)::boolean AS message_silent,
|
||||
COALESCE(m.noforwards, false)::boolean AS message_noforwards,
|
||||
COALESCE(m.reply_to_msg_id, 0)::int AS message_reply_to_msg_id,
|
||||
|
|
@ -212,6 +213,7 @@ SELECT
|
|||
message_ttl_period,
|
||||
message_expires_at,
|
||||
message_edit_date,
|
||||
message_hide_edited,
|
||||
message_silent,
|
||||
message_noforwards,
|
||||
message_reply_to_msg_id,
|
||||
|
|
@ -388,6 +390,7 @@ base AS (
|
|||
COALESCE(m.ttl_period, 0)::int AS message_ttl_period,
|
||||
COALESCE(m.expires_at, 0)::int AS message_expires_at,
|
||||
COALESCE(m.edit_date, 0)::int AS message_edit_date,
|
||||
COALESCE(m.hide_edited, false)::boolean AS message_hide_edited,
|
||||
COALESCE(m.silent, false)::boolean AS message_silent,
|
||||
COALESCE(m.noforwards, false)::boolean AS message_noforwards,
|
||||
COALESCE(m.reply_to_msg_id, 0)::int AS message_reply_to_msg_id,
|
||||
|
|
@ -472,6 +475,7 @@ SELECT
|
|||
message_ttl_period,
|
||||
message_expires_at,
|
||||
message_edit_date,
|
||||
message_hide_edited,
|
||||
message_silent,
|
||||
message_noforwards,
|
||||
message_reply_to_msg_id,
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ box AS (
|
|||
from_user_id,
|
||||
message_date,
|
||||
edit_date,
|
||||
hide_edited,
|
||||
outgoing,
|
||||
body,
|
||||
entities::text AS entities_json,
|
||||
|
|
@ -69,6 +70,7 @@ SELECT
|
|||
from_user_id,
|
||||
message_date,
|
||||
edit_date,
|
||||
hide_edited,
|
||||
outgoing,
|
||||
body,
|
||||
entities_json,
|
||||
|
|
@ -246,6 +248,7 @@ RETURNING
|
|||
ttl_period,
|
||||
expires_at,
|
||||
edit_date,
|
||||
hide_edited,
|
||||
outgoing,
|
||||
body,
|
||||
entities::text AS entities_json,
|
||||
|
|
@ -291,6 +294,7 @@ SELECT
|
|||
ttl_period,
|
||||
expires_at,
|
||||
edit_date,
|
||||
hide_edited,
|
||||
outgoing,
|
||||
body,
|
||||
entities::text AS entities_json,
|
||||
|
|
@ -361,6 +365,7 @@ SELECT
|
|||
m.ttl_period,
|
||||
m.expires_at,
|
||||
m.edit_date,
|
||||
m.hide_edited,
|
||||
m.outgoing,
|
||||
m.body,
|
||||
m.entities::text AS entities_json,
|
||||
|
|
@ -429,6 +434,7 @@ base AS NOT MATERIALIZED (
|
|||
m.ttl_period,
|
||||
m.expires_at,
|
||||
m.edit_date,
|
||||
m.hide_edited,
|
||||
m.outgoing,
|
||||
m.body,
|
||||
m.entities::text AS entities_json,
|
||||
|
|
@ -604,6 +610,7 @@ SELECT
|
|||
ttl_period,
|
||||
expires_at,
|
||||
edit_date,
|
||||
hide_edited,
|
||||
outgoing,
|
||||
body,
|
||||
entities_json,
|
||||
|
|
@ -688,6 +695,7 @@ SELECT
|
|||
m.ttl_period,
|
||||
m.expires_at,
|
||||
m.edit_date,
|
||||
m.hide_edited,
|
||||
m.outgoing,
|
||||
m.body,
|
||||
m.entities::text AS entities_json,
|
||||
|
|
@ -838,6 +846,7 @@ SELECT
|
|||
m.ttl_period,
|
||||
m.expires_at,
|
||||
m.edit_date,
|
||||
m.hide_edited,
|
||||
m.outgoing,
|
||||
m.body,
|
||||
m.entities::text AS entities_json,
|
||||
|
|
@ -922,6 +931,7 @@ SELECT
|
|||
ttl_period,
|
||||
expires_at,
|
||||
edit_date,
|
||||
hide_edited,
|
||||
outgoing,
|
||||
body,
|
||||
entities::text AS entities_json,
|
||||
|
|
@ -976,6 +986,7 @@ SELECT
|
|||
ttl_period,
|
||||
expires_at,
|
||||
edit_date,
|
||||
hide_edited,
|
||||
outgoing,
|
||||
body,
|
||||
entities::text AS entities_json,
|
||||
|
|
@ -1021,6 +1032,7 @@ UPDATE private_messages
|
|||
SET body = sqlc.arg(body)::text,
|
||||
entities = sqlc.arg(entities_json)::jsonb,
|
||||
edit_date = sqlc.arg(edit_date)::int,
|
||||
hide_edited = sqlc.arg(hide_edited)::boolean,
|
||||
reply_markup = CASE
|
||||
WHEN sqlc.arg(set_reply_markup)::boolean THEN sqlc.arg(reply_markup_json)::jsonb
|
||||
ELSE reply_markup
|
||||
|
|
@ -1033,6 +1045,7 @@ UPDATE message_boxes
|
|||
SET body = sqlc.arg(body)::text,
|
||||
entities = sqlc.arg(entities_json)::jsonb,
|
||||
edit_date = sqlc.arg(edit_date)::int,
|
||||
hide_edited = sqlc.arg(hide_edited)::boolean,
|
||||
pts = sqlc.arg(pts)::int,
|
||||
reply_markup = CASE
|
||||
WHEN sqlc.arg(set_reply_markup)::boolean THEN sqlc.arg(reply_markup_json)::jsonb
|
||||
|
|
@ -1053,6 +1066,7 @@ RETURNING
|
|||
ttl_period,
|
||||
expires_at,
|
||||
edit_date,
|
||||
hide_edited,
|
||||
outgoing,
|
||||
body,
|
||||
entities::text AS entities_json,
|
||||
|
|
@ -1351,6 +1365,7 @@ SELECT
|
|||
ttl_period,
|
||||
expires_at,
|
||||
edit_date,
|
||||
hide_edited,
|
||||
outgoing,
|
||||
body,
|
||||
entities::text AS entities_json,
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ SELECT
|
|||
m.ttl_period,
|
||||
m.expires_at,
|
||||
m.edit_date,
|
||||
m.hide_edited,
|
||||
m.outgoing,
|
||||
m.body,
|
||||
m.entities::text AS entities_json,
|
||||
|
|
@ -98,6 +99,7 @@ SELECT
|
|||
m.ttl_period,
|
||||
m.expires_at,
|
||||
m.edit_date,
|
||||
m.hide_edited,
|
||||
m.outgoing,
|
||||
m.body,
|
||||
m.entities::text AS entities_json,
|
||||
|
|
@ -174,6 +176,7 @@ SELECT
|
|||
m.ttl_period,
|
||||
m.expires_at,
|
||||
m.edit_date,
|
||||
m.hide_edited,
|
||||
m.outgoing,
|
||||
m.body,
|
||||
m.entities::text AS entities_json,
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ SELECT
|
|||
COALESCE(m.ttl_period, 0)::int AS ttl_period,
|
||||
COALESCE(m.expires_at, 0)::int AS expires_at,
|
||||
COALESCE(m.edit_date, 0)::int AS edit_date,
|
||||
COALESCE(m.hide_edited, false)::boolean AS hide_edited,
|
||||
COALESCE(m.outgoing, false)::boolean AS outgoing,
|
||||
COALESCE(m.body, '')::text AS body,
|
||||
COALESCE(m.entities::text, '[]')::text AS message_entities_json,
|
||||
|
|
@ -292,6 +293,7 @@ SELECT
|
|||
COALESCE(m.ttl_period, 0)::int AS ttl_period,
|
||||
COALESCE(m.expires_at, 0)::int AS expires_at,
|
||||
COALESCE(m.edit_date, 0)::int AS edit_date,
|
||||
COALESCE(m.hide_edited, false)::boolean AS hide_edited,
|
||||
COALESCE(m.outgoing, false)::boolean AS outgoing,
|
||||
COALESCE(m.body, '')::text AS body,
|
||||
COALESCE(m.entities::text, '[]')::text AS message_entities_json,
|
||||
|
|
|
|||
|
|
@ -363,6 +363,7 @@ type savedDialogTopRowFields struct {
|
|||
TtlPeriod int32
|
||||
ExpiresAt int32
|
||||
EditDate int32
|
||||
HideEdited bool
|
||||
Outgoing bool
|
||||
Body string
|
||||
EntitiesJson string
|
||||
|
|
@ -400,11 +401,11 @@ type savedDialogTopRowFields struct {
|
|||
func savedDialogRowFields[T sqlcgen.ListSavedDialogTopsRow | sqlcgen.ListPinnedSavedDialogTopsRow | sqlcgen.ListSavedDialogTopsByPeersRow](row T) savedDialogTopRowFields {
|
||||
switch r := any(row).(type) {
|
||||
case sqlcgen.ListSavedDialogTopsRow:
|
||||
return savedDialogTopRowFields{r.BoxID, r.PrivateMessageID, r.OwnerUserID, r.PeerType, r.PeerID, r.FromUserID, r.MessageDate, r.TtlPeriod, r.ExpiresAt, r.EditDate, r.Outgoing, r.Body, r.EntitiesJson, r.Silent, r.Noforwards, r.ReplyToMsgID, r.ReplyToPeerType, r.ReplyToPeerID, r.ReplyToTopID, r.ReplyToStoryID, r.QuoteText, r.QuoteEntitiesJson, r.QuoteOffset, r.FwdFromPeerType, r.FwdFromPeerID, r.FwdFromName, r.FwdDate, r.FwdSavedFromPeerType, r.FwdSavedFromPeerID, r.FwdSavedFromMsgID, r.SavedPeerType, r.SavedPeerID, r.Pts, r.MediaJson, r.MediaUnread, r.ReactionUnread, r.ViaBotID, r.GroupedID, r.Effect, r.ReplyMarkupJson, r.RichMessageJson, r.Pinned}
|
||||
return savedDialogTopRowFields{r.BoxID, r.PrivateMessageID, r.OwnerUserID, r.PeerType, r.PeerID, r.FromUserID, r.MessageDate, r.TtlPeriod, r.ExpiresAt, r.EditDate, r.HideEdited, r.Outgoing, r.Body, r.EntitiesJson, r.Silent, r.Noforwards, r.ReplyToMsgID, r.ReplyToPeerType, r.ReplyToPeerID, r.ReplyToTopID, r.ReplyToStoryID, r.QuoteText, r.QuoteEntitiesJson, r.QuoteOffset, r.FwdFromPeerType, r.FwdFromPeerID, r.FwdFromName, r.FwdDate, r.FwdSavedFromPeerType, r.FwdSavedFromPeerID, r.FwdSavedFromMsgID, r.SavedPeerType, r.SavedPeerID, r.Pts, r.MediaJson, r.MediaUnread, r.ReactionUnread, r.ViaBotID, r.GroupedID, r.Effect, r.ReplyMarkupJson, r.RichMessageJson, r.Pinned}
|
||||
case sqlcgen.ListPinnedSavedDialogTopsRow:
|
||||
return savedDialogTopRowFields{r.BoxID, r.PrivateMessageID, r.OwnerUserID, r.PeerType, r.PeerID, r.FromUserID, r.MessageDate, r.TtlPeriod, r.ExpiresAt, r.EditDate, r.Outgoing, r.Body, r.EntitiesJson, r.Silent, r.Noforwards, r.ReplyToMsgID, r.ReplyToPeerType, r.ReplyToPeerID, r.ReplyToTopID, r.ReplyToStoryID, r.QuoteText, r.QuoteEntitiesJson, r.QuoteOffset, r.FwdFromPeerType, r.FwdFromPeerID, r.FwdFromName, r.FwdDate, r.FwdSavedFromPeerType, r.FwdSavedFromPeerID, r.FwdSavedFromMsgID, r.SavedPeerType, r.SavedPeerID, r.Pts, r.MediaJson, r.MediaUnread, r.ReactionUnread, r.ViaBotID, r.GroupedID, r.Effect, r.ReplyMarkupJson, r.RichMessageJson, r.Pinned}
|
||||
return savedDialogTopRowFields{r.BoxID, r.PrivateMessageID, r.OwnerUserID, r.PeerType, r.PeerID, r.FromUserID, r.MessageDate, r.TtlPeriod, r.ExpiresAt, r.EditDate, r.HideEdited, r.Outgoing, r.Body, r.EntitiesJson, r.Silent, r.Noforwards, r.ReplyToMsgID, r.ReplyToPeerType, r.ReplyToPeerID, r.ReplyToTopID, r.ReplyToStoryID, r.QuoteText, r.QuoteEntitiesJson, r.QuoteOffset, r.FwdFromPeerType, r.FwdFromPeerID, r.FwdFromName, r.FwdDate, r.FwdSavedFromPeerType, r.FwdSavedFromPeerID, r.FwdSavedFromMsgID, r.SavedPeerType, r.SavedPeerID, r.Pts, r.MediaJson, r.MediaUnread, r.ReactionUnread, r.ViaBotID, r.GroupedID, r.Effect, r.ReplyMarkupJson, r.RichMessageJson, r.Pinned}
|
||||
case sqlcgen.ListSavedDialogTopsByPeersRow:
|
||||
return savedDialogTopRowFields{r.BoxID, r.PrivateMessageID, r.OwnerUserID, r.PeerType, r.PeerID, r.FromUserID, r.MessageDate, r.TtlPeriod, r.ExpiresAt, r.EditDate, r.Outgoing, r.Body, r.EntitiesJson, r.Silent, r.Noforwards, r.ReplyToMsgID, r.ReplyToPeerType, r.ReplyToPeerID, r.ReplyToTopID, r.ReplyToStoryID, r.QuoteText, r.QuoteEntitiesJson, r.QuoteOffset, r.FwdFromPeerType, r.FwdFromPeerID, r.FwdFromName, r.FwdDate, r.FwdSavedFromPeerType, r.FwdSavedFromPeerID, r.FwdSavedFromMsgID, r.SavedPeerType, r.SavedPeerID, r.Pts, r.MediaJson, r.MediaUnread, r.ReactionUnread, r.ViaBotID, r.GroupedID, r.Effect, r.ReplyMarkupJson, r.RichMessageJson, r.Pinned}
|
||||
return savedDialogTopRowFields{r.BoxID, r.PrivateMessageID, r.OwnerUserID, r.PeerType, r.PeerID, r.FromUserID, r.MessageDate, r.TtlPeriod, r.ExpiresAt, r.EditDate, r.HideEdited, r.Outgoing, r.Body, r.EntitiesJson, r.Silent, r.Noforwards, r.ReplyToMsgID, r.ReplyToPeerType, r.ReplyToPeerID, r.ReplyToTopID, r.ReplyToStoryID, r.QuoteText, r.QuoteEntitiesJson, r.QuoteOffset, r.FwdFromPeerType, r.FwdFromPeerID, r.FwdFromName, r.FwdDate, r.FwdSavedFromPeerType, r.FwdSavedFromPeerID, r.FwdSavedFromMsgID, r.SavedPeerType, r.SavedPeerID, r.Pts, r.MediaJson, r.MediaUnread, r.ReactionUnread, r.ViaBotID, r.GroupedID, r.Effect, r.ReplyMarkupJson, r.RichMessageJson, r.Pinned}
|
||||
}
|
||||
return savedDialogTopRowFields{}
|
||||
}
|
||||
|
|
@ -456,6 +457,7 @@ func messageFromSavedDialogRow(row savedDialogTopRowFields) (domain.Message, err
|
|||
From: domain.Peer{Type: domain.PeerTypeUser, ID: row.FromUserID},
|
||||
Date: int(row.MessageDate),
|
||||
EditDate: int(row.EditDate),
|
||||
HideEdited: row.HideEdited,
|
||||
Out: row.Outgoing,
|
||||
Silent: silent,
|
||||
NoForwards: noforwards,
|
||||
|
|
|
|||
|
|
@ -712,6 +712,7 @@ base AS (
|
|||
COALESCE(m.ttl_period, 0)::int AS message_ttl_period,
|
||||
COALESCE(m.expires_at, 0)::int AS message_expires_at,
|
||||
COALESCE(m.edit_date, 0)::int AS message_edit_date,
|
||||
COALESCE(m.hide_edited, false)::boolean AS message_hide_edited,
|
||||
COALESCE(m.silent, false)::boolean AS message_silent,
|
||||
COALESCE(m.noforwards, false)::boolean AS message_noforwards,
|
||||
COALESCE(m.reply_to_msg_id, 0)::int AS message_reply_to_msg_id,
|
||||
|
|
@ -796,6 +797,7 @@ SELECT
|
|||
message_ttl_period,
|
||||
message_expires_at,
|
||||
message_edit_date,
|
||||
message_hide_edited,
|
||||
message_silent,
|
||||
message_noforwards,
|
||||
message_reply_to_msg_id,
|
||||
|
|
@ -880,6 +882,7 @@ type ListDialogsByPeersRow struct {
|
|||
MessageTtlPeriod int32
|
||||
MessageExpiresAt int32
|
||||
MessageEditDate int32
|
||||
MessageHideEdited bool
|
||||
MessageSilent bool
|
||||
MessageNoforwards bool
|
||||
MessageReplyToMsgID int32
|
||||
|
|
@ -965,6 +968,7 @@ func (q *Queries) ListDialogsByPeers(ctx context.Context, arg ListDialogsByPeers
|
|||
&i.MessageTtlPeriod,
|
||||
&i.MessageExpiresAt,
|
||||
&i.MessageEditDate,
|
||||
&i.MessageHideEdited,
|
||||
&i.MessageSilent,
|
||||
&i.MessageNoforwards,
|
||||
&i.MessageReplyToMsgID,
|
||||
|
|
@ -1052,6 +1056,7 @@ WITH base AS (
|
|||
COALESCE(m.ttl_period, 0)::int AS message_ttl_period,
|
||||
COALESCE(m.expires_at, 0)::int AS message_expires_at,
|
||||
COALESCE(m.edit_date, 0)::int AS message_edit_date,
|
||||
COALESCE(m.hide_edited, false)::boolean AS message_hide_edited,
|
||||
COALESCE(m.silent, false)::boolean AS message_silent,
|
||||
COALESCE(m.noforwards, false)::boolean AS message_noforwards,
|
||||
COALESCE(m.reply_to_msg_id, 0)::int AS message_reply_to_msg_id,
|
||||
|
|
@ -1134,7 +1139,7 @@ WITH base AS (
|
|||
AND (NOT $16::boolean OR NOT d.pinned)
|
||||
),
|
||||
paged AS (
|
||||
SELECT user_id, peer_type, peer_id, folder_id, top_message_id, top_message_date, read_inbox_max_id, read_outbox_max_id, unread_count, unread_mentions_count, unread_reactions_count, ttl_period, theme_emoticon, has_scheduled, pinned, pinned_order, unread_mark, hidden_peer_settings_bar, peer_user_id, peer_access_hash, peer_phone, peer_first_name, peer_last_name, peer_username, peer_country_code, peer_verified, peer_support, peer_is_bot, peer_bot_info_version, peer_premium_until, peer_emoji_status_document_id, peer_emoji_status_until, peer_last_seen_at, peer_contact, peer_mutual, message_id, message_private_message_id, message_from_user_id, message_date, message_outgoing, message_body, message_entities_json, message_media_json, message_ttl_period, message_expires_at, message_edit_date, message_silent, message_noforwards, message_reply_to_msg_id, message_reply_to_peer_type, message_reply_to_peer_id, message_reply_to_top_id, message_reply_to_story_id, message_quote_text, message_quote_entities_json, message_quote_offset, message_fwd_from_peer_type, message_fwd_from_peer_id, message_fwd_from_name, message_fwd_date, message_fwd_saved_from_peer_type, message_fwd_saved_from_peer_id, message_fwd_saved_from_msg_id, message_saved_peer_type, message_saved_peer_id, message_media_unread, message_reaction_unread, message_via_bot_id, message_grouped_id, message_effect, message_reply_markup_json, message_rich_message_json, message_pinned
|
||||
SELECT user_id, peer_type, peer_id, folder_id, top_message_id, top_message_date, read_inbox_max_id, read_outbox_max_id, unread_count, unread_mentions_count, unread_reactions_count, ttl_period, theme_emoticon, has_scheduled, pinned, pinned_order, unread_mark, hidden_peer_settings_bar, peer_user_id, peer_access_hash, peer_phone, peer_first_name, peer_last_name, peer_username, peer_country_code, peer_verified, peer_support, peer_is_bot, peer_bot_info_version, peer_premium_until, peer_emoji_status_document_id, peer_emoji_status_until, peer_last_seen_at, peer_contact, peer_mutual, message_id, message_private_message_id, message_from_user_id, message_date, message_outgoing, message_body, message_entities_json, message_media_json, message_ttl_period, message_expires_at, message_edit_date, message_hide_edited, message_silent, message_noforwards, message_reply_to_msg_id, message_reply_to_peer_type, message_reply_to_peer_id, message_reply_to_top_id, message_reply_to_story_id, message_quote_text, message_quote_entities_json, message_quote_offset, message_fwd_from_peer_type, message_fwd_from_peer_id, message_fwd_from_name, message_fwd_date, message_fwd_saved_from_peer_type, message_fwd_saved_from_peer_id, message_fwd_saved_from_msg_id, message_saved_peer_type, message_saved_peer_id, message_media_unread, message_reaction_unread, message_via_bot_id, message_grouped_id, message_effect, message_reply_markup_json, message_rich_message_json, message_pinned
|
||||
FROM base
|
||||
WHERE (
|
||||
($17::int <= 0 AND $18::int <= 0)
|
||||
|
|
@ -1217,6 +1222,7 @@ SELECT
|
|||
message_ttl_period,
|
||||
message_expires_at,
|
||||
message_edit_date,
|
||||
message_hide_edited,
|
||||
message_silent,
|
||||
message_noforwards,
|
||||
message_reply_to_msg_id,
|
||||
|
|
@ -1324,6 +1330,7 @@ type ListDialogsByUserRow struct {
|
|||
MessageTtlPeriod int32
|
||||
MessageExpiresAt int32
|
||||
MessageEditDate int32
|
||||
MessageHideEdited bool
|
||||
MessageSilent bool
|
||||
MessageNoforwards bool
|
||||
MessageReplyToMsgID int32
|
||||
|
|
@ -1430,6 +1437,7 @@ func (q *Queries) ListDialogsByUser(ctx context.Context, arg ListDialogsByUserPa
|
|||
&i.MessageTtlPeriod,
|
||||
&i.MessageExpiresAt,
|
||||
&i.MessageEditDate,
|
||||
&i.MessageHideEdited,
|
||||
&i.MessageSilent,
|
||||
&i.MessageNoforwards,
|
||||
&i.MessageReplyToMsgID,
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ box AS (
|
|||
from_user_id,
|
||||
message_date,
|
||||
edit_date,
|
||||
hide_edited,
|
||||
outgoing,
|
||||
body,
|
||||
entities::text AS entities_json,
|
||||
|
|
@ -149,6 +150,7 @@ SELECT
|
|||
from_user_id,
|
||||
message_date,
|
||||
edit_date,
|
||||
hide_edited,
|
||||
outgoing,
|
||||
body,
|
||||
entities_json,
|
||||
|
|
@ -178,6 +180,7 @@ type CreateMessageRow struct {
|
|||
FromUserID int64
|
||||
MessageDate int32
|
||||
EditDate int32
|
||||
HideEdited bool
|
||||
Outgoing bool
|
||||
Body string
|
||||
EntitiesJson string
|
||||
|
|
@ -207,6 +210,7 @@ func (q *Queries) CreateMessage(ctx context.Context, arg CreateMessageParams) (C
|
|||
&i.FromUserID,
|
||||
&i.MessageDate,
|
||||
&i.EditDate,
|
||||
&i.HideEdited,
|
||||
&i.Outgoing,
|
||||
&i.Body,
|
||||
&i.EntitiesJson,
|
||||
|
|
@ -303,6 +307,7 @@ RETURNING
|
|||
ttl_period,
|
||||
expires_at,
|
||||
edit_date,
|
||||
hide_edited,
|
||||
outgoing,
|
||||
body,
|
||||
entities::text AS entities_json,
|
||||
|
|
@ -392,6 +397,7 @@ type CreateMessageBoxRow struct {
|
|||
TtlPeriod int32
|
||||
ExpiresAt int32
|
||||
EditDate int32
|
||||
HideEdited bool
|
||||
Outgoing bool
|
||||
Body string
|
||||
EntitiesJson string
|
||||
|
|
@ -482,6 +488,7 @@ func (q *Queries) CreateMessageBox(ctx context.Context, arg CreateMessageBoxPara
|
|||
&i.TtlPeriod,
|
||||
&i.ExpiresAt,
|
||||
&i.EditDate,
|
||||
&i.HideEdited,
|
||||
&i.Outgoing,
|
||||
&i.Body,
|
||||
&i.EntitiesJson,
|
||||
|
|
@ -1056,6 +1063,7 @@ SELECT
|
|||
ttl_period,
|
||||
expires_at,
|
||||
edit_date,
|
||||
hide_edited,
|
||||
outgoing,
|
||||
body,
|
||||
entities::text AS entities_json,
|
||||
|
|
@ -1110,6 +1118,7 @@ type GetMessageBoxByPrivateMessageRow struct {
|
|||
TtlPeriod int32
|
||||
ExpiresAt int32
|
||||
EditDate int32
|
||||
HideEdited bool
|
||||
Outgoing bool
|
||||
Body string
|
||||
EntitiesJson string
|
||||
|
|
@ -1158,6 +1167,7 @@ func (q *Queries) GetMessageBoxByPrivateMessage(ctx context.Context, arg GetMess
|
|||
&i.TtlPeriod,
|
||||
&i.ExpiresAt,
|
||||
&i.EditDate,
|
||||
&i.HideEdited,
|
||||
&i.Outgoing,
|
||||
&i.Body,
|
||||
&i.EntitiesJson,
|
||||
|
|
@ -1207,6 +1217,7 @@ SELECT
|
|||
ttl_period,
|
||||
expires_at,
|
||||
edit_date,
|
||||
hide_edited,
|
||||
outgoing,
|
||||
body,
|
||||
entities::text AS entities_json,
|
||||
|
|
@ -1268,6 +1279,7 @@ type GetMessageBoxForEditRow struct {
|
|||
TtlPeriod int32
|
||||
ExpiresAt int32
|
||||
EditDate int32
|
||||
HideEdited bool
|
||||
Outgoing bool
|
||||
Body string
|
||||
EntitiesJson string
|
||||
|
|
@ -1322,6 +1334,7 @@ func (q *Queries) GetMessageBoxForEdit(ctx context.Context, arg GetMessageBoxFor
|
|||
&i.TtlPeriod,
|
||||
&i.ExpiresAt,
|
||||
&i.EditDate,
|
||||
&i.HideEdited,
|
||||
&i.Outgoing,
|
||||
&i.Body,
|
||||
&i.EntitiesJson,
|
||||
|
|
@ -1460,6 +1473,7 @@ SELECT
|
|||
m.ttl_period,
|
||||
m.expires_at,
|
||||
m.edit_date,
|
||||
m.hide_edited,
|
||||
m.outgoing,
|
||||
m.body,
|
||||
m.entities::text AS entities_json,
|
||||
|
|
@ -1549,6 +1563,7 @@ type GetMessageBoxesByIDsRow struct {
|
|||
TtlPeriod int32
|
||||
ExpiresAt int32
|
||||
EditDate int32
|
||||
HideEdited bool
|
||||
Outgoing bool
|
||||
Body string
|
||||
EntitiesJson string
|
||||
|
|
@ -1634,6 +1649,7 @@ func (q *Queries) GetMessageBoxesByIDs(ctx context.Context, arg GetMessageBoxesB
|
|||
&i.TtlPeriod,
|
||||
&i.ExpiresAt,
|
||||
&i.EditDate,
|
||||
&i.HideEdited,
|
||||
&i.Outgoing,
|
||||
&i.Body,
|
||||
&i.EntitiesJson,
|
||||
|
|
@ -1727,6 +1743,7 @@ SELECT
|
|||
m.ttl_period,
|
||||
m.expires_at,
|
||||
m.edit_date,
|
||||
m.hide_edited,
|
||||
m.outgoing,
|
||||
m.body,
|
||||
m.entities::text AS entities_json,
|
||||
|
|
@ -1786,6 +1803,7 @@ type GetMessageBoxesForForwardRow struct {
|
|||
TtlPeriod int32
|
||||
ExpiresAt int32
|
||||
EditDate int32
|
||||
HideEdited bool
|
||||
Outgoing bool
|
||||
Body string
|
||||
EntitiesJson string
|
||||
|
|
@ -1844,6 +1862,7 @@ func (q *Queries) GetMessageBoxesForForward(ctx context.Context, arg GetMessageB
|
|||
&i.TtlPeriod,
|
||||
&i.ExpiresAt,
|
||||
&i.EditDate,
|
||||
&i.HideEdited,
|
||||
&i.Outgoing,
|
||||
&i.Body,
|
||||
&i.EntitiesJson,
|
||||
|
|
@ -2131,6 +2150,7 @@ SELECT
|
|||
m.ttl_period,
|
||||
m.expires_at,
|
||||
m.edit_date,
|
||||
m.hide_edited,
|
||||
m.outgoing,
|
||||
m.body,
|
||||
m.entities::text AS entities_json,
|
||||
|
|
@ -2263,6 +2283,7 @@ type ListMessagesBackwardRow struct {
|
|||
TtlPeriod int32
|
||||
ExpiresAt int32
|
||||
EditDate int32
|
||||
HideEdited bool
|
||||
Outgoing bool
|
||||
Body string
|
||||
EntitiesJson string
|
||||
|
|
@ -2368,6 +2389,7 @@ func (q *Queries) ListMessagesBackward(ctx context.Context, arg ListMessagesBack
|
|||
&i.TtlPeriod,
|
||||
&i.ExpiresAt,
|
||||
&i.EditDate,
|
||||
&i.HideEdited,
|
||||
&i.Outgoing,
|
||||
&i.Body,
|
||||
&i.EntitiesJson,
|
||||
|
|
@ -2466,6 +2488,7 @@ base AS NOT MATERIALIZED (
|
|||
m.ttl_period,
|
||||
m.expires_at,
|
||||
m.edit_date,
|
||||
m.hide_edited,
|
||||
m.outgoing,
|
||||
m.body,
|
||||
m.entities::text AS entities_json,
|
||||
|
|
@ -2567,7 +2590,7 @@ total AS (
|
|||
WHERE $16::boolean
|
||||
),
|
||||
backward AS (
|
||||
SELECT b.box_id, b.private_message_id, b.owner_user_id, b.peer_type, b.peer_id, b.from_user_id, b.message_date, b.ttl_period, b.expires_at, b.edit_date, b.outgoing, b.body, b.entities_json, b.silent, b.noforwards, b.reply_to_msg_id, b.reply_to_peer_type, b.reply_to_peer_id, b.reply_to_top_id, b.reply_to_story_id, b.quote_text, b.quote_entities_json, b.quote_offset, b.fwd_from_peer_type, b.fwd_from_peer_id, b.fwd_from_name, b.fwd_date, b.fwd_saved_from_peer_type, b.fwd_saved_from_peer_id, b.fwd_saved_from_msg_id, b.saved_peer_type, b.saved_peer_id, b.pts, b.media_json, b.media_unread, b.reaction_unread, b.pinned, b.via_bot_id, b.grouped_id, b.effect, b.reply_markup_json, b.rich_message_json, b.peer_user_id, b.peer_access_hash, b.peer_phone, b.peer_first_name, b.peer_last_name, b.peer_username, b.peer_country_code, b.peer_verified, b.peer_support, b.peer_is_bot, b.peer_bot_info_version, b.peer_premium_until, b.peer_emoji_status_document_id, b.peer_emoji_status_until, b.peer_last_seen_at, b.from_user_user_id, b.from_user_access_hash, b.from_user_phone, b.from_user_first_name, b.from_user_last_name, b.from_user_username, b.from_user_country_code, b.from_user_verified, b.from_user_support, b.from_user_is_bot, b.from_user_bot_info_version, b.from_user_premium_until, b.from_user_emoji_status_document_id, b.from_user_emoji_status_until, b.from_user_last_seen_at
|
||||
SELECT b.box_id, b.private_message_id, b.owner_user_id, b.peer_type, b.peer_id, b.from_user_id, b.message_date, b.ttl_period, b.expires_at, b.edit_date, b.hide_edited, b.outgoing, b.body, b.entities_json, b.silent, b.noforwards, b.reply_to_msg_id, b.reply_to_peer_type, b.reply_to_peer_id, b.reply_to_top_id, b.reply_to_story_id, b.quote_text, b.quote_entities_json, b.quote_offset, b.fwd_from_peer_type, b.fwd_from_peer_id, b.fwd_from_name, b.fwd_date, b.fwd_saved_from_peer_type, b.fwd_saved_from_peer_id, b.fwd_saved_from_msg_id, b.saved_peer_type, b.saved_peer_id, b.pts, b.media_json, b.media_unread, b.reaction_unread, b.pinned, b.via_bot_id, b.grouped_id, b.effect, b.reply_markup_json, b.rich_message_json, b.peer_user_id, b.peer_access_hash, b.peer_phone, b.peer_first_name, b.peer_last_name, b.peer_username, b.peer_country_code, b.peer_verified, b.peer_support, b.peer_is_bot, b.peer_bot_info_version, b.peer_premium_until, b.peer_emoji_status_document_id, b.peer_emoji_status_until, b.peer_last_seen_at, b.from_user_user_id, b.from_user_access_hash, b.from_user_phone, b.from_user_first_name, b.from_user_last_name, b.from_user_username, b.from_user_country_code, b.from_user_verified, b.from_user_support, b.from_user_is_bot, b.from_user_bot_info_version, b.from_user_premium_until, b.from_user_emoji_status_document_id, b.from_user_emoji_status_until, b.from_user_last_seen_at
|
||||
FROM base b
|
||||
CROSS JOIN load_params p
|
||||
WHERE p.load_type = 'backward'
|
||||
|
|
@ -2580,9 +2603,9 @@ backward AS (
|
|||
LIMIT (SELECT limit_count FROM load_params)
|
||||
),
|
||||
around_forward AS (
|
||||
SELECT f.box_id, f.private_message_id, f.owner_user_id, f.peer_type, f.peer_id, f.from_user_id, f.message_date, f.ttl_period, f.expires_at, f.edit_date, f.outgoing, f.body, f.entities_json, f.silent, f.noforwards, f.reply_to_msg_id, f.reply_to_peer_type, f.reply_to_peer_id, f.reply_to_top_id, f.reply_to_story_id, f.quote_text, f.quote_entities_json, f.quote_offset, f.fwd_from_peer_type, f.fwd_from_peer_id, f.fwd_from_name, f.fwd_date, f.fwd_saved_from_peer_type, f.fwd_saved_from_peer_id, f.fwd_saved_from_msg_id, f.saved_peer_type, f.saved_peer_id, f.pts, f.media_json, f.media_unread, f.reaction_unread, f.pinned, f.via_bot_id, f.grouped_id, f.effect, f.reply_markup_json, f.rich_message_json, f.peer_user_id, f.peer_access_hash, f.peer_phone, f.peer_first_name, f.peer_last_name, f.peer_username, f.peer_country_code, f.peer_verified, f.peer_support, f.peer_is_bot, f.peer_bot_info_version, f.peer_premium_until, f.peer_emoji_status_document_id, f.peer_emoji_status_until, f.peer_last_seen_at, f.from_user_user_id, f.from_user_access_hash, f.from_user_phone, f.from_user_first_name, f.from_user_last_name, f.from_user_username, f.from_user_country_code, f.from_user_verified, f.from_user_support, f.from_user_is_bot, f.from_user_bot_info_version, f.from_user_premium_until, f.from_user_emoji_status_document_id, f.from_user_emoji_status_until, f.from_user_last_seen_at
|
||||
SELECT f.box_id, f.private_message_id, f.owner_user_id, f.peer_type, f.peer_id, f.from_user_id, f.message_date, f.ttl_period, f.expires_at, f.edit_date, f.hide_edited, f.outgoing, f.body, f.entities_json, f.silent, f.noforwards, f.reply_to_msg_id, f.reply_to_peer_type, f.reply_to_peer_id, f.reply_to_top_id, f.reply_to_story_id, f.quote_text, f.quote_entities_json, f.quote_offset, f.fwd_from_peer_type, f.fwd_from_peer_id, f.fwd_from_name, f.fwd_date, f.fwd_saved_from_peer_type, f.fwd_saved_from_peer_id, f.fwd_saved_from_msg_id, f.saved_peer_type, f.saved_peer_id, f.pts, f.media_json, f.media_unread, f.reaction_unread, f.pinned, f.via_bot_id, f.grouped_id, f.effect, f.reply_markup_json, f.rich_message_json, f.peer_user_id, f.peer_access_hash, f.peer_phone, f.peer_first_name, f.peer_last_name, f.peer_username, f.peer_country_code, f.peer_verified, f.peer_support, f.peer_is_bot, f.peer_bot_info_version, f.peer_premium_until, f.peer_emoji_status_document_id, f.peer_emoji_status_until, f.peer_last_seen_at, f.from_user_user_id, f.from_user_access_hash, f.from_user_phone, f.from_user_first_name, f.from_user_last_name, f.from_user_username, f.from_user_country_code, f.from_user_verified, f.from_user_support, f.from_user_is_bot, f.from_user_bot_info_version, f.from_user_premium_until, f.from_user_emoji_status_document_id, f.from_user_emoji_status_until, f.from_user_last_seen_at
|
||||
FROM (
|
||||
SELECT b.box_id, b.private_message_id, b.owner_user_id, b.peer_type, b.peer_id, b.from_user_id, b.message_date, b.ttl_period, b.expires_at, b.edit_date, b.outgoing, b.body, b.entities_json, b.silent, b.noforwards, b.reply_to_msg_id, b.reply_to_peer_type, b.reply_to_peer_id, b.reply_to_top_id, b.reply_to_story_id, b.quote_text, b.quote_entities_json, b.quote_offset, b.fwd_from_peer_type, b.fwd_from_peer_id, b.fwd_from_name, b.fwd_date, b.fwd_saved_from_peer_type, b.fwd_saved_from_peer_id, b.fwd_saved_from_msg_id, b.saved_peer_type, b.saved_peer_id, b.pts, b.media_json, b.media_unread, b.reaction_unread, b.pinned, b.via_bot_id, b.grouped_id, b.effect, b.reply_markup_json, b.rich_message_json, b.peer_user_id, b.peer_access_hash, b.peer_phone, b.peer_first_name, b.peer_last_name, b.peer_username, b.peer_country_code, b.peer_verified, b.peer_support, b.peer_is_bot, b.peer_bot_info_version, b.peer_premium_until, b.peer_emoji_status_document_id, b.peer_emoji_status_until, b.peer_last_seen_at, b.from_user_user_id, b.from_user_access_hash, b.from_user_phone, b.from_user_first_name, b.from_user_last_name, b.from_user_username, b.from_user_country_code, b.from_user_verified, b.from_user_support, b.from_user_is_bot, b.from_user_bot_info_version, b.from_user_premium_until, b.from_user_emoji_status_document_id, b.from_user_emoji_status_until, b.from_user_last_seen_at
|
||||
SELECT b.box_id, b.private_message_id, b.owner_user_id, b.peer_type, b.peer_id, b.from_user_id, b.message_date, b.ttl_period, b.expires_at, b.edit_date, b.hide_edited, b.outgoing, b.body, b.entities_json, b.silent, b.noforwards, b.reply_to_msg_id, b.reply_to_peer_type, b.reply_to_peer_id, b.reply_to_top_id, b.reply_to_story_id, b.quote_text, b.quote_entities_json, b.quote_offset, b.fwd_from_peer_type, b.fwd_from_peer_id, b.fwd_from_name, b.fwd_date, b.fwd_saved_from_peer_type, b.fwd_saved_from_peer_id, b.fwd_saved_from_msg_id, b.saved_peer_type, b.saved_peer_id, b.pts, b.media_json, b.media_unread, b.reaction_unread, b.pinned, b.via_bot_id, b.grouped_id, b.effect, b.reply_markup_json, b.rich_message_json, b.peer_user_id, b.peer_access_hash, b.peer_phone, b.peer_first_name, b.peer_last_name, b.peer_username, b.peer_country_code, b.peer_verified, b.peer_support, b.peer_is_bot, b.peer_bot_info_version, b.peer_premium_until, b.peer_emoji_status_document_id, b.peer_emoji_status_until, b.peer_last_seen_at, b.from_user_user_id, b.from_user_access_hash, b.from_user_phone, b.from_user_first_name, b.from_user_last_name, b.from_user_username, b.from_user_country_code, b.from_user_verified, b.from_user_support, b.from_user_is_bot, b.from_user_bot_info_version, b.from_user_premium_until, b.from_user_emoji_status_document_id, b.from_user_emoji_status_until, b.from_user_last_seen_at
|
||||
FROM base b
|
||||
CROSS JOIN load_params p
|
||||
WHERE p.load_type = 'around'
|
||||
|
|
@ -2595,7 +2618,7 @@ around_forward AS (
|
|||
) f
|
||||
),
|
||||
around_backward AS (
|
||||
SELECT b.box_id, b.private_message_id, b.owner_user_id, b.peer_type, b.peer_id, b.from_user_id, b.message_date, b.ttl_period, b.expires_at, b.edit_date, b.outgoing, b.body, b.entities_json, b.silent, b.noforwards, b.reply_to_msg_id, b.reply_to_peer_type, b.reply_to_peer_id, b.reply_to_top_id, b.reply_to_story_id, b.quote_text, b.quote_entities_json, b.quote_offset, b.fwd_from_peer_type, b.fwd_from_peer_id, b.fwd_from_name, b.fwd_date, b.fwd_saved_from_peer_type, b.fwd_saved_from_peer_id, b.fwd_saved_from_msg_id, b.saved_peer_type, b.saved_peer_id, b.pts, b.media_json, b.media_unread, b.reaction_unread, b.pinned, b.via_bot_id, b.grouped_id, b.effect, b.reply_markup_json, b.rich_message_json, b.peer_user_id, b.peer_access_hash, b.peer_phone, b.peer_first_name, b.peer_last_name, b.peer_username, b.peer_country_code, b.peer_verified, b.peer_support, b.peer_is_bot, b.peer_bot_info_version, b.peer_premium_until, b.peer_emoji_status_document_id, b.peer_emoji_status_until, b.peer_last_seen_at, b.from_user_user_id, b.from_user_access_hash, b.from_user_phone, b.from_user_first_name, b.from_user_last_name, b.from_user_username, b.from_user_country_code, b.from_user_verified, b.from_user_support, b.from_user_is_bot, b.from_user_bot_info_version, b.from_user_premium_until, b.from_user_emoji_status_document_id, b.from_user_emoji_status_until, b.from_user_last_seen_at
|
||||
SELECT b.box_id, b.private_message_id, b.owner_user_id, b.peer_type, b.peer_id, b.from_user_id, b.message_date, b.ttl_period, b.expires_at, b.edit_date, b.hide_edited, b.outgoing, b.body, b.entities_json, b.silent, b.noforwards, b.reply_to_msg_id, b.reply_to_peer_type, b.reply_to_peer_id, b.reply_to_top_id, b.reply_to_story_id, b.quote_text, b.quote_entities_json, b.quote_offset, b.fwd_from_peer_type, b.fwd_from_peer_id, b.fwd_from_name, b.fwd_date, b.fwd_saved_from_peer_type, b.fwd_saved_from_peer_id, b.fwd_saved_from_msg_id, b.saved_peer_type, b.saved_peer_id, b.pts, b.media_json, b.media_unread, b.reaction_unread, b.pinned, b.via_bot_id, b.grouped_id, b.effect, b.reply_markup_json, b.rich_message_json, b.peer_user_id, b.peer_access_hash, b.peer_phone, b.peer_first_name, b.peer_last_name, b.peer_username, b.peer_country_code, b.peer_verified, b.peer_support, b.peer_is_bot, b.peer_bot_info_version, b.peer_premium_until, b.peer_emoji_status_document_id, b.peer_emoji_status_until, b.peer_last_seen_at, b.from_user_user_id, b.from_user_access_hash, b.from_user_phone, b.from_user_first_name, b.from_user_last_name, b.from_user_username, b.from_user_country_code, b.from_user_verified, b.from_user_support, b.from_user_is_bot, b.from_user_bot_info_version, b.from_user_premium_until, b.from_user_emoji_status_document_id, b.from_user_emoji_status_until, b.from_user_last_seen_at
|
||||
FROM base b
|
||||
CROSS JOIN load_params p
|
||||
WHERE p.load_type = 'around'
|
||||
|
|
@ -2607,9 +2630,9 @@ around_backward AS (
|
|||
LIMIT GREATEST((SELECT limit_count + add_offset FROM load_params), 0)
|
||||
),
|
||||
forward AS (
|
||||
SELECT f.box_id, f.private_message_id, f.owner_user_id, f.peer_type, f.peer_id, f.from_user_id, f.message_date, f.ttl_period, f.expires_at, f.edit_date, f.outgoing, f.body, f.entities_json, f.silent, f.noforwards, f.reply_to_msg_id, f.reply_to_peer_type, f.reply_to_peer_id, f.reply_to_top_id, f.reply_to_story_id, f.quote_text, f.quote_entities_json, f.quote_offset, f.fwd_from_peer_type, f.fwd_from_peer_id, f.fwd_from_name, f.fwd_date, f.fwd_saved_from_peer_type, f.fwd_saved_from_peer_id, f.fwd_saved_from_msg_id, f.saved_peer_type, f.saved_peer_id, f.pts, f.media_json, f.media_unread, f.reaction_unread, f.pinned, f.via_bot_id, f.grouped_id, f.effect, f.reply_markup_json, f.rich_message_json, f.peer_user_id, f.peer_access_hash, f.peer_phone, f.peer_first_name, f.peer_last_name, f.peer_username, f.peer_country_code, f.peer_verified, f.peer_support, f.peer_is_bot, f.peer_bot_info_version, f.peer_premium_until, f.peer_emoji_status_document_id, f.peer_emoji_status_until, f.peer_last_seen_at, f.from_user_user_id, f.from_user_access_hash, f.from_user_phone, f.from_user_first_name, f.from_user_last_name, f.from_user_username, f.from_user_country_code, f.from_user_verified, f.from_user_support, f.from_user_is_bot, f.from_user_bot_info_version, f.from_user_premium_until, f.from_user_emoji_status_document_id, f.from_user_emoji_status_until, f.from_user_last_seen_at
|
||||
SELECT f.box_id, f.private_message_id, f.owner_user_id, f.peer_type, f.peer_id, f.from_user_id, f.message_date, f.ttl_period, f.expires_at, f.edit_date, f.hide_edited, f.outgoing, f.body, f.entities_json, f.silent, f.noforwards, f.reply_to_msg_id, f.reply_to_peer_type, f.reply_to_peer_id, f.reply_to_top_id, f.reply_to_story_id, f.quote_text, f.quote_entities_json, f.quote_offset, f.fwd_from_peer_type, f.fwd_from_peer_id, f.fwd_from_name, f.fwd_date, f.fwd_saved_from_peer_type, f.fwd_saved_from_peer_id, f.fwd_saved_from_msg_id, f.saved_peer_type, f.saved_peer_id, f.pts, f.media_json, f.media_unread, f.reaction_unread, f.pinned, f.via_bot_id, f.grouped_id, f.effect, f.reply_markup_json, f.rich_message_json, f.peer_user_id, f.peer_access_hash, f.peer_phone, f.peer_first_name, f.peer_last_name, f.peer_username, f.peer_country_code, f.peer_verified, f.peer_support, f.peer_is_bot, f.peer_bot_info_version, f.peer_premium_until, f.peer_emoji_status_document_id, f.peer_emoji_status_until, f.peer_last_seen_at, f.from_user_user_id, f.from_user_access_hash, f.from_user_phone, f.from_user_first_name, f.from_user_last_name, f.from_user_username, f.from_user_country_code, f.from_user_verified, f.from_user_support, f.from_user_is_bot, f.from_user_bot_info_version, f.from_user_premium_until, f.from_user_emoji_status_document_id, f.from_user_emoji_status_until, f.from_user_last_seen_at
|
||||
FROM (
|
||||
SELECT b.box_id, b.private_message_id, b.owner_user_id, b.peer_type, b.peer_id, b.from_user_id, b.message_date, b.ttl_period, b.expires_at, b.edit_date, b.outgoing, b.body, b.entities_json, b.silent, b.noforwards, b.reply_to_msg_id, b.reply_to_peer_type, b.reply_to_peer_id, b.reply_to_top_id, b.reply_to_story_id, b.quote_text, b.quote_entities_json, b.quote_offset, b.fwd_from_peer_type, b.fwd_from_peer_id, b.fwd_from_name, b.fwd_date, b.fwd_saved_from_peer_type, b.fwd_saved_from_peer_id, b.fwd_saved_from_msg_id, b.saved_peer_type, b.saved_peer_id, b.pts, b.media_json, b.media_unread, b.reaction_unread, b.pinned, b.via_bot_id, b.grouped_id, b.effect, b.reply_markup_json, b.rich_message_json, b.peer_user_id, b.peer_access_hash, b.peer_phone, b.peer_first_name, b.peer_last_name, b.peer_username, b.peer_country_code, b.peer_verified, b.peer_support, b.peer_is_bot, b.peer_bot_info_version, b.peer_premium_until, b.peer_emoji_status_document_id, b.peer_emoji_status_until, b.peer_last_seen_at, b.from_user_user_id, b.from_user_access_hash, b.from_user_phone, b.from_user_first_name, b.from_user_last_name, b.from_user_username, b.from_user_country_code, b.from_user_verified, b.from_user_support, b.from_user_is_bot, b.from_user_bot_info_version, b.from_user_premium_until, b.from_user_emoji_status_document_id, b.from_user_emoji_status_until, b.from_user_last_seen_at
|
||||
SELECT b.box_id, b.private_message_id, b.owner_user_id, b.peer_type, b.peer_id, b.from_user_id, b.message_date, b.ttl_period, b.expires_at, b.edit_date, b.hide_edited, b.outgoing, b.body, b.entities_json, b.silent, b.noforwards, b.reply_to_msg_id, b.reply_to_peer_type, b.reply_to_peer_id, b.reply_to_top_id, b.reply_to_story_id, b.quote_text, b.quote_entities_json, b.quote_offset, b.fwd_from_peer_type, b.fwd_from_peer_id, b.fwd_from_name, b.fwd_date, b.fwd_saved_from_peer_type, b.fwd_saved_from_peer_id, b.fwd_saved_from_msg_id, b.saved_peer_type, b.saved_peer_id, b.pts, b.media_json, b.media_unread, b.reaction_unread, b.pinned, b.via_bot_id, b.grouped_id, b.effect, b.reply_markup_json, b.rich_message_json, b.peer_user_id, b.peer_access_hash, b.peer_phone, b.peer_first_name, b.peer_last_name, b.peer_username, b.peer_country_code, b.peer_verified, b.peer_support, b.peer_is_bot, b.peer_bot_info_version, b.peer_premium_until, b.peer_emoji_status_document_id, b.peer_emoji_status_until, b.peer_last_seen_at, b.from_user_user_id, b.from_user_access_hash, b.from_user_phone, b.from_user_first_name, b.from_user_last_name, b.from_user_username, b.from_user_country_code, b.from_user_verified, b.from_user_support, b.from_user_is_bot, b.from_user_bot_info_version, b.from_user_premium_until, b.from_user_emoji_status_document_id, b.from_user_emoji_status_until, b.from_user_last_seen_at
|
||||
FROM base b
|
||||
CROSS JOIN load_params p
|
||||
WHERE p.load_type = 'forward'
|
||||
|
|
@ -2622,13 +2645,13 @@ forward AS (
|
|||
) f
|
||||
),
|
||||
paged AS (
|
||||
SELECT box_id, private_message_id, owner_user_id, peer_type, peer_id, from_user_id, message_date, ttl_period, expires_at, edit_date, outgoing, body, entities_json, silent, noforwards, reply_to_msg_id, reply_to_peer_type, reply_to_peer_id, reply_to_top_id, reply_to_story_id, quote_text, quote_entities_json, quote_offset, fwd_from_peer_type, fwd_from_peer_id, fwd_from_name, fwd_date, fwd_saved_from_peer_type, fwd_saved_from_peer_id, fwd_saved_from_msg_id, saved_peer_type, saved_peer_id, pts, media_json, media_unread, reaction_unread, pinned, via_bot_id, grouped_id, effect, reply_markup_json, rich_message_json, peer_user_id, peer_access_hash, peer_phone, peer_first_name, peer_last_name, peer_username, peer_country_code, peer_verified, peer_support, peer_is_bot, peer_bot_info_version, peer_premium_until, peer_emoji_status_document_id, peer_emoji_status_until, peer_last_seen_at, from_user_user_id, from_user_access_hash, from_user_phone, from_user_first_name, from_user_last_name, from_user_username, from_user_country_code, from_user_verified, from_user_support, from_user_is_bot, from_user_bot_info_version, from_user_premium_until, from_user_emoji_status_document_id, from_user_emoji_status_until, from_user_last_seen_at FROM backward
|
||||
SELECT box_id, private_message_id, owner_user_id, peer_type, peer_id, from_user_id, message_date, ttl_period, expires_at, edit_date, hide_edited, outgoing, body, entities_json, silent, noforwards, reply_to_msg_id, reply_to_peer_type, reply_to_peer_id, reply_to_top_id, reply_to_story_id, quote_text, quote_entities_json, quote_offset, fwd_from_peer_type, fwd_from_peer_id, fwd_from_name, fwd_date, fwd_saved_from_peer_type, fwd_saved_from_peer_id, fwd_saved_from_msg_id, saved_peer_type, saved_peer_id, pts, media_json, media_unread, reaction_unread, pinned, via_bot_id, grouped_id, effect, reply_markup_json, rich_message_json, peer_user_id, peer_access_hash, peer_phone, peer_first_name, peer_last_name, peer_username, peer_country_code, peer_verified, peer_support, peer_is_bot, peer_bot_info_version, peer_premium_until, peer_emoji_status_document_id, peer_emoji_status_until, peer_last_seen_at, from_user_user_id, from_user_access_hash, from_user_phone, from_user_first_name, from_user_last_name, from_user_username, from_user_country_code, from_user_verified, from_user_support, from_user_is_bot, from_user_bot_info_version, from_user_premium_until, from_user_emoji_status_document_id, from_user_emoji_status_until, from_user_last_seen_at FROM backward
|
||||
UNION ALL
|
||||
SELECT box_id, private_message_id, owner_user_id, peer_type, peer_id, from_user_id, message_date, ttl_period, expires_at, edit_date, outgoing, body, entities_json, silent, noforwards, reply_to_msg_id, reply_to_peer_type, reply_to_peer_id, reply_to_top_id, reply_to_story_id, quote_text, quote_entities_json, quote_offset, fwd_from_peer_type, fwd_from_peer_id, fwd_from_name, fwd_date, fwd_saved_from_peer_type, fwd_saved_from_peer_id, fwd_saved_from_msg_id, saved_peer_type, saved_peer_id, pts, media_json, media_unread, reaction_unread, pinned, via_bot_id, grouped_id, effect, reply_markup_json, rich_message_json, peer_user_id, peer_access_hash, peer_phone, peer_first_name, peer_last_name, peer_username, peer_country_code, peer_verified, peer_support, peer_is_bot, peer_bot_info_version, peer_premium_until, peer_emoji_status_document_id, peer_emoji_status_until, peer_last_seen_at, from_user_user_id, from_user_access_hash, from_user_phone, from_user_first_name, from_user_last_name, from_user_username, from_user_country_code, from_user_verified, from_user_support, from_user_is_bot, from_user_bot_info_version, from_user_premium_until, from_user_emoji_status_document_id, from_user_emoji_status_until, from_user_last_seen_at FROM around_forward
|
||||
SELECT box_id, private_message_id, owner_user_id, peer_type, peer_id, from_user_id, message_date, ttl_period, expires_at, edit_date, hide_edited, outgoing, body, entities_json, silent, noforwards, reply_to_msg_id, reply_to_peer_type, reply_to_peer_id, reply_to_top_id, reply_to_story_id, quote_text, quote_entities_json, quote_offset, fwd_from_peer_type, fwd_from_peer_id, fwd_from_name, fwd_date, fwd_saved_from_peer_type, fwd_saved_from_peer_id, fwd_saved_from_msg_id, saved_peer_type, saved_peer_id, pts, media_json, media_unread, reaction_unread, pinned, via_bot_id, grouped_id, effect, reply_markup_json, rich_message_json, peer_user_id, peer_access_hash, peer_phone, peer_first_name, peer_last_name, peer_username, peer_country_code, peer_verified, peer_support, peer_is_bot, peer_bot_info_version, peer_premium_until, peer_emoji_status_document_id, peer_emoji_status_until, peer_last_seen_at, from_user_user_id, from_user_access_hash, from_user_phone, from_user_first_name, from_user_last_name, from_user_username, from_user_country_code, from_user_verified, from_user_support, from_user_is_bot, from_user_bot_info_version, from_user_premium_until, from_user_emoji_status_document_id, from_user_emoji_status_until, from_user_last_seen_at FROM around_forward
|
||||
UNION ALL
|
||||
SELECT box_id, private_message_id, owner_user_id, peer_type, peer_id, from_user_id, message_date, ttl_period, expires_at, edit_date, outgoing, body, entities_json, silent, noforwards, reply_to_msg_id, reply_to_peer_type, reply_to_peer_id, reply_to_top_id, reply_to_story_id, quote_text, quote_entities_json, quote_offset, fwd_from_peer_type, fwd_from_peer_id, fwd_from_name, fwd_date, fwd_saved_from_peer_type, fwd_saved_from_peer_id, fwd_saved_from_msg_id, saved_peer_type, saved_peer_id, pts, media_json, media_unread, reaction_unread, pinned, via_bot_id, grouped_id, effect, reply_markup_json, rich_message_json, peer_user_id, peer_access_hash, peer_phone, peer_first_name, peer_last_name, peer_username, peer_country_code, peer_verified, peer_support, peer_is_bot, peer_bot_info_version, peer_premium_until, peer_emoji_status_document_id, peer_emoji_status_until, peer_last_seen_at, from_user_user_id, from_user_access_hash, from_user_phone, from_user_first_name, from_user_last_name, from_user_username, from_user_country_code, from_user_verified, from_user_support, from_user_is_bot, from_user_bot_info_version, from_user_premium_until, from_user_emoji_status_document_id, from_user_emoji_status_until, from_user_last_seen_at FROM around_backward
|
||||
SELECT box_id, private_message_id, owner_user_id, peer_type, peer_id, from_user_id, message_date, ttl_period, expires_at, edit_date, hide_edited, outgoing, body, entities_json, silent, noforwards, reply_to_msg_id, reply_to_peer_type, reply_to_peer_id, reply_to_top_id, reply_to_story_id, quote_text, quote_entities_json, quote_offset, fwd_from_peer_type, fwd_from_peer_id, fwd_from_name, fwd_date, fwd_saved_from_peer_type, fwd_saved_from_peer_id, fwd_saved_from_msg_id, saved_peer_type, saved_peer_id, pts, media_json, media_unread, reaction_unread, pinned, via_bot_id, grouped_id, effect, reply_markup_json, rich_message_json, peer_user_id, peer_access_hash, peer_phone, peer_first_name, peer_last_name, peer_username, peer_country_code, peer_verified, peer_support, peer_is_bot, peer_bot_info_version, peer_premium_until, peer_emoji_status_document_id, peer_emoji_status_until, peer_last_seen_at, from_user_user_id, from_user_access_hash, from_user_phone, from_user_first_name, from_user_last_name, from_user_username, from_user_country_code, from_user_verified, from_user_support, from_user_is_bot, from_user_bot_info_version, from_user_premium_until, from_user_emoji_status_document_id, from_user_emoji_status_until, from_user_last_seen_at FROM around_backward
|
||||
UNION ALL
|
||||
SELECT box_id, private_message_id, owner_user_id, peer_type, peer_id, from_user_id, message_date, ttl_period, expires_at, edit_date, outgoing, body, entities_json, silent, noforwards, reply_to_msg_id, reply_to_peer_type, reply_to_peer_id, reply_to_top_id, reply_to_story_id, quote_text, quote_entities_json, quote_offset, fwd_from_peer_type, fwd_from_peer_id, fwd_from_name, fwd_date, fwd_saved_from_peer_type, fwd_saved_from_peer_id, fwd_saved_from_msg_id, saved_peer_type, saved_peer_id, pts, media_json, media_unread, reaction_unread, pinned, via_bot_id, grouped_id, effect, reply_markup_json, rich_message_json, peer_user_id, peer_access_hash, peer_phone, peer_first_name, peer_last_name, peer_username, peer_country_code, peer_verified, peer_support, peer_is_bot, peer_bot_info_version, peer_premium_until, peer_emoji_status_document_id, peer_emoji_status_until, peer_last_seen_at, from_user_user_id, from_user_access_hash, from_user_phone, from_user_first_name, from_user_last_name, from_user_username, from_user_country_code, from_user_verified, from_user_support, from_user_is_bot, from_user_bot_info_version, from_user_premium_until, from_user_emoji_status_document_id, from_user_emoji_status_until, from_user_last_seen_at FROM forward
|
||||
SELECT box_id, private_message_id, owner_user_id, peer_type, peer_id, from_user_id, message_date, ttl_period, expires_at, edit_date, hide_edited, outgoing, body, entities_json, silent, noforwards, reply_to_msg_id, reply_to_peer_type, reply_to_peer_id, reply_to_top_id, reply_to_story_id, quote_text, quote_entities_json, quote_offset, fwd_from_peer_type, fwd_from_peer_id, fwd_from_name, fwd_date, fwd_saved_from_peer_type, fwd_saved_from_peer_id, fwd_saved_from_msg_id, saved_peer_type, saved_peer_id, pts, media_json, media_unread, reaction_unread, pinned, via_bot_id, grouped_id, effect, reply_markup_json, rich_message_json, peer_user_id, peer_access_hash, peer_phone, peer_first_name, peer_last_name, peer_username, peer_country_code, peer_verified, peer_support, peer_is_bot, peer_bot_info_version, peer_premium_until, peer_emoji_status_document_id, peer_emoji_status_until, peer_last_seen_at, from_user_user_id, from_user_access_hash, from_user_phone, from_user_first_name, from_user_last_name, from_user_username, from_user_country_code, from_user_verified, from_user_support, from_user_is_bot, from_user_bot_info_version, from_user_premium_until, from_user_emoji_status_document_id, from_user_emoji_status_until, from_user_last_seen_at FROM forward
|
||||
)
|
||||
SELECT
|
||||
box_id,
|
||||
|
|
@ -2641,6 +2664,7 @@ SELECT
|
|||
ttl_period,
|
||||
expires_at,
|
||||
edit_date,
|
||||
hide_edited,
|
||||
outgoing,
|
||||
body,
|
||||
entities_json,
|
||||
|
|
@ -2739,6 +2763,7 @@ type ListMessagesByUserRow struct {
|
|||
TtlPeriod int32
|
||||
ExpiresAt int32
|
||||
EditDate int32
|
||||
HideEdited bool
|
||||
Outgoing bool
|
||||
Body string
|
||||
EntitiesJson string
|
||||
|
|
@ -2841,6 +2866,7 @@ func (q *Queries) ListMessagesByUser(ctx context.Context, arg ListMessagesByUser
|
|||
&i.TtlPeriod,
|
||||
&i.ExpiresAt,
|
||||
&i.EditDate,
|
||||
&i.HideEdited,
|
||||
&i.Outgoing,
|
||||
&i.Body,
|
||||
&i.EntitiesJson,
|
||||
|
|
@ -2927,6 +2953,7 @@ SELECT
|
|||
ttl_period,
|
||||
expires_at,
|
||||
edit_date,
|
||||
hide_edited,
|
||||
outgoing,
|
||||
body,
|
||||
entities::text AS entities_json,
|
||||
|
|
@ -2987,6 +3014,7 @@ type ListUnreadReactionMessageBoxesRow struct {
|
|||
TtlPeriod int32
|
||||
ExpiresAt int32
|
||||
EditDate int32
|
||||
HideEdited bool
|
||||
Outgoing bool
|
||||
Body string
|
||||
EntitiesJson string
|
||||
|
|
@ -3046,6 +3074,7 @@ func (q *Queries) ListUnreadReactionMessageBoxes(ctx context.Context, arg ListUn
|
|||
&i.TtlPeriod,
|
||||
&i.ExpiresAt,
|
||||
&i.EditDate,
|
||||
&i.HideEdited,
|
||||
&i.Outgoing,
|
||||
&i.Body,
|
||||
&i.EntitiesJson,
|
||||
|
|
@ -3102,6 +3131,7 @@ SELECT
|
|||
ttl_period,
|
||||
expires_at,
|
||||
edit_date,
|
||||
hide_edited,
|
||||
outgoing,
|
||||
body,
|
||||
entities::text AS entities_json,
|
||||
|
|
@ -3161,6 +3191,7 @@ type ListVisibleMessageBoxesByPrivateMessageRow struct {
|
|||
TtlPeriod int32
|
||||
ExpiresAt int32
|
||||
EditDate int32
|
||||
HideEdited bool
|
||||
Outgoing bool
|
||||
Body string
|
||||
EntitiesJson string
|
||||
|
|
@ -3216,6 +3247,7 @@ func (q *Queries) ListVisibleMessageBoxesByPrivateMessage(ctx context.Context, a
|
|||
&i.TtlPeriod,
|
||||
&i.ExpiresAt,
|
||||
&i.EditDate,
|
||||
&i.HideEdited,
|
||||
&i.Outgoing,
|
||||
&i.Body,
|
||||
&i.EntitiesJson,
|
||||
|
|
@ -3517,13 +3549,14 @@ UPDATE message_boxes
|
|||
SET body = $1::text,
|
||||
entities = $2::jsonb,
|
||||
edit_date = $3::int,
|
||||
pts = $4::int,
|
||||
hide_edited = $4::boolean,
|
||||
pts = $5::int,
|
||||
reply_markup = CASE
|
||||
WHEN $5::boolean THEN $6::jsonb
|
||||
WHEN $6::boolean THEN $7::jsonb
|
||||
ELSE reply_markup
|
||||
END
|
||||
WHERE owner_user_id = $7::bigint
|
||||
AND box_id = $8::int
|
||||
WHERE owner_user_id = $8::bigint
|
||||
AND box_id = $9::int
|
||||
AND NOT deleted
|
||||
RETURNING
|
||||
box_id,
|
||||
|
|
@ -3537,6 +3570,7 @@ RETURNING
|
|||
ttl_period,
|
||||
expires_at,
|
||||
edit_date,
|
||||
hide_edited,
|
||||
outgoing,
|
||||
body,
|
||||
entities::text AS entities_json,
|
||||
|
|
@ -3575,6 +3609,7 @@ type UpdateMessageBoxEditParams struct {
|
|||
Body string
|
||||
EntitiesJson []byte
|
||||
EditDate int32
|
||||
HideEdited bool
|
||||
Pts int32
|
||||
SetReplyMarkup bool
|
||||
ReplyMarkupJson []byte
|
||||
|
|
@ -3594,6 +3629,7 @@ type UpdateMessageBoxEditRow struct {
|
|||
TtlPeriod int32
|
||||
ExpiresAt int32
|
||||
EditDate int32
|
||||
HideEdited bool
|
||||
Outgoing bool
|
||||
Body string
|
||||
EntitiesJson string
|
||||
|
|
@ -3633,6 +3669,7 @@ func (q *Queries) UpdateMessageBoxEdit(ctx context.Context, arg UpdateMessageBox
|
|||
arg.Body,
|
||||
arg.EntitiesJson,
|
||||
arg.EditDate,
|
||||
arg.HideEdited,
|
||||
arg.Pts,
|
||||
arg.SetReplyMarkup,
|
||||
arg.ReplyMarkupJson,
|
||||
|
|
@ -3652,6 +3689,7 @@ func (q *Queries) UpdateMessageBoxEdit(ctx context.Context, arg UpdateMessageBox
|
|||
&i.TtlPeriod,
|
||||
&i.ExpiresAt,
|
||||
&i.EditDate,
|
||||
&i.HideEdited,
|
||||
&i.Outgoing,
|
||||
&i.Body,
|
||||
&i.EntitiesJson,
|
||||
|
|
@ -3693,18 +3731,20 @@ UPDATE private_messages
|
|||
SET body = $1::text,
|
||||
entities = $2::jsonb,
|
||||
edit_date = $3::int,
|
||||
hide_edited = $4::boolean,
|
||||
reply_markup = CASE
|
||||
WHEN $4::boolean THEN $5::jsonb
|
||||
WHEN $5::boolean THEN $6::jsonb
|
||||
ELSE reply_markup
|
||||
END
|
||||
WHERE sender_user_id = $6::bigint
|
||||
AND id = $7::bigint
|
||||
WHERE sender_user_id = $7::bigint
|
||||
AND id = $8::bigint
|
||||
`
|
||||
|
||||
type UpdatePrivateMessageEditParams struct {
|
||||
Body string
|
||||
EntitiesJson []byte
|
||||
EditDate int32
|
||||
HideEdited bool
|
||||
SetReplyMarkup bool
|
||||
ReplyMarkupJson []byte
|
||||
SenderUserID int64
|
||||
|
|
@ -3716,6 +3756,7 @@ func (q *Queries) UpdatePrivateMessageEdit(ctx context.Context, arg UpdatePrivat
|
|||
arg.Body,
|
||||
arg.EntitiesJson,
|
||||
arg.EditDate,
|
||||
arg.HideEdited,
|
||||
arg.SetReplyMarkup,
|
||||
arg.ReplyMarkupJson,
|
||||
arg.SenderUserID,
|
||||
|
|
|
|||
|
|
@ -53,6 +53,15 @@ type AccountReactionSetting struct {
|
|||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type AccountSendRestriction struct {
|
||||
UserID int64
|
||||
Frozen bool
|
||||
Reason string
|
||||
Actor string
|
||||
CommandID string
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type AccountSetting struct {
|
||||
UserID int64
|
||||
ArchiveAndMuteNewNoncontactPeers bool
|
||||
|
|
@ -68,6 +77,60 @@ type AccountSetting struct {
|
|||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type AdminAuditLog struct {
|
||||
ID int64
|
||||
CommandID string
|
||||
Actor string
|
||||
Action string
|
||||
TargetUserID int64
|
||||
TargetPeerType string
|
||||
TargetPeerID int64
|
||||
DryRun bool
|
||||
Reason string
|
||||
Request []byte
|
||||
Result []byte
|
||||
Status string
|
||||
Error string
|
||||
CreatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type AdminCommand struct {
|
||||
CommandID string
|
||||
Actor string
|
||||
Action string
|
||||
TargetUserID int64
|
||||
TargetPeerType string
|
||||
TargetPeerID int64
|
||||
DryRun bool
|
||||
Reason string
|
||||
Request []byte
|
||||
Result []byte
|
||||
Status string
|
||||
Error string
|
||||
CreatedAt pgtype.Timestamptz
|
||||
CompletedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type AiComposeTone struct {
|
||||
ID int64
|
||||
AccessHash int64
|
||||
OwnerUserID int64
|
||||
Slug string
|
||||
Title string
|
||||
EmojiID int64
|
||||
Prompt string
|
||||
DisplayAuthor bool
|
||||
InstallsCount int32
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type AiComposeToneSafe struct {
|
||||
UserID int64
|
||||
ToneID int64
|
||||
SavedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type AppConfig struct {
|
||||
Client string
|
||||
Hash int32
|
||||
|
|
@ -75,6 +138,31 @@ type AppConfig struct {
|
|||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type AttachMenuBot struct {
|
||||
BotUserID int64
|
||||
AppID *int64
|
||||
ShortName string
|
||||
Inactive bool
|
||||
HasSettings bool
|
||||
RequestWriteAccess bool
|
||||
ShowInAttachMenu bool
|
||||
ShowInSideMenu bool
|
||||
SideMenuDisclaimerNeeded bool
|
||||
PeerTypes []string
|
||||
Icons []byte
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type AttachMenuUserState struct {
|
||||
UserID int64
|
||||
BotUserID int64
|
||||
Enabled bool
|
||||
WriteAllowed bool
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type AuthKey struct {
|
||||
AuthKeyID int64
|
||||
Body []byte
|
||||
|
|
@ -130,6 +218,46 @@ type Bot struct {
|
|||
BotInlineGeo bool
|
||||
}
|
||||
|
||||
type BotApp struct {
|
||||
ID int64
|
||||
BotUserID int64
|
||||
ShortName string
|
||||
Title string
|
||||
Description string
|
||||
Url string
|
||||
PhotoID int64
|
||||
DocumentID int64
|
||||
AccessHash int64
|
||||
Hash int64
|
||||
Inactive bool
|
||||
RequestWriteAccess bool
|
||||
HasSettings bool
|
||||
IsMain bool
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type BotAppPreviewMedium struct {
|
||||
ID int64
|
||||
BotUserID int64
|
||||
AppID int64
|
||||
Position int32
|
||||
PhotoID int64
|
||||
DocumentID int64
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type BotAppSetting struct {
|
||||
BotUserID int64
|
||||
PlaceholderPath []byte
|
||||
BackgroundColor *int32
|
||||
BackgroundDarkColor *int32
|
||||
HeaderColor *int32
|
||||
HeaderDarkColor *int32
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type BotChatState struct {
|
||||
BotUserID int64
|
||||
UserID int64
|
||||
|
|
@ -137,6 +265,14 @@ type BotChatState struct {
|
|||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type BotEmojiStatusPermission struct {
|
||||
BotUserID int64
|
||||
UserID int64
|
||||
Allowed bool
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type BotUserPermission struct {
|
||||
BotUserID int64
|
||||
UserID int64
|
||||
|
|
@ -244,6 +380,8 @@ type Channel struct {
|
|||
BoostsUnrestrict int32
|
||||
Monoforum bool
|
||||
LinkedMonoforumID int64
|
||||
Wallpaper []byte
|
||||
Verified bool
|
||||
}
|
||||
|
||||
type ChannelAdminLogEvent struct {
|
||||
|
|
@ -525,12 +663,6 @@ type ChannelUpdateEvent struct {
|
|||
CreatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type ChannelUsername struct {
|
||||
UsernameLower string
|
||||
ChannelID int64
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type Contact struct {
|
||||
UserID int64
|
||||
ContactUserID int64
|
||||
|
|
@ -707,19 +839,44 @@ type FileBlob struct {
|
|||
}
|
||||
|
||||
type GroupCall struct {
|
||||
CallID int64
|
||||
AccessHash int64
|
||||
ChannelID int64
|
||||
CreatorUserID int64
|
||||
State string
|
||||
Title string
|
||||
JoinMuted bool
|
||||
Version int32
|
||||
ParticipantsCount int32
|
||||
CreatedAt int32
|
||||
DiscardedAt int32
|
||||
Duration int32
|
||||
StartedMsgID int32
|
||||
CallID int64
|
||||
AccessHash int64
|
||||
ChannelID int64
|
||||
CreatorUserID int64
|
||||
State string
|
||||
Title string
|
||||
JoinMuted bool
|
||||
Version int32
|
||||
ParticipantsCount int32
|
||||
CreatedAt int32
|
||||
DiscardedAt int32
|
||||
Duration int32
|
||||
StartedMsgID int32
|
||||
Kind string
|
||||
InviteSlug string
|
||||
InviteLink string
|
||||
RandomID int64
|
||||
MigratedFromPhoneCallID int64
|
||||
}
|
||||
|
||||
type GroupCallChainBlock struct {
|
||||
CallID int64
|
||||
SubChainID int32
|
||||
BlockOffset int32
|
||||
Block []byte
|
||||
CreatedAt int32
|
||||
AuthorUserID int64
|
||||
}
|
||||
|
||||
type GroupCallInvite struct {
|
||||
CallID int64
|
||||
InviterUserID int64
|
||||
InviteeUserID int64
|
||||
MessageID int32
|
||||
Status string
|
||||
Video bool
|
||||
CreatedAt int32
|
||||
UpdatedAt int32
|
||||
}
|
||||
|
||||
type GroupCallParticipant struct {
|
||||
|
|
@ -736,6 +893,8 @@ type GroupCallParticipant struct {
|
|||
PresentationJson []byte
|
||||
LeftCall bool
|
||||
LastCheckDate int32
|
||||
PublicKey []byte
|
||||
JoinBlock []byte
|
||||
}
|
||||
|
||||
type GroupCallParticipantOverride struct {
|
||||
|
|
@ -817,6 +976,7 @@ type MessageBox struct {
|
|||
GroupedID int64
|
||||
ReplyToStoryID int32
|
||||
Effect int64
|
||||
HideEdited bool
|
||||
}
|
||||
|
||||
type MessageBoxMedium struct {
|
||||
|
|
@ -853,6 +1013,29 @@ type PasskeyCredential struct {
|
|||
LastUsedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type PeerStarGift struct {
|
||||
ID int64
|
||||
OwnerPeerID int64
|
||||
FromUserID int64
|
||||
GiftID int64
|
||||
MsgID int32
|
||||
GiftDate int32
|
||||
NameHidden bool
|
||||
Unsaved bool
|
||||
Converted bool
|
||||
ConvertStars int64
|
||||
Message string
|
||||
OwnerPeerType string
|
||||
SavedID int64
|
||||
}
|
||||
|
||||
type PeerUsername struct {
|
||||
UsernameLower string
|
||||
PeerType string
|
||||
PeerID int64
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type Photo struct {
|
||||
ID int64
|
||||
AccessHash int64
|
||||
|
|
@ -930,6 +1113,7 @@ type PrivateMessage struct {
|
|||
GroupedID int64
|
||||
ReplyToStoryID int32
|
||||
Effect int64
|
||||
HideEdited bool
|
||||
}
|
||||
|
||||
type PrivateMessageReaction struct {
|
||||
|
|
@ -1065,6 +1249,12 @@ type SecretQtsWatermark struct {
|
|||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type SeedState struct {
|
||||
Key string
|
||||
ContentHash string
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type StarsBalance struct {
|
||||
UserID int64
|
||||
Balance int64
|
||||
|
|
@ -1109,6 +1299,12 @@ type StickerSet struct {
|
|||
SortOrder int32
|
||||
SystemKey string
|
||||
CreatedAt pgtype.Timestamptz
|
||||
CreatorUserID int64
|
||||
TextColor bool
|
||||
Deleted bool
|
||||
Software string
|
||||
Keywords []byte
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type Story struct {
|
||||
|
|
@ -1139,6 +1335,16 @@ type Story struct {
|
|||
FwdFrom []byte
|
||||
}
|
||||
|
||||
type StoryExposure struct {
|
||||
OwnerPeerType string
|
||||
OwnerPeerID int64
|
||||
StoryID int32
|
||||
ViewerUserID int64
|
||||
Date int32
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type StoryHiddenPeer struct {
|
||||
ViewerUserID int64
|
||||
OwnerPeerType string
|
||||
|
|
@ -1295,20 +1501,6 @@ type UserSavedReactionTag struct {
|
|||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type UserStarGift struct {
|
||||
ID int64
|
||||
OwnerUserID int64
|
||||
FromUserID int64
|
||||
GiftID int64
|
||||
MsgID int32
|
||||
GiftDate int32
|
||||
NameHidden bool
|
||||
Unsaved bool
|
||||
Converted bool
|
||||
ConvertStars int64
|
||||
Message string
|
||||
}
|
||||
|
||||
type UserStickerCollection struct {
|
||||
OwnerUserID int64
|
||||
Kind string
|
||||
|
|
@ -1316,6 +1508,16 @@ type UserStickerCollection struct {
|
|||
UsedAt int32
|
||||
}
|
||||
|
||||
type UserStickerSet struct {
|
||||
OwnerUserID int64
|
||||
StickerSetID int64
|
||||
SetKind string
|
||||
Archived bool
|
||||
InstalledDate int32
|
||||
OrderValue int64
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type UserTopReaction struct {
|
||||
UserID int64
|
||||
ReactionType string
|
||||
|
|
@ -1369,3 +1571,25 @@ type WebPage struct {
|
|||
CreatedAt int64
|
||||
RefreshedAt int64
|
||||
}
|
||||
|
||||
type WebviewCustomMethodQuery struct {
|
||||
ID string
|
||||
BotUserID int64
|
||||
UserID int64
|
||||
CustomMethod string
|
||||
Params []byte
|
||||
CreatedAt pgtype.Timestamptz
|
||||
ExpiresAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type WebviewRequestedButton struct {
|
||||
WebappReqID string
|
||||
BotUserID int64
|
||||
UserID int64
|
||||
ButtonID int32
|
||||
Text string
|
||||
PeerType string
|
||||
MaxQuantity int32
|
||||
CreatedAt pgtype.Timestamptz
|
||||
ExpiresAt pgtype.Timestamptz
|
||||
}
|
||||
|
|
|
|||
|
|
@ -260,6 +260,7 @@ SELECT
|
|||
m.ttl_period,
|
||||
m.expires_at,
|
||||
m.edit_date,
|
||||
m.hide_edited,
|
||||
m.outgoing,
|
||||
m.body,
|
||||
m.entities::text AS entities_json,
|
||||
|
|
@ -317,6 +318,7 @@ type ListPinnedSavedDialogTopsRow struct {
|
|||
TtlPeriod int32
|
||||
ExpiresAt int32
|
||||
EditDate int32
|
||||
HideEdited bool
|
||||
Outgoing bool
|
||||
Body string
|
||||
EntitiesJson string
|
||||
|
|
@ -374,6 +376,7 @@ func (q *Queries) ListPinnedSavedDialogTops(ctx context.Context, ownerUserID int
|
|||
&i.TtlPeriod,
|
||||
&i.ExpiresAt,
|
||||
&i.EditDate,
|
||||
&i.HideEdited,
|
||||
&i.Outgoing,
|
||||
&i.Body,
|
||||
&i.EntitiesJson,
|
||||
|
|
@ -443,6 +446,7 @@ SELECT
|
|||
m.ttl_period,
|
||||
m.expires_at,
|
||||
m.edit_date,
|
||||
m.hide_edited,
|
||||
m.outgoing,
|
||||
m.body,
|
||||
m.entities::text AS entities_json,
|
||||
|
|
@ -510,6 +514,7 @@ type ListSavedDialogTopsRow struct {
|
|||
TtlPeriod int32
|
||||
ExpiresAt int32
|
||||
EditDate int32
|
||||
HideEdited bool
|
||||
Outgoing bool
|
||||
Body string
|
||||
EntitiesJson string
|
||||
|
|
@ -576,6 +581,7 @@ func (q *Queries) ListSavedDialogTops(ctx context.Context, arg ListSavedDialogTo
|
|||
&i.TtlPeriod,
|
||||
&i.ExpiresAt,
|
||||
&i.EditDate,
|
||||
&i.HideEdited,
|
||||
&i.Outgoing,
|
||||
&i.Body,
|
||||
&i.EntitiesJson,
|
||||
|
|
@ -653,6 +659,7 @@ SELECT
|
|||
m.ttl_period,
|
||||
m.expires_at,
|
||||
m.edit_date,
|
||||
m.hide_edited,
|
||||
m.outgoing,
|
||||
m.body,
|
||||
m.entities::text AS entities_json,
|
||||
|
|
@ -716,6 +723,7 @@ type ListSavedDialogTopsByPeersRow struct {
|
|||
TtlPeriod int32
|
||||
ExpiresAt int32
|
||||
EditDate int32
|
||||
HideEdited bool
|
||||
Outgoing bool
|
||||
Body string
|
||||
EntitiesJson string
|
||||
|
|
@ -773,6 +781,7 @@ func (q *Queries) ListSavedDialogTopsByPeers(ctx context.Context, arg ListSavedD
|
|||
&i.TtlPeriod,
|
||||
&i.ExpiresAt,
|
||||
&i.EditDate,
|
||||
&i.HideEdited,
|
||||
&i.Outgoing,
|
||||
&i.Body,
|
||||
&i.EntitiesJson,
|
||||
|
|
|
|||
|
|
@ -150,6 +150,7 @@ SELECT
|
|||
COALESCE(m.ttl_period, 0)::int AS ttl_period,
|
||||
COALESCE(m.expires_at, 0)::int AS expires_at,
|
||||
COALESCE(m.edit_date, 0)::int AS edit_date,
|
||||
COALESCE(m.hide_edited, false)::boolean AS hide_edited,
|
||||
COALESCE(m.outgoing, false)::boolean AS outgoing,
|
||||
COALESCE(m.body, '')::text AS body,
|
||||
COALESCE(m.entities::text, '[]')::text AS message_entities_json,
|
||||
|
|
@ -285,6 +286,7 @@ type BatchListDispatchEventsRow struct {
|
|||
TtlPeriod int32
|
||||
ExpiresAt int32
|
||||
EditDate int32
|
||||
HideEdited bool
|
||||
Outgoing bool
|
||||
Body string
|
||||
MessageEntitiesJson string
|
||||
|
|
@ -418,6 +420,7 @@ func (q *Queries) BatchListDispatchEvents(ctx context.Context, arg BatchListDisp
|
|||
&i.TtlPeriod,
|
||||
&i.ExpiresAt,
|
||||
&i.EditDate,
|
||||
&i.HideEdited,
|
||||
&i.Outgoing,
|
||||
&i.Body,
|
||||
&i.MessageEntitiesJson,
|
||||
|
|
@ -704,6 +707,7 @@ SELECT
|
|||
COALESCE(m.ttl_period, 0)::int AS ttl_period,
|
||||
COALESCE(m.expires_at, 0)::int AS expires_at,
|
||||
COALESCE(m.edit_date, 0)::int AS edit_date,
|
||||
COALESCE(m.hide_edited, false)::boolean AS hide_edited,
|
||||
COALESCE(m.outgoing, false)::boolean AS outgoing,
|
||||
COALESCE(m.body, '')::text AS body,
|
||||
COALESCE(m.entities::text, '[]')::text AS message_entities_json,
|
||||
|
|
@ -842,6 +846,7 @@ type ListUserUpdateEventsAfterRow struct {
|
|||
TtlPeriod int32
|
||||
ExpiresAt int32
|
||||
EditDate int32
|
||||
HideEdited bool
|
||||
Outgoing bool
|
||||
Body string
|
||||
MessageEntitiesJson string
|
||||
|
|
@ -973,6 +978,7 @@ func (q *Queries) ListUserUpdateEventsAfter(ctx context.Context, arg ListUserUpd
|
|||
&i.TtlPeriod,
|
||||
&i.ExpiresAt,
|
||||
&i.EditDate,
|
||||
&i.HideEdited,
|
||||
&i.Outgoing,
|
||||
&i.Body,
|
||||
&i.MessageEntitiesJson,
|
||||
|
|
|
|||
|
|
@ -426,6 +426,7 @@ func (s *UpdateEventStore) ListAfter(ctx context.Context, userID int64, pts, lim
|
|||
From: domain.Peer{Type: domain.PeerTypeUser, ID: row.FromUserID},
|
||||
Date: int(row.MessageDate),
|
||||
EditDate: int(row.EditDate),
|
||||
HideEdited: row.HideEdited,
|
||||
Out: row.Outgoing,
|
||||
Silent: silent,
|
||||
NoForwards: noforwards,
|
||||
|
|
@ -590,6 +591,7 @@ func (s *UpdateEventStore) BatchByCursor(ctx context.Context, cursors []store.Ev
|
|||
From: domain.Peer{Type: domain.PeerTypeUser, ID: row.FromUserID},
|
||||
Date: int(row.MessageDate),
|
||||
EditDate: int(row.EditDate),
|
||||
HideEdited: row.HideEdited,
|
||||
Out: row.Outgoing,
|
||||
Silent: silent,
|
||||
NoForwards: noforwards,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue