Merge remote-tracking branch 'upstream/main' into dev
This commit is contained in:
commit
6b29556ef8
836 changed files with 1598388 additions and 64684 deletions
|
|
@ -1,55 +0,0 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: authkey.sql
|
||||
|
||||
package sqlcgen
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const getAuthKey = `-- name: GetAuthKey :one
|
||||
SELECT auth_key_id, body, server_salt, created_at
|
||||
FROM auth_keys
|
||||
WHERE auth_key_id = $1
|
||||
`
|
||||
|
||||
type GetAuthKeyRow struct {
|
||||
AuthKeyID int64
|
||||
Body []byte
|
||||
ServerSalt int64
|
||||
CreatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
func (q *Queries) GetAuthKey(ctx context.Context, authKeyID int64) (GetAuthKeyRow, error) {
|
||||
row := q.db.QueryRow(ctx, getAuthKey, authKeyID)
|
||||
var i GetAuthKeyRow
|
||||
err := row.Scan(
|
||||
&i.AuthKeyID,
|
||||
&i.Body,
|
||||
&i.ServerSalt,
|
||||
&i.CreatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const upsertAuthKey = `-- name: UpsertAuthKey :exec
|
||||
INSERT INTO auth_keys (auth_key_id, body, server_salt)
|
||||
VALUES ($1, $2, $3)
|
||||
ON CONFLICT (auth_key_id) DO UPDATE
|
||||
SET body = EXCLUDED.body, server_salt = EXCLUDED.server_salt
|
||||
`
|
||||
|
||||
type UpsertAuthKeyParams struct {
|
||||
AuthKeyID int64
|
||||
Body []byte
|
||||
ServerSalt int64
|
||||
}
|
||||
|
||||
func (q *Queries) UpsertAuthKey(ctx context.Context, arg UpsertAuthKeyParams) error {
|
||||
_, err := q.db.Exec(ctx, upsertAuthKey, arg.AuthKeyID, arg.Body, arg.ServerSalt)
|
||||
return err
|
||||
}
|
||||
|
|
@ -9,6 +9,46 @@ import (
|
|||
"context"
|
||||
)
|
||||
|
||||
const deleteLangPackMeta = `-- name: DeleteLangPackMeta :exec
|
||||
DELETE FROM lang_packs
|
||||
WHERE lang_pack = $1 AND lang_code = $2
|
||||
`
|
||||
|
||||
type DeleteLangPackMetaParams struct {
|
||||
LangPack string
|
||||
LangCode string
|
||||
}
|
||||
|
||||
func (q *Queries) DeleteLangPackMeta(ctx context.Context, arg DeleteLangPackMetaParams) error {
|
||||
_, err := q.db.Exec(ctx, deleteLangPackMeta, arg.LangPack, arg.LangCode)
|
||||
return err
|
||||
}
|
||||
|
||||
const deleteLangPackSeedHash = `-- name: DeleteLangPackSeedHash :exec
|
||||
DELETE FROM seed_states
|
||||
WHERE key = $1
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteLangPackSeedHash(ctx context.Context, key string) error {
|
||||
_, err := q.db.Exec(ctx, deleteLangPackSeedHash, key)
|
||||
return err
|
||||
}
|
||||
|
||||
const deleteLangPackStrings = `-- name: DeleteLangPackStrings :exec
|
||||
DELETE FROM lang_pack_strings
|
||||
WHERE lang_pack = $1 AND lang_code = $2
|
||||
`
|
||||
|
||||
type DeleteLangPackStringsParams struct {
|
||||
LangPack string
|
||||
LangCode string
|
||||
}
|
||||
|
||||
func (q *Queries) DeleteLangPackStrings(ctx context.Context, arg DeleteLangPackStringsParams) error {
|
||||
_, err := q.db.Exec(ctx, deleteLangPackStrings, arg.LangPack, arg.LangCode)
|
||||
return err
|
||||
}
|
||||
|
||||
const getLangPackMeta = `-- name: GetLangPackMeta :one
|
||||
SELECT lang_pack, lang_code, version, strings_count
|
||||
FROM lang_packs
|
||||
|
|
@ -39,6 +79,19 @@ func (q *Queries) GetLangPackMeta(ctx context.Context, arg GetLangPackMetaParams
|
|||
return i, err
|
||||
}
|
||||
|
||||
const getLangPackSeedHash = `-- name: GetLangPackSeedHash :one
|
||||
SELECT content_hash
|
||||
FROM seed_states
|
||||
WHERE key = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetLangPackSeedHash(ctx context.Context, key string) (string, error) {
|
||||
row := q.db.QueryRow(ctx, getLangPackSeedHash, key)
|
||||
var content_hash string
|
||||
err := row.Scan(&content_hash)
|
||||
return content_hash, err
|
||||
}
|
||||
|
||||
const getLangPackStringsByKeys = `-- name: GetLangPackStringsByKeys :many
|
||||
SELECT
|
||||
lang_pack, lang_code, key, version, pluralized, value,
|
||||
|
|
@ -104,6 +157,115 @@ func (q *Queries) GetLangPackStringsByKeys(ctx context.Context, arg GetLangPackS
|
|||
return items, nil
|
||||
}
|
||||
|
||||
const listLangPackCodes = `-- name: ListLangPackCodes :many
|
||||
SELECT lang_code
|
||||
FROM lang_packs
|
||||
WHERE lang_pack = $1
|
||||
ORDER BY lang_code
|
||||
`
|
||||
|
||||
func (q *Queries) ListLangPackCodes(ctx context.Context, langPack string) ([]string, error) {
|
||||
rows, err := q.db.Query(ctx, listLangPackCodes, langPack)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []string
|
||||
for rows.Next() {
|
||||
var lang_code string
|
||||
if err := rows.Scan(&lang_code); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, lang_code)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const listLangPackLanguages = `-- name: ListLangPackLanguages :many
|
||||
SELECT
|
||||
p.lang_pack,
|
||||
p.lang_code,
|
||||
p.version,
|
||||
p.strings_count,
|
||||
COALESCE(
|
||||
MAX(s.value) FILTER (WHERE s.key = 'LanguageNameInEnglish'),
|
||||
MAX(s.value) FILTER (WHERE s.key = 'Localization.EnglishLanguageName'),
|
||||
''
|
||||
)::text AS name,
|
||||
CASE
|
||||
WHEN p.lang_pack = 'android' THEN COALESCE(
|
||||
MAX(s.value) FILTER (WHERE s.key = 'TranslateLanguage' || upper(split_part(replace(p.lang_code, '-', '_'), '_', 1))),
|
||||
MAX(s.value) FILTER (WHERE s.key = 'PassportLanguage_' || upper(split_part(replace(p.lang_code, '-', '_'), '_', 1))),
|
||||
MAX(s.value) FILTER (WHERE s.key = 'LanguageName'),
|
||||
''
|
||||
)
|
||||
ELSE COALESCE(
|
||||
MAX(s.value) FILTER (WHERE s.key = 'lng_language_name'),
|
||||
MAX(s.value) FILTER (WHERE s.key = 'LanguageName'),
|
||||
MAX(s.value) FILTER (WHERE s.key = 'Localization.LanguageName'),
|
||||
MAX(s.value) FILTER (WHERE s.key = 'TranslateLanguage' || upper(split_part(replace(p.lang_code, '-', '_'), '_', 1))),
|
||||
MAX(s.value) FILTER (WHERE s.key = 'PassportLanguage_' || upper(split_part(replace(p.lang_code, '-', '_'), '_', 1))),
|
||||
''
|
||||
)
|
||||
END::text AS native_name
|
||||
FROM lang_packs p
|
||||
LEFT JOIN lang_pack_strings s
|
||||
ON s.lang_pack = p.lang_pack
|
||||
AND s.lang_code = p.lang_code
|
||||
AND s.key = ANY(ARRAY[
|
||||
'lng_language_name',
|
||||
'LanguageName',
|
||||
'LanguageNameInEnglish',
|
||||
'Localization.LanguageName',
|
||||
'Localization.EnglishLanguageName',
|
||||
'TranslateLanguage' || upper(split_part(replace(p.lang_code, '-', '_'), '_', 1)),
|
||||
'PassportLanguage_' || upper(split_part(replace(p.lang_code, '-', '_'), '_', 1))
|
||||
]::text[])
|
||||
AND NOT s.deleted
|
||||
WHERE p.lang_pack = $1
|
||||
GROUP BY p.lang_pack, p.lang_code, p.version, p.strings_count
|
||||
ORDER BY p.lang_code
|
||||
`
|
||||
|
||||
type ListLangPackLanguagesRow struct {
|
||||
LangPack string
|
||||
LangCode string
|
||||
Version int32
|
||||
StringsCount int32
|
||||
Name string
|
||||
NativeName string
|
||||
}
|
||||
|
||||
func (q *Queries) ListLangPackLanguages(ctx context.Context, langPack string) ([]ListLangPackLanguagesRow, error) {
|
||||
rows, err := q.db.Query(ctx, listLangPackLanguages, langPack)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []ListLangPackLanguagesRow
|
||||
for rows.Next() {
|
||||
var i ListLangPackLanguagesRow
|
||||
if err := rows.Scan(
|
||||
&i.LangPack,
|
||||
&i.LangCode,
|
||||
&i.Version,
|
||||
&i.StringsCount,
|
||||
&i.Name,
|
||||
&i.NativeName,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const listLangPackStrings = `-- name: ListLangPackStrings :many
|
||||
SELECT
|
||||
lang_pack, lang_code, key, version, pluralized, value,
|
||||
|
|
@ -168,6 +330,24 @@ func (q *Queries) ListLangPackStrings(ctx context.Context, arg ListLangPackStrin
|
|||
return items, nil
|
||||
}
|
||||
|
||||
const putLangPackSeedHash = `-- name: PutLangPackSeedHash :exec
|
||||
INSERT INTO seed_states (key, content_hash)
|
||||
VALUES ($1, $2)
|
||||
ON CONFLICT (key) DO UPDATE SET
|
||||
content_hash = EXCLUDED.content_hash,
|
||||
updated_at = now()
|
||||
`
|
||||
|
||||
type PutLangPackSeedHashParams struct {
|
||||
Key string
|
||||
ContentHash string
|
||||
}
|
||||
|
||||
func (q *Queries) PutLangPackSeedHash(ctx context.Context, arg PutLangPackSeedHashParams) error {
|
||||
_, err := q.db.Exec(ctx, putLangPackSeedHash, arg.Key, arg.ContentHash)
|
||||
return err
|
||||
}
|
||||
|
||||
const upsertLangPackMeta = `-- name: UpsertLangPackMeta :exec
|
||||
INSERT INTO lang_packs (lang_pack, lang_code, version, strings_count)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
|
|
|
|||
|
|
@ -53,13 +53,16 @@ type AccountReactionSetting struct {
|
|||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type AccountSendRestriction struct {
|
||||
UserID int64
|
||||
Frozen bool
|
||||
Reason string
|
||||
Actor string
|
||||
CommandID string
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
type AccountRestriction struct {
|
||||
UserID int64
|
||||
Frozen bool
|
||||
Reason string
|
||||
Actor string
|
||||
CommandID string
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
FrozenSince pgtype.Timestamptz
|
||||
FrozenUntil pgtype.Timestamptz
|
||||
AppealUrl string
|
||||
}
|
||||
|
||||
type AccountSetting struct {
|
||||
|
|
@ -131,6 +134,17 @@ type AiComposeToneSafe struct {
|
|||
SavedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
// Durable pre-send binding from album item random_id to grouped_id; never reconstructed from a retry subset.
|
||||
type AlbumGroupReservation struct {
|
||||
SenderUserID int64
|
||||
PeerType string
|
||||
PeerID int64
|
||||
RandomID int64
|
||||
IntentHash []byte
|
||||
GroupedID int64
|
||||
CreatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type AppConfig struct {
|
||||
Client string
|
||||
Hash int32
|
||||
|
|
@ -164,17 +178,28 @@ type AttachMenuUserState struct {
|
|||
}
|
||||
|
||||
type AuthKey struct {
|
||||
AuthKeyID int64
|
||||
Body []byte
|
||||
ServerSalt int64
|
||||
CreatedAt pgtype.Timestamptz
|
||||
AuthKeyID int64
|
||||
Body []byte
|
||||
ServerSalt int64
|
||||
CreatedAt pgtype.Timestamptz
|
||||
Layer int32
|
||||
DeviceModel string
|
||||
Platform string
|
||||
SystemVersion string
|
||||
ApiID int32
|
||||
AppVersion string
|
||||
LastUsedAt pgtype.Timestamptz
|
||||
ExpiresAt int32
|
||||
LayerObservationID int64
|
||||
}
|
||||
|
||||
type AuthKeySessionLayer struct {
|
||||
RawAuthKeyID int64
|
||||
SessionID int64
|
||||
Layer int32
|
||||
DeviceModel string
|
||||
Platform string
|
||||
SystemVersion string
|
||||
ApiID int32
|
||||
AppVersion string
|
||||
LastUsedAt pgtype.Timestamptz
|
||||
MsgID int64
|
||||
ObservationID int64
|
||||
ExpiresAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type Authorization struct {
|
||||
|
|
@ -627,6 +652,7 @@ type ChannelMessage struct {
|
|||
DeletePtsCount int32
|
||||
DeleteDate int32
|
||||
DeleteMessageIds []byte
|
||||
RequestFingerprint []byte
|
||||
}
|
||||
|
||||
type ChannelMessageMedium struct {
|
||||
|
|
@ -1032,6 +1058,20 @@ type LangPackString struct {
|
|||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type LoginCodeMessageDelivery struct {
|
||||
// SHA-256(phone_code_hash); raw phone_code_hash is never persisted
|
||||
DeliveryKey []byte
|
||||
// HMAC-SHA-256(code), keyed by the non-persisted raw phone_code_hash
|
||||
CodeFingerprint []byte
|
||||
UserID int64
|
||||
PrivateMessageID int64
|
||||
MessageBoxID int32
|
||||
Pts int32
|
||||
MessageDate int32
|
||||
CreatedAt pgtype.Timestamptz
|
||||
ExpiresAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type MessageBox struct {
|
||||
OwnerUserID int64
|
||||
BoxID int32
|
||||
|
|
@ -1131,6 +1171,14 @@ type PeerStarGift struct {
|
|||
SavedID int64
|
||||
}
|
||||
|
||||
type PeerTranslationSetting struct {
|
||||
UserID int64
|
||||
PeerType string
|
||||
PeerID int64
|
||||
Disabled bool
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type PeerUsername struct {
|
||||
UsernameLower string
|
||||
PeerType string
|
||||
|
|
@ -1631,6 +1679,7 @@ type UserStickerCollection struct {
|
|||
Kind string
|
||||
DocumentID int64
|
||||
UsedAt int32
|
||||
OrderKey int64
|
||||
}
|
||||
|
||||
type UserStickerSet struct {
|
||||
|
|
|
|||
|
|
@ -10,13 +10,18 @@ import (
|
|||
)
|
||||
|
||||
const deleteExpiredTempAuthKeys = `-- name: DeleteExpiredTempAuthKeys :execrows
|
||||
DELETE FROM auth_keys
|
||||
WHERE auth_key_id IN (
|
||||
SELECT temp_auth_key_id
|
||||
FROM temp_auth_key_bindings
|
||||
WHERE expires_at < $1
|
||||
WITH candidates AS (
|
||||
SELECT candidate_key.auth_key_id
|
||||
FROM auth_keys AS candidate_key
|
||||
WHERE candidate_key.expires_at > 0
|
||||
AND candidate_key.expires_at < $1
|
||||
ORDER BY candidate_key.expires_at, candidate_key.auth_key_id
|
||||
LIMIT $2
|
||||
FOR UPDATE SKIP LOCKED
|
||||
)
|
||||
DELETE FROM auth_keys AS k
|
||||
USING candidates AS c
|
||||
WHERE k.auth_key_id = c.auth_key_id
|
||||
`
|
||||
|
||||
type DeleteExpiredTempAuthKeysParams struct {
|
||||
|
|
@ -67,18 +72,24 @@ func (q *Queries) GetTempAuthKeyBinding(ctx context.Context, tempAuthKeyID int64
|
|||
return i, err
|
||||
}
|
||||
|
||||
const upsertTempAuthKeyBinding = `-- name: UpsertTempAuthKeyBinding :exec
|
||||
const upsertTempAuthKeyBinding = `-- name: UpsertTempAuthKeyBinding :execrows
|
||||
INSERT INTO temp_auth_key_bindings (
|
||||
temp_auth_key_id, perm_auth_key_id, nonce, temp_session_id, expires_at, encrypted_message
|
||||
)
|
||||
VALUES ($1, $2, $3, $4, $5, $6)
|
||||
SELECT $1, $2, $3, $4, $5, $6
|
||||
FROM auth_keys AS temp_key
|
||||
JOIN auth_keys AS perm_key ON perm_key.auth_key_id = $2
|
||||
WHERE temp_key.auth_key_id = $1
|
||||
AND temp_key.expires_at = $5
|
||||
AND temp_key.expires_at > 0
|
||||
AND perm_key.expires_at = 0
|
||||
ON CONFLICT (temp_auth_key_id) DO UPDATE SET
|
||||
perm_auth_key_id = EXCLUDED.perm_auth_key_id,
|
||||
nonce = EXCLUDED.nonce,
|
||||
temp_session_id = EXCLUDED.temp_session_id,
|
||||
expires_at = EXCLUDED.expires_at,
|
||||
encrypted_message = EXCLUDED.encrypted_message,
|
||||
created_at = now()
|
||||
WHERE temp_auth_key_bindings.perm_auth_key_id = EXCLUDED.perm_auth_key_id
|
||||
`
|
||||
|
||||
type UpsertTempAuthKeyBindingParams struct {
|
||||
|
|
@ -90,8 +101,8 @@ type UpsertTempAuthKeyBindingParams struct {
|
|||
EncryptedMessage []byte
|
||||
}
|
||||
|
||||
func (q *Queries) UpsertTempAuthKeyBinding(ctx context.Context, arg UpsertTempAuthKeyBindingParams) error {
|
||||
_, err := q.db.Exec(ctx, upsertTempAuthKeyBinding,
|
||||
func (q *Queries) UpsertTempAuthKeyBinding(ctx context.Context, arg UpsertTempAuthKeyBindingParams) (int64, error) {
|
||||
result, err := q.db.Exec(ctx, upsertTempAuthKeyBinding,
|
||||
arg.TempAuthKeyID,
|
||||
arg.PermAuthKeyID,
|
||||
arg.Nonce,
|
||||
|
|
@ -99,5 +110,8 @@ func (q *Queries) UpsertTempAuthKeyBinding(ctx context.Context, arg UpsertTempAu
|
|||
arg.ExpiresAt,
|
||||
arg.EncryptedMessage,
|
||||
)
|
||||
return err
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return result.RowsAffected(), nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue