Initial open source release
This commit is contained in:
commit
74992e893f
377 changed files with 118084 additions and 0 deletions
87
internal/store/postgres/sqlcgen/account.sql.go
Normal file
87
internal/store/postgres/sqlcgen/account.sql.go
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: account.sql
|
||||
|
||||
package sqlcgen
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
const getPasswordByUser = `-- name: GetPasswordByUser :one
|
||||
SELECT
|
||||
user_id, has_recovery, has_secure_values, has_password, hint,
|
||||
email_unconfirmed_pattern, login_email_pattern, secure_random
|
||||
FROM account_passwords
|
||||
WHERE user_id = $1
|
||||
`
|
||||
|
||||
type GetPasswordByUserRow struct {
|
||||
UserID int64
|
||||
HasRecovery bool
|
||||
HasSecureValues bool
|
||||
HasPassword bool
|
||||
Hint string
|
||||
EmailUnconfirmedPattern string
|
||||
LoginEmailPattern string
|
||||
SecureRandom []byte
|
||||
}
|
||||
|
||||
func (q *Queries) GetPasswordByUser(ctx context.Context, userID int64) (GetPasswordByUserRow, error) {
|
||||
row := q.db.QueryRow(ctx, getPasswordByUser, userID)
|
||||
var i GetPasswordByUserRow
|
||||
err := row.Scan(
|
||||
&i.UserID,
|
||||
&i.HasRecovery,
|
||||
&i.HasSecureValues,
|
||||
&i.HasPassword,
|
||||
&i.Hint,
|
||||
&i.EmailUnconfirmedPattern,
|
||||
&i.LoginEmailPattern,
|
||||
&i.SecureRandom,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const upsertPassword = `-- name: UpsertPassword :exec
|
||||
INSERT INTO account_passwords (
|
||||
user_id, has_recovery, has_secure_values, has_password, hint,
|
||||
email_unconfirmed_pattern, login_email_pattern, secure_random
|
||||
)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
||||
ON CONFLICT (user_id) DO UPDATE SET
|
||||
has_recovery = EXCLUDED.has_recovery,
|
||||
has_secure_values = EXCLUDED.has_secure_values,
|
||||
has_password = EXCLUDED.has_password,
|
||||
hint = EXCLUDED.hint,
|
||||
email_unconfirmed_pattern = EXCLUDED.email_unconfirmed_pattern,
|
||||
login_email_pattern = EXCLUDED.login_email_pattern,
|
||||
secure_random = EXCLUDED.secure_random,
|
||||
updated_at = now()
|
||||
`
|
||||
|
||||
type UpsertPasswordParams struct {
|
||||
UserID int64
|
||||
HasRecovery bool
|
||||
HasSecureValues bool
|
||||
HasPassword bool
|
||||
Hint string
|
||||
EmailUnconfirmedPattern string
|
||||
LoginEmailPattern string
|
||||
SecureRandom []byte
|
||||
}
|
||||
|
||||
func (q *Queries) UpsertPassword(ctx context.Context, arg UpsertPasswordParams) error {
|
||||
_, err := q.db.Exec(ctx, upsertPassword,
|
||||
arg.UserID,
|
||||
arg.HasRecovery,
|
||||
arg.HasSecureValues,
|
||||
arg.HasPassword,
|
||||
arg.Hint,
|
||||
arg.EmailUnconfirmedPattern,
|
||||
arg.LoginEmailPattern,
|
||||
arg.SecureRandom,
|
||||
)
|
||||
return err
|
||||
}
|
||||
46
internal/store/postgres/sqlcgen/authkey.sql.go
Normal file
46
internal/store/postgres/sqlcgen/authkey.sql.go
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: authkey.sql
|
||||
|
||||
package sqlcgen
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
const getAuthKey = `-- name: GetAuthKey :one
|
||||
SELECT auth_key_id, body, server_salt, created_at
|
||||
FROM auth_keys
|
||||
WHERE auth_key_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetAuthKey(ctx context.Context, authKeyID int64) (AuthKey, error) {
|
||||
row := q.db.QueryRow(ctx, getAuthKey, authKeyID)
|
||||
var i AuthKey
|
||||
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
|
||||
}
|
||||
124
internal/store/postgres/sqlcgen/authorization.sql.go
Normal file
124
internal/store/postgres/sqlcgen/authorization.sql.go
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: authorization.sql
|
||||
|
||||
package sqlcgen
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
const deleteAuthorization = `-- name: DeleteAuthorization :exec
|
||||
DELETE FROM authorizations WHERE auth_key_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteAuthorization(ctx context.Context, authKeyID int64) error {
|
||||
_, err := q.db.Exec(ctx, deleteAuthorization, authKeyID)
|
||||
return err
|
||||
}
|
||||
|
||||
const getAuthorizationByAuthKey = `-- name: GetAuthorizationByAuthKey :one
|
||||
SELECT auth_key_id, user_id, hash, layer, device_model, platform, system_version, api_id, app_version, ip, created_at, active_at FROM authorizations WHERE auth_key_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetAuthorizationByAuthKey(ctx context.Context, authKeyID int64) (Authorization, error) {
|
||||
row := q.db.QueryRow(ctx, getAuthorizationByAuthKey, authKeyID)
|
||||
var i Authorization
|
||||
err := row.Scan(
|
||||
&i.AuthKeyID,
|
||||
&i.UserID,
|
||||
&i.Hash,
|
||||
&i.Layer,
|
||||
&i.DeviceModel,
|
||||
&i.Platform,
|
||||
&i.SystemVersion,
|
||||
&i.ApiID,
|
||||
&i.AppVersion,
|
||||
&i.Ip,
|
||||
&i.CreatedAt,
|
||||
&i.ActiveAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const listAuthorizationsByUser = `-- name: ListAuthorizationsByUser :many
|
||||
SELECT auth_key_id, user_id, hash, layer, device_model, platform, system_version, api_id, app_version, ip, created_at, active_at FROM authorizations
|
||||
WHERE user_id = $1
|
||||
ORDER BY active_at DESC, auth_key_id DESC
|
||||
`
|
||||
|
||||
func (q *Queries) ListAuthorizationsByUser(ctx context.Context, userID int64) ([]Authorization, error) {
|
||||
rows, err := q.db.Query(ctx, listAuthorizationsByUser, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Authorization
|
||||
for rows.Next() {
|
||||
var i Authorization
|
||||
if err := rows.Scan(
|
||||
&i.AuthKeyID,
|
||||
&i.UserID,
|
||||
&i.Hash,
|
||||
&i.Layer,
|
||||
&i.DeviceModel,
|
||||
&i.Platform,
|
||||
&i.SystemVersion,
|
||||
&i.ApiID,
|
||||
&i.AppVersion,
|
||||
&i.Ip,
|
||||
&i.CreatedAt,
|
||||
&i.ActiveAt,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const upsertAuthorization = `-- name: UpsertAuthorization :exec
|
||||
INSERT INTO authorizations (auth_key_id, user_id, layer, device_model, platform, system_version, api_id, app_version, ip)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
|
||||
ON CONFLICT (auth_key_id) DO UPDATE SET
|
||||
user_id = EXCLUDED.user_id,
|
||||
layer = EXCLUDED.layer,
|
||||
device_model = EXCLUDED.device_model,
|
||||
platform = EXCLUDED.platform,
|
||||
system_version = EXCLUDED.system_version,
|
||||
api_id = EXCLUDED.api_id,
|
||||
app_version = EXCLUDED.app_version,
|
||||
ip = EXCLUDED.ip,
|
||||
active_at = now()
|
||||
`
|
||||
|
||||
type UpsertAuthorizationParams struct {
|
||||
AuthKeyID int64
|
||||
UserID int64
|
||||
Layer int32
|
||||
DeviceModel string
|
||||
Platform string
|
||||
SystemVersion string
|
||||
ApiID int32
|
||||
AppVersion string
|
||||
Ip string
|
||||
}
|
||||
|
||||
func (q *Queries) UpsertAuthorization(ctx context.Context, arg UpsertAuthorizationParams) error {
|
||||
_, err := q.db.Exec(ctx, upsertAuthorization,
|
||||
arg.AuthKeyID,
|
||||
arg.UserID,
|
||||
arg.Layer,
|
||||
arg.DeviceModel,
|
||||
arg.Platform,
|
||||
arg.SystemVersion,
|
||||
arg.ApiID,
|
||||
arg.AppVersion,
|
||||
arg.Ip,
|
||||
)
|
||||
return err
|
||||
}
|
||||
426
internal/store/postgres/sqlcgen/contact.sql.go
Normal file
426
internal/store/postgres/sqlcgen/contact.sql.go
Normal file
|
|
@ -0,0 +1,426 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: contact.sql
|
||||
|
||||
package sqlcgen
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
const deleteContacts = `-- name: DeleteContacts :one
|
||||
WITH deleted AS (
|
||||
DELETE FROM contacts
|
||||
WHERE user_id = $1::bigint
|
||||
AND contact_user_id = ANY($2::bigint[])
|
||||
RETURNING contact_user_id
|
||||
),
|
||||
reverse_updated AS (
|
||||
UPDATE contacts c
|
||||
SET mutual = false,
|
||||
updated_at = now()
|
||||
FROM deleted d
|
||||
WHERE c.user_id = d.contact_user_id
|
||||
AND c.contact_user_id = $1::bigint
|
||||
RETURNING c.user_id
|
||||
)
|
||||
SELECT COUNT(*)::int AS deleted_count
|
||||
FROM deleted
|
||||
`
|
||||
|
||||
type DeleteContactsParams struct {
|
||||
UserID int64
|
||||
ContactUserIds []int64
|
||||
}
|
||||
|
||||
func (q *Queries) DeleteContacts(ctx context.Context, arg DeleteContactsParams) (int32, error) {
|
||||
row := q.db.QueryRow(ctx, deleteContacts, arg.UserID, arg.ContactUserIds)
|
||||
var deleted_count int32
|
||||
err := row.Scan(&deleted_count)
|
||||
return deleted_count, err
|
||||
}
|
||||
|
||||
const getContact = `-- name: GetContact :one
|
||||
SELECT
|
||||
c.contact_user_id,
|
||||
c.mutual,
|
||||
c.contact_phone,
|
||||
c.contact_first_name,
|
||||
c.contact_last_name,
|
||||
c.note,
|
||||
COALESCE(c.note_entities::text, '[]')::text AS note_entities_json,
|
||||
u.id,
|
||||
u.access_hash,
|
||||
COALESCE(NULLIF(c.contact_phone, ''), u.phone)::text AS phone,
|
||||
COALESCE(NULLIF(c.contact_first_name, ''), u.first_name)::text AS first_name,
|
||||
COALESCE(c.contact_last_name, u.last_name)::text AS last_name,
|
||||
u.username,
|
||||
u.country_code,
|
||||
u.verified,
|
||||
u.support,
|
||||
u.last_seen_at
|
||||
FROM contacts c
|
||||
JOIN users u ON u.id = c.contact_user_id
|
||||
WHERE c.user_id = $1
|
||||
AND c.contact_user_id = $2
|
||||
`
|
||||
|
||||
type GetContactParams struct {
|
||||
UserID int64
|
||||
ContactUserID int64
|
||||
}
|
||||
|
||||
type GetContactRow struct {
|
||||
ContactUserID int64
|
||||
Mutual bool
|
||||
ContactPhone string
|
||||
ContactFirstName string
|
||||
ContactLastName string
|
||||
Note string
|
||||
NoteEntitiesJson string
|
||||
ID int64
|
||||
AccessHash int64
|
||||
Phone string
|
||||
FirstName string
|
||||
LastName string
|
||||
Username string
|
||||
CountryCode string
|
||||
Verified bool
|
||||
Support bool
|
||||
LastSeenAt int64
|
||||
}
|
||||
|
||||
func (q *Queries) GetContact(ctx context.Context, arg GetContactParams) (GetContactRow, error) {
|
||||
row := q.db.QueryRow(ctx, getContact, arg.UserID, arg.ContactUserID)
|
||||
var i GetContactRow
|
||||
err := row.Scan(
|
||||
&i.ContactUserID,
|
||||
&i.Mutual,
|
||||
&i.ContactPhone,
|
||||
&i.ContactFirstName,
|
||||
&i.ContactLastName,
|
||||
&i.Note,
|
||||
&i.NoteEntitiesJson,
|
||||
&i.ID,
|
||||
&i.AccessHash,
|
||||
&i.Phone,
|
||||
&i.FirstName,
|
||||
&i.LastName,
|
||||
&i.Username,
|
||||
&i.CountryCode,
|
||||
&i.Verified,
|
||||
&i.Support,
|
||||
&i.LastSeenAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const listContactsByUser = `-- name: ListContactsByUser :many
|
||||
SELECT
|
||||
c.contact_user_id,
|
||||
c.mutual,
|
||||
c.contact_phone,
|
||||
c.contact_first_name,
|
||||
c.contact_last_name,
|
||||
c.note,
|
||||
COALESCE(c.note_entities::text, '[]')::text AS note_entities_json,
|
||||
u.id,
|
||||
u.access_hash,
|
||||
COALESCE(NULLIF(c.contact_phone, ''), u.phone)::text AS phone,
|
||||
COALESCE(NULLIF(c.contact_first_name, ''), u.first_name)::text AS first_name,
|
||||
COALESCE(c.contact_last_name, u.last_name)::text AS last_name,
|
||||
u.username,
|
||||
u.country_code,
|
||||
u.verified,
|
||||
u.support,
|
||||
u.last_seen_at
|
||||
FROM contacts c
|
||||
JOIN users u ON u.id = c.contact_user_id
|
||||
WHERE c.user_id = $1
|
||||
ORDER BY c.contact_first_name, c.contact_last_name, u.first_name, u.last_name, u.id
|
||||
`
|
||||
|
||||
type ListContactsByUserRow struct {
|
||||
ContactUserID int64
|
||||
Mutual bool
|
||||
ContactPhone string
|
||||
ContactFirstName string
|
||||
ContactLastName string
|
||||
Note string
|
||||
NoteEntitiesJson string
|
||||
ID int64
|
||||
AccessHash int64
|
||||
Phone string
|
||||
FirstName string
|
||||
LastName string
|
||||
Username string
|
||||
CountryCode string
|
||||
Verified bool
|
||||
Support bool
|
||||
LastSeenAt int64
|
||||
}
|
||||
|
||||
func (q *Queries) ListContactsByUser(ctx context.Context, userID int64) ([]ListContactsByUserRow, error) {
|
||||
rows, err := q.db.Query(ctx, listContactsByUser, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []ListContactsByUserRow
|
||||
for rows.Next() {
|
||||
var i ListContactsByUserRow
|
||||
if err := rows.Scan(
|
||||
&i.ContactUserID,
|
||||
&i.Mutual,
|
||||
&i.ContactPhone,
|
||||
&i.ContactFirstName,
|
||||
&i.ContactLastName,
|
||||
&i.Note,
|
||||
&i.NoteEntitiesJson,
|
||||
&i.ID,
|
||||
&i.AccessHash,
|
||||
&i.Phone,
|
||||
&i.FirstName,
|
||||
&i.LastName,
|
||||
&i.Username,
|
||||
&i.CountryCode,
|
||||
&i.Verified,
|
||||
&i.Support,
|
||||
&i.LastSeenAt,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const updateContactNote = `-- name: UpdateContactNote :one
|
||||
WITH updated AS (
|
||||
UPDATE contacts c
|
||||
SET note = $1::text,
|
||||
note_entities = $2::jsonb,
|
||||
updated_at = now()
|
||||
WHERE c.user_id = $3::bigint
|
||||
AND c.contact_user_id = $4::bigint
|
||||
RETURNING user_id, contact_user_id, mutual, created_at, updated_at, contact_phone, contact_first_name, contact_last_name, note, note_entities, close_friend, stories_hidden
|
||||
)
|
||||
SELECT
|
||||
c.contact_user_id,
|
||||
c.mutual,
|
||||
c.contact_phone,
|
||||
c.contact_first_name,
|
||||
c.contact_last_name,
|
||||
c.note,
|
||||
COALESCE(c.note_entities::text, '[]')::text AS note_entities_json,
|
||||
u.id,
|
||||
u.access_hash,
|
||||
COALESCE(NULLIF(c.contact_phone, ''), u.phone)::text AS phone,
|
||||
COALESCE(NULLIF(c.contact_first_name, ''), u.first_name)::text AS first_name,
|
||||
COALESCE(c.contact_last_name, u.last_name)::text AS last_name,
|
||||
u.username,
|
||||
u.country_code,
|
||||
u.verified,
|
||||
u.support,
|
||||
u.last_seen_at
|
||||
FROM updated c
|
||||
JOIN users u ON u.id = c.contact_user_id
|
||||
`
|
||||
|
||||
type UpdateContactNoteParams struct {
|
||||
Note string
|
||||
NoteEntities []byte
|
||||
UserID int64
|
||||
ContactUserID int64
|
||||
}
|
||||
|
||||
type UpdateContactNoteRow struct {
|
||||
ContactUserID int64
|
||||
Mutual bool
|
||||
ContactPhone string
|
||||
ContactFirstName string
|
||||
ContactLastName string
|
||||
Note string
|
||||
NoteEntitiesJson string
|
||||
ID int64
|
||||
AccessHash int64
|
||||
Phone string
|
||||
FirstName string
|
||||
LastName string
|
||||
Username string
|
||||
CountryCode string
|
||||
Verified bool
|
||||
Support bool
|
||||
LastSeenAt int64
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateContactNote(ctx context.Context, arg UpdateContactNoteParams) (UpdateContactNoteRow, error) {
|
||||
row := q.db.QueryRow(ctx, updateContactNote,
|
||||
arg.Note,
|
||||
arg.NoteEntities,
|
||||
arg.UserID,
|
||||
arg.ContactUserID,
|
||||
)
|
||||
var i UpdateContactNoteRow
|
||||
err := row.Scan(
|
||||
&i.ContactUserID,
|
||||
&i.Mutual,
|
||||
&i.ContactPhone,
|
||||
&i.ContactFirstName,
|
||||
&i.ContactLastName,
|
||||
&i.Note,
|
||||
&i.NoteEntitiesJson,
|
||||
&i.ID,
|
||||
&i.AccessHash,
|
||||
&i.Phone,
|
||||
&i.FirstName,
|
||||
&i.LastName,
|
||||
&i.Username,
|
||||
&i.CountryCode,
|
||||
&i.Verified,
|
||||
&i.Support,
|
||||
&i.LastSeenAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const upsertContact = `-- name: UpsertContact :one
|
||||
WITH reverse AS (
|
||||
SELECT EXISTS (
|
||||
SELECT 1
|
||||
FROM contacts
|
||||
WHERE user_id = $1::bigint
|
||||
AND contact_user_id = $2::bigint
|
||||
)::boolean AS mutual
|
||||
),
|
||||
upserted AS (
|
||||
INSERT INTO contacts (
|
||||
user_id,
|
||||
contact_user_id,
|
||||
contact_phone,
|
||||
contact_first_name,
|
||||
contact_last_name,
|
||||
note,
|
||||
note_entities,
|
||||
mutual
|
||||
)
|
||||
SELECT
|
||||
$2::bigint,
|
||||
$1::bigint,
|
||||
$3::text,
|
||||
$4::text,
|
||||
$5::text,
|
||||
$6::text,
|
||||
$7::jsonb,
|
||||
reverse.mutual
|
||||
FROM reverse
|
||||
ON CONFLICT (user_id, contact_user_id) DO UPDATE SET
|
||||
contact_phone = EXCLUDED.contact_phone,
|
||||
contact_first_name = EXCLUDED.contact_first_name,
|
||||
contact_last_name = EXCLUDED.contact_last_name,
|
||||
note = EXCLUDED.note,
|
||||
note_entities = EXCLUDED.note_entities,
|
||||
mutual = contacts.mutual OR EXCLUDED.mutual,
|
||||
updated_at = now()
|
||||
RETURNING user_id, contact_user_id, mutual, created_at, updated_at, contact_phone, contact_first_name, contact_last_name, note, note_entities, close_friend, stories_hidden
|
||||
),
|
||||
reverse_updated AS (
|
||||
UPDATE contacts c
|
||||
SET mutual = true,
|
||||
updated_at = now()
|
||||
WHERE c.user_id = $1::bigint
|
||||
AND c.contact_user_id = $2::bigint
|
||||
AND NOT c.mutual
|
||||
RETURNING c.user_id
|
||||
)
|
||||
SELECT
|
||||
c.contact_user_id,
|
||||
c.mutual,
|
||||
c.contact_phone,
|
||||
c.contact_first_name,
|
||||
c.contact_last_name,
|
||||
c.note,
|
||||
COALESCE(c.note_entities::text, '[]')::text AS note_entities_json,
|
||||
u.id,
|
||||
u.access_hash,
|
||||
COALESCE(NULLIF(c.contact_phone, ''), u.phone)::text AS phone,
|
||||
COALESCE(NULLIF(c.contact_first_name, ''), u.first_name)::text AS first_name,
|
||||
COALESCE(c.contact_last_name, u.last_name)::text AS last_name,
|
||||
u.username,
|
||||
u.country_code,
|
||||
u.verified,
|
||||
u.support,
|
||||
u.last_seen_at,
|
||||
EXISTS (SELECT 1 FROM reverse_updated)::boolean AS reverse_mutual_changed
|
||||
FROM upserted c
|
||||
JOIN users u ON u.id = c.contact_user_id
|
||||
`
|
||||
|
||||
type UpsertContactParams struct {
|
||||
ContactUserID int64
|
||||
UserID int64
|
||||
ContactPhone string
|
||||
ContactFirstName string
|
||||
ContactLastName string
|
||||
Note string
|
||||
NoteEntities []byte
|
||||
}
|
||||
|
||||
type UpsertContactRow struct {
|
||||
ContactUserID int64
|
||||
Mutual bool
|
||||
ContactPhone string
|
||||
ContactFirstName string
|
||||
ContactLastName string
|
||||
Note string
|
||||
NoteEntitiesJson string
|
||||
ID int64
|
||||
AccessHash int64
|
||||
Phone string
|
||||
FirstName string
|
||||
LastName string
|
||||
Username string
|
||||
CountryCode string
|
||||
Verified bool
|
||||
Support bool
|
||||
LastSeenAt int64
|
||||
ReverseMutualChanged bool
|
||||
}
|
||||
|
||||
func (q *Queries) UpsertContact(ctx context.Context, arg UpsertContactParams) (UpsertContactRow, error) {
|
||||
row := q.db.QueryRow(ctx, upsertContact,
|
||||
arg.ContactUserID,
|
||||
arg.UserID,
|
||||
arg.ContactPhone,
|
||||
arg.ContactFirstName,
|
||||
arg.ContactLastName,
|
||||
arg.Note,
|
||||
arg.NoteEntities,
|
||||
)
|
||||
var i UpsertContactRow
|
||||
err := row.Scan(
|
||||
&i.ContactUserID,
|
||||
&i.Mutual,
|
||||
&i.ContactPhone,
|
||||
&i.ContactFirstName,
|
||||
&i.ContactLastName,
|
||||
&i.Note,
|
||||
&i.NoteEntitiesJson,
|
||||
&i.ID,
|
||||
&i.AccessHash,
|
||||
&i.Phone,
|
||||
&i.FirstName,
|
||||
&i.LastName,
|
||||
&i.Username,
|
||||
&i.CountryCode,
|
||||
&i.Verified,
|
||||
&i.Support,
|
||||
&i.LastSeenAt,
|
||||
&i.ReverseMutualChanged,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
32
internal/store/postgres/sqlcgen/db.go
Normal file
32
internal/store/postgres/sqlcgen/db.go
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
|
||||
package sqlcgen
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
)
|
||||
|
||||
type DBTX interface {
|
||||
Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
|
||||
Query(context.Context, string, ...interface{}) (pgx.Rows, error)
|
||||
QueryRow(context.Context, string, ...interface{}) pgx.Row
|
||||
}
|
||||
|
||||
func New(db DBTX) *Queries {
|
||||
return &Queries{db: db}
|
||||
}
|
||||
|
||||
type Queries struct {
|
||||
db DBTX
|
||||
}
|
||||
|
||||
func (q *Queries) WithTx(tx pgx.Tx) *Queries {
|
||||
return &Queries{
|
||||
db: tx,
|
||||
}
|
||||
}
|
||||
1592
internal/store/postgres/sqlcgen/dialog.sql.go
Normal file
1592
internal/store/postgres/sqlcgen/dialog.sql.go
Normal file
File diff suppressed because it is too large
Load diff
159
internal/store/postgres/sqlcgen/help.sql.go
Normal file
159
internal/store/postgres/sqlcgen/help.sql.go
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: help.sql
|
||||
|
||||
package sqlcgen
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
const getAppConfig = `-- name: GetAppConfig :one
|
||||
SELECT client, hash, config_json::text AS config_json
|
||||
FROM app_configs
|
||||
WHERE client = $1
|
||||
`
|
||||
|
||||
type GetAppConfigRow struct {
|
||||
Client string
|
||||
Hash int32
|
||||
ConfigJson string
|
||||
}
|
||||
|
||||
func (q *Queries) GetAppConfig(ctx context.Context, client string) (GetAppConfigRow, error) {
|
||||
row := q.db.QueryRow(ctx, getAppConfig, client)
|
||||
var i GetAppConfigRow
|
||||
err := row.Scan(&i.Client, &i.Hash, &i.ConfigJson)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const listCountries = `-- name: ListCountries :many
|
||||
SELECT
|
||||
c.iso2,
|
||||
c.default_name,
|
||||
c.name,
|
||||
c.hidden,
|
||||
cc.country_code,
|
||||
cc.prefixes,
|
||||
cc.patterns
|
||||
FROM countries c
|
||||
JOIN country_codes cc ON cc.iso2 = c.iso2
|
||||
ORDER BY c.order_index, c.iso2, cc.order_index, cc.country_code
|
||||
`
|
||||
|
||||
type ListCountriesRow struct {
|
||||
Iso2 string
|
||||
DefaultName string
|
||||
Name string
|
||||
Hidden bool
|
||||
CountryCode string
|
||||
Prefixes []string
|
||||
Patterns []string
|
||||
}
|
||||
|
||||
func (q *Queries) ListCountries(ctx context.Context) ([]ListCountriesRow, error) {
|
||||
rows, err := q.db.Query(ctx, listCountries)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []ListCountriesRow
|
||||
for rows.Next() {
|
||||
var i ListCountriesRow
|
||||
if err := rows.Scan(
|
||||
&i.Iso2,
|
||||
&i.DefaultName,
|
||||
&i.Name,
|
||||
&i.Hidden,
|
||||
&i.CountryCode,
|
||||
&i.Prefixes,
|
||||
&i.Patterns,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const upsertAppConfig = `-- name: UpsertAppConfig :exec
|
||||
INSERT INTO app_configs (client, hash, config_json)
|
||||
VALUES ($1, $2, $3::jsonb)
|
||||
ON CONFLICT (client) DO UPDATE SET
|
||||
hash = EXCLUDED.hash,
|
||||
config_json = EXCLUDED.config_json,
|
||||
updated_at = now()
|
||||
`
|
||||
|
||||
type UpsertAppConfigParams struct {
|
||||
Client string
|
||||
Hash int32
|
||||
ConfigJson []byte
|
||||
}
|
||||
|
||||
func (q *Queries) UpsertAppConfig(ctx context.Context, arg UpsertAppConfigParams) error {
|
||||
_, err := q.db.Exec(ctx, upsertAppConfig, arg.Client, arg.Hash, arg.ConfigJson)
|
||||
return err
|
||||
}
|
||||
|
||||
const upsertCountry = `-- name: UpsertCountry :exec
|
||||
INSERT INTO countries (iso2, default_name, name, hidden, order_index)
|
||||
VALUES ($1, $2, $3, $4, $5)
|
||||
ON CONFLICT (iso2) DO UPDATE SET
|
||||
default_name = EXCLUDED.default_name,
|
||||
name = EXCLUDED.name,
|
||||
hidden = EXCLUDED.hidden,
|
||||
order_index = EXCLUDED.order_index,
|
||||
updated_at = now()
|
||||
`
|
||||
|
||||
type UpsertCountryParams struct {
|
||||
Iso2 string
|
||||
DefaultName string
|
||||
Name string
|
||||
Hidden bool
|
||||
OrderIndex int32
|
||||
}
|
||||
|
||||
func (q *Queries) UpsertCountry(ctx context.Context, arg UpsertCountryParams) error {
|
||||
_, err := q.db.Exec(ctx, upsertCountry,
|
||||
arg.Iso2,
|
||||
arg.DefaultName,
|
||||
arg.Name,
|
||||
arg.Hidden,
|
||||
arg.OrderIndex,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
const upsertCountryCode = `-- name: UpsertCountryCode :exec
|
||||
INSERT INTO country_codes (iso2, country_code, prefixes, patterns, order_index)
|
||||
VALUES ($1, $2, $3, $4, $5)
|
||||
ON CONFLICT (iso2, country_code) DO UPDATE SET
|
||||
prefixes = EXCLUDED.prefixes,
|
||||
patterns = EXCLUDED.patterns,
|
||||
order_index = EXCLUDED.order_index
|
||||
`
|
||||
|
||||
type UpsertCountryCodeParams struct {
|
||||
Iso2 string
|
||||
CountryCode string
|
||||
Prefixes []string
|
||||
Patterns []string
|
||||
OrderIndex int32
|
||||
}
|
||||
|
||||
func (q *Queries) UpsertCountryCode(ctx context.Context, arg UpsertCountryCodeParams) error {
|
||||
_, err := q.db.Exec(ctx, upsertCountryCode,
|
||||
arg.Iso2,
|
||||
arg.CountryCode,
|
||||
arg.Prefixes,
|
||||
arg.Patterns,
|
||||
arg.OrderIndex,
|
||||
)
|
||||
return err
|
||||
}
|
||||
250
internal/store/postgres/sqlcgen/langpack.sql.go
Normal file
250
internal/store/postgres/sqlcgen/langpack.sql.go
Normal file
|
|
@ -0,0 +1,250 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: langpack.sql
|
||||
|
||||
package sqlcgen
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
const getLangPackMeta = `-- name: GetLangPackMeta :one
|
||||
SELECT lang_pack, lang_code, version, strings_count
|
||||
FROM lang_packs
|
||||
WHERE lang_pack = $1 AND lang_code = $2
|
||||
`
|
||||
|
||||
type GetLangPackMetaParams struct {
|
||||
LangPack string
|
||||
LangCode string
|
||||
}
|
||||
|
||||
type GetLangPackMetaRow struct {
|
||||
LangPack string
|
||||
LangCode string
|
||||
Version int32
|
||||
StringsCount int32
|
||||
}
|
||||
|
||||
func (q *Queries) GetLangPackMeta(ctx context.Context, arg GetLangPackMetaParams) (GetLangPackMetaRow, error) {
|
||||
row := q.db.QueryRow(ctx, getLangPackMeta, arg.LangPack, arg.LangCode)
|
||||
var i GetLangPackMetaRow
|
||||
err := row.Scan(
|
||||
&i.LangPack,
|
||||
&i.LangCode,
|
||||
&i.Version,
|
||||
&i.StringsCount,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getLangPackStringsByKeys = `-- name: GetLangPackStringsByKeys :many
|
||||
SELECT
|
||||
lang_pack, lang_code, key, version, pluralized, value,
|
||||
zero_value, one_value, two_value, few_value, many_value, other_value, deleted
|
||||
FROM lang_pack_strings
|
||||
WHERE lang_pack = $1 AND lang_code = $2 AND key = ANY($3::text[]) AND NOT deleted
|
||||
ORDER BY key
|
||||
`
|
||||
|
||||
type GetLangPackStringsByKeysParams struct {
|
||||
LangPack string
|
||||
LangCode string
|
||||
Keys []string
|
||||
}
|
||||
|
||||
type GetLangPackStringsByKeysRow struct {
|
||||
LangPack string
|
||||
LangCode string
|
||||
Key string
|
||||
Version int32
|
||||
Pluralized bool
|
||||
Value string
|
||||
ZeroValue string
|
||||
OneValue string
|
||||
TwoValue string
|
||||
FewValue string
|
||||
ManyValue string
|
||||
OtherValue string
|
||||
Deleted bool
|
||||
}
|
||||
|
||||
func (q *Queries) GetLangPackStringsByKeys(ctx context.Context, arg GetLangPackStringsByKeysParams) ([]GetLangPackStringsByKeysRow, error) {
|
||||
rows, err := q.db.Query(ctx, getLangPackStringsByKeys, arg.LangPack, arg.LangCode, arg.Keys)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []GetLangPackStringsByKeysRow
|
||||
for rows.Next() {
|
||||
var i GetLangPackStringsByKeysRow
|
||||
if err := rows.Scan(
|
||||
&i.LangPack,
|
||||
&i.LangCode,
|
||||
&i.Key,
|
||||
&i.Version,
|
||||
&i.Pluralized,
|
||||
&i.Value,
|
||||
&i.ZeroValue,
|
||||
&i.OneValue,
|
||||
&i.TwoValue,
|
||||
&i.FewValue,
|
||||
&i.ManyValue,
|
||||
&i.OtherValue,
|
||||
&i.Deleted,
|
||||
); 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,
|
||||
zero_value, one_value, two_value, few_value, many_value, other_value, deleted
|
||||
FROM lang_pack_strings
|
||||
WHERE lang_pack = $1 AND lang_code = $2 AND NOT deleted
|
||||
ORDER BY key
|
||||
`
|
||||
|
||||
type ListLangPackStringsParams struct {
|
||||
LangPack string
|
||||
LangCode string
|
||||
}
|
||||
|
||||
type ListLangPackStringsRow struct {
|
||||
LangPack string
|
||||
LangCode string
|
||||
Key string
|
||||
Version int32
|
||||
Pluralized bool
|
||||
Value string
|
||||
ZeroValue string
|
||||
OneValue string
|
||||
TwoValue string
|
||||
FewValue string
|
||||
ManyValue string
|
||||
OtherValue string
|
||||
Deleted bool
|
||||
}
|
||||
|
||||
func (q *Queries) ListLangPackStrings(ctx context.Context, arg ListLangPackStringsParams) ([]ListLangPackStringsRow, error) {
|
||||
rows, err := q.db.Query(ctx, listLangPackStrings, arg.LangPack, arg.LangCode)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []ListLangPackStringsRow
|
||||
for rows.Next() {
|
||||
var i ListLangPackStringsRow
|
||||
if err := rows.Scan(
|
||||
&i.LangPack,
|
||||
&i.LangCode,
|
||||
&i.Key,
|
||||
&i.Version,
|
||||
&i.Pluralized,
|
||||
&i.Value,
|
||||
&i.ZeroValue,
|
||||
&i.OneValue,
|
||||
&i.TwoValue,
|
||||
&i.FewValue,
|
||||
&i.ManyValue,
|
||||
&i.OtherValue,
|
||||
&i.Deleted,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const upsertLangPackMeta = `-- name: UpsertLangPackMeta :exec
|
||||
INSERT INTO lang_packs (lang_pack, lang_code, version, strings_count)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
ON CONFLICT (lang_pack, lang_code) DO UPDATE SET
|
||||
version = EXCLUDED.version,
|
||||
strings_count = EXCLUDED.strings_count,
|
||||
updated_at = now()
|
||||
`
|
||||
|
||||
type UpsertLangPackMetaParams struct {
|
||||
LangPack string
|
||||
LangCode string
|
||||
Version int32
|
||||
StringsCount int32
|
||||
}
|
||||
|
||||
func (q *Queries) UpsertLangPackMeta(ctx context.Context, arg UpsertLangPackMetaParams) error {
|
||||
_, err := q.db.Exec(ctx, upsertLangPackMeta,
|
||||
arg.LangPack,
|
||||
arg.LangCode,
|
||||
arg.Version,
|
||||
arg.StringsCount,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
const upsertLangPackString = `-- name: UpsertLangPackString :exec
|
||||
INSERT INTO lang_pack_strings (
|
||||
lang_pack, lang_code, key, version, pluralized, value,
|
||||
zero_value, one_value, two_value, few_value, many_value, other_value, deleted
|
||||
)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)
|
||||
ON CONFLICT (lang_pack, lang_code, key) DO UPDATE SET
|
||||
version = EXCLUDED.version,
|
||||
pluralized = EXCLUDED.pluralized,
|
||||
value = EXCLUDED.value,
|
||||
zero_value = EXCLUDED.zero_value,
|
||||
one_value = EXCLUDED.one_value,
|
||||
two_value = EXCLUDED.two_value,
|
||||
few_value = EXCLUDED.few_value,
|
||||
many_value = EXCLUDED.many_value,
|
||||
other_value = EXCLUDED.other_value,
|
||||
deleted = EXCLUDED.deleted,
|
||||
updated_at = now()
|
||||
`
|
||||
|
||||
type UpsertLangPackStringParams struct {
|
||||
LangPack string
|
||||
LangCode string
|
||||
Key string
|
||||
Version int32
|
||||
Pluralized bool
|
||||
Value string
|
||||
ZeroValue string
|
||||
OneValue string
|
||||
TwoValue string
|
||||
FewValue string
|
||||
ManyValue string
|
||||
OtherValue string
|
||||
Deleted bool
|
||||
}
|
||||
|
||||
func (q *Queries) UpsertLangPackString(ctx context.Context, arg UpsertLangPackStringParams) error {
|
||||
_, err := q.db.Exec(ctx, upsertLangPackString,
|
||||
arg.LangPack,
|
||||
arg.LangCode,
|
||||
arg.Key,
|
||||
arg.Version,
|
||||
arg.Pluralized,
|
||||
arg.Value,
|
||||
arg.ZeroValue,
|
||||
arg.OneValue,
|
||||
arg.TwoValue,
|
||||
arg.FewValue,
|
||||
arg.ManyValue,
|
||||
arg.OtherValue,
|
||||
arg.Deleted,
|
||||
)
|
||||
return err
|
||||
}
|
||||
1154
internal/store/postgres/sqlcgen/media.sql.go
Normal file
1154
internal/store/postgres/sqlcgen/media.sql.go
Normal file
File diff suppressed because it is too large
Load diff
2331
internal/store/postgres/sqlcgen/message.sql.go
Normal file
2331
internal/store/postgres/sqlcgen/message.sql.go
Normal file
File diff suppressed because it is too large
Load diff
681
internal/store/postgres/sqlcgen/models.go
Normal file
681
internal/store/postgres/sqlcgen/models.go
Normal file
|
|
@ -0,0 +1,681 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
|
||||
package sqlcgen
|
||||
|
||||
import (
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
type AccountPassword struct {
|
||||
UserID int64
|
||||
HasRecovery bool
|
||||
HasSecureValues bool
|
||||
HasPassword bool
|
||||
Hint string
|
||||
EmailUnconfirmedPattern string
|
||||
LoginEmailPattern string
|
||||
SecureRandom []byte
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type AppConfig struct {
|
||||
Client string
|
||||
Hash int32
|
||||
ConfigJson []byte
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type AuthKey struct {
|
||||
AuthKeyID int64
|
||||
Body []byte
|
||||
ServerSalt int64
|
||||
CreatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type Authorization struct {
|
||||
AuthKeyID int64
|
||||
UserID int64
|
||||
Hash int64
|
||||
Layer int32
|
||||
DeviceModel string
|
||||
Platform string
|
||||
SystemVersion string
|
||||
ApiID int32
|
||||
AppVersion string
|
||||
Ip string
|
||||
CreatedAt pgtype.Timestamptz
|
||||
ActiveAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type AvailableReaction struct {
|
||||
Reaction string
|
||||
Title string
|
||||
Inactive bool
|
||||
Premium bool
|
||||
StaticIconID int64
|
||||
AppearAnimationID int64
|
||||
SelectAnimationID int64
|
||||
ActivateAnimationID int64
|
||||
EffectAnimationID int64
|
||||
AroundAnimationID int64
|
||||
CenterIconID int64
|
||||
SortOrder int32
|
||||
}
|
||||
|
||||
type Channel struct {
|
||||
ID int64
|
||||
AccessHash int64
|
||||
CreatorUserID int64
|
||||
Title string
|
||||
About string
|
||||
Username *string
|
||||
Broadcast bool
|
||||
Megagroup bool
|
||||
Forum bool
|
||||
ForumTabs bool
|
||||
Noforwards bool
|
||||
JoinToSend bool
|
||||
JoinRequest bool
|
||||
Signatures bool
|
||||
PreHistoryHidden bool
|
||||
ParticipantsHidden bool
|
||||
Antispam bool
|
||||
LinkedChatID int64
|
||||
SlowmodeSeconds int32
|
||||
DefaultBannedRights []byte
|
||||
AvailableReactions []byte
|
||||
ColorSet bool
|
||||
Color int32
|
||||
ColorBackgroundEmojiID int64
|
||||
ProfileColorSet bool
|
||||
ProfileColor int32
|
||||
ProfileColorBackgroundEmojiID int64
|
||||
EmojiStatusDocumentID int64
|
||||
EmojiStatusUntil int32
|
||||
ParticipantsCount int32
|
||||
AdminsCount int32
|
||||
KickedCount int32
|
||||
BannedCount int32
|
||||
TopMessageID int32
|
||||
Pts int32
|
||||
AdminLogSeq int64
|
||||
TtlPeriod int32
|
||||
Date int32
|
||||
Deleted bool
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
PinnedMessageID int32
|
||||
Autotranslation bool
|
||||
RestrictedSponsored bool
|
||||
BroadcastMessagesAllowed bool
|
||||
SendPaidMessagesStars int64
|
||||
PhotoID int64
|
||||
PhotoDcID int32
|
||||
PhotoStripped []byte
|
||||
}
|
||||
|
||||
type ChannelAdminLogEvent struct {
|
||||
ChannelID int64
|
||||
ID int64
|
||||
ActorUserID int64
|
||||
EventDate int32
|
||||
EventType string
|
||||
PrevString string
|
||||
NewString string
|
||||
PrevBool bool
|
||||
NewBool bool
|
||||
PrevInt int32
|
||||
NewInt int32
|
||||
PrevParticipant []byte
|
||||
NewParticipant []byte
|
||||
Participant []byte
|
||||
Message []byte
|
||||
PrevMessage []byte
|
||||
NewMessage []byte
|
||||
Query string
|
||||
CreatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type ChannelDialog struct {
|
||||
UserID int64
|
||||
ChannelID int64
|
||||
FolderID int32
|
||||
TopMessageID int32
|
||||
TopMessageDate int32
|
||||
ReadInboxMaxID int32
|
||||
ReadOutboxMaxID int32
|
||||
UnreadCount int32
|
||||
UnreadMentionsCount int32
|
||||
UnreadReactionsCount int32
|
||||
Pinned bool
|
||||
PinnedOrder int32
|
||||
UnreadMark bool
|
||||
ViewForumAsMessages bool
|
||||
NotifySettings []byte
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
DefaultSendAsPeerType *string
|
||||
DefaultSendAsPeerID *int64
|
||||
}
|
||||
|
||||
type ChannelForumTopic struct {
|
||||
ChannelID int64
|
||||
TopicID int32
|
||||
CreatorUserID int64
|
||||
Title string
|
||||
IconColor int32
|
||||
IconEmojiID int64
|
||||
TitleMissing bool
|
||||
Closed bool
|
||||
Hidden bool
|
||||
Pinned bool
|
||||
PinnedOrder int32
|
||||
Date int32
|
||||
TopMessageID int32
|
||||
ReadInboxMaxID int32
|
||||
ReadOutboxMaxID int32
|
||||
UnreadCount int32
|
||||
UnreadMentionsCount int32
|
||||
UnreadReactionsCount int32
|
||||
UnreadPollVotesCount int32
|
||||
Deleted bool
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type ChannelInvite struct {
|
||||
ChannelID int64
|
||||
InviteID int64
|
||||
Hash string
|
||||
AdminUserID int64
|
||||
Title string
|
||||
Permanent bool
|
||||
Revoked bool
|
||||
RequestNeeded bool
|
||||
ExpireDate *int32
|
||||
UsageLimit *int32
|
||||
UsageCount int32
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
RequestedCount int32
|
||||
}
|
||||
|
||||
type ChannelInviteHash struct {
|
||||
Hash string
|
||||
ChannelID int64
|
||||
InviteID int64
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type ChannelInviteImporter struct {
|
||||
ChannelID int64
|
||||
InviteID int64
|
||||
UserID int64
|
||||
Date int32
|
||||
Requested bool
|
||||
ApprovedBy int64
|
||||
ViaChatlist bool
|
||||
About string
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type ChannelMember struct {
|
||||
ChannelID int64
|
||||
UserID int64
|
||||
InviterUserID int64
|
||||
Role string
|
||||
Status string
|
||||
JoinedAt int32
|
||||
LeftAt int32
|
||||
AdminRights []byte
|
||||
BannedRights []byte
|
||||
Rank string
|
||||
AvailableMinID int32
|
||||
AvailableMinPts int32
|
||||
ReadInboxMaxID int32
|
||||
ReadInboxDate int32
|
||||
ReadOutboxMaxID int32
|
||||
UnreadMark bool
|
||||
SlowmodeLastSendDate int32
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type ChannelMessage struct {
|
||||
ChannelID int64
|
||||
ID int32
|
||||
RandomID int64
|
||||
SenderUserID int64
|
||||
FromPeerType string
|
||||
FromPeerID int64
|
||||
SendAsPeerType *string
|
||||
SendAsPeerID *int64
|
||||
MessageDate int32
|
||||
EditDate int32
|
||||
Post bool
|
||||
Silent bool
|
||||
Noforwards bool
|
||||
Body string
|
||||
Entities []byte
|
||||
ReplyTo []byte
|
||||
ReplyToMsgID int32
|
||||
ReplyToPeerType string
|
||||
ReplyToPeerID int64
|
||||
ReplyToTopID int32
|
||||
FwdFrom []byte
|
||||
DiscussionChannelID int64
|
||||
DiscussionMessageID int32
|
||||
Action []byte
|
||||
Pts int32
|
||||
Deleted bool
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
ViewsCount int32
|
||||
Media []byte
|
||||
}
|
||||
|
||||
type ChannelMessageReaction struct {
|
||||
ChannelID int64
|
||||
MessageID int32
|
||||
ReactedUserID int64
|
||||
SenderUserID int64
|
||||
ReactionType string
|
||||
ReactionValue string
|
||||
Big bool
|
||||
Unread bool
|
||||
ChosenOrder int32
|
||||
ReactionDate int32
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type ChannelMessageViewer struct {
|
||||
ChannelID int64
|
||||
MessageID int32
|
||||
ViewerUserID int64
|
||||
ViewedAt int32
|
||||
CreatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type ChannelUnreadMention struct {
|
||||
UserID int64
|
||||
ChannelID int64
|
||||
MessageID int32
|
||||
TopMessageID int32
|
||||
CreatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type ChannelUpdateEvent struct {
|
||||
ChannelID int64
|
||||
Pts int32
|
||||
PtsCount int32
|
||||
Date int32
|
||||
EventType string
|
||||
MessageID int32
|
||||
MessageIds []byte
|
||||
SenderUserID int64
|
||||
UserIds []byte
|
||||
Payload []byte
|
||||
CreatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type ChannelUsername struct {
|
||||
UsernameLower string
|
||||
ChannelID int64
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type Contact struct {
|
||||
UserID int64
|
||||
ContactUserID int64
|
||||
Mutual bool
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
ContactPhone string
|
||||
ContactFirstName string
|
||||
ContactLastName string
|
||||
Note string
|
||||
NoteEntities []byte
|
||||
CloseFriend bool
|
||||
StoriesHidden bool
|
||||
}
|
||||
|
||||
type Country struct {
|
||||
Iso2 string
|
||||
DefaultName string
|
||||
Name string
|
||||
Hidden bool
|
||||
OrderIndex int32
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type CountryCode struct {
|
||||
ID int64
|
||||
Iso2 string
|
||||
CountryCode string
|
||||
Prefixes []string
|
||||
Patterns []string
|
||||
OrderIndex int32
|
||||
}
|
||||
|
||||
type Dialog struct {
|
||||
UserID int64
|
||||
PeerType string
|
||||
PeerID int64
|
||||
TopMessageID int32
|
||||
TopMessageDate int32
|
||||
ReadInboxMaxID int32
|
||||
ReadOutboxMaxID int32
|
||||
UnreadCount int32
|
||||
UnreadMentionsCount int32
|
||||
UnreadReactionsCount int32
|
||||
Pinned bool
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
PinnedOrder int32
|
||||
UnreadMark bool
|
||||
HiddenPeerSettingsBar bool
|
||||
FolderID int32
|
||||
}
|
||||
|
||||
type DialogDraft struct {
|
||||
UserID int64
|
||||
PeerType string
|
||||
PeerID int64
|
||||
TopMessageID int32
|
||||
Date int32
|
||||
Draft []byte
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type DialogFilter struct {
|
||||
UserID int64
|
||||
FilterID int32
|
||||
IsChatlist bool
|
||||
Filter []byte
|
||||
OrderValue int32
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type DialogFilterSetting struct {
|
||||
UserID int64
|
||||
TagsEnabled bool
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type DispatchOutbox struct {
|
||||
ID int64
|
||||
TargetUserID int64
|
||||
Pts int32
|
||||
EventType string
|
||||
ExcludeSessionID int64
|
||||
Status string
|
||||
Attempts int32
|
||||
NextAttemptAt pgtype.Timestamptz
|
||||
LastError string
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
ExcludeAuthKeyID int64
|
||||
}
|
||||
|
||||
type Document struct {
|
||||
ID int64
|
||||
AccessHash int64
|
||||
FileReference []byte
|
||||
Date int32
|
||||
MimeType string
|
||||
Size int64
|
||||
DcID int32
|
||||
Attributes []byte
|
||||
Thumbs []byte
|
||||
CreatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type FileBlob struct {
|
||||
LocationKey string
|
||||
Backend string
|
||||
ObjectKey string
|
||||
Size int64
|
||||
Sha256 []byte
|
||||
MimeType string
|
||||
CreatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type LangPack struct {
|
||||
LangPack string
|
||||
LangCode string
|
||||
Version int32
|
||||
StringsCount int32
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type LangPackString struct {
|
||||
LangPack string
|
||||
LangCode string
|
||||
Key string
|
||||
Version int32
|
||||
Pluralized bool
|
||||
Value string
|
||||
ZeroValue string
|
||||
OneValue string
|
||||
TwoValue string
|
||||
FewValue string
|
||||
ManyValue string
|
||||
OtherValue string
|
||||
Deleted bool
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type MessageBox struct {
|
||||
OwnerUserID int64
|
||||
BoxID int32
|
||||
PrivateMessageID int64
|
||||
MessageSenderID int64
|
||||
PeerType string
|
||||
PeerID int64
|
||||
FromUserID int64
|
||||
MessageDate int32
|
||||
Outgoing bool
|
||||
Body string
|
||||
Entities []byte
|
||||
Pts int32
|
||||
Deleted bool
|
||||
CreatedAt pgtype.Timestamptz
|
||||
EditDate int32
|
||||
Silent bool
|
||||
Noforwards bool
|
||||
ReplyToMsgID int32
|
||||
ReplyToPeerType string
|
||||
ReplyToPeerID int64
|
||||
ReplyToTopID int32
|
||||
QuoteText string
|
||||
QuoteEntities []byte
|
||||
QuoteOffset int32
|
||||
FwdFromPeerType string
|
||||
FwdFromPeerID int64
|
||||
FwdFromName string
|
||||
FwdDate int32
|
||||
Media []byte
|
||||
}
|
||||
|
||||
type Photo struct {
|
||||
ID int64
|
||||
AccessHash int64
|
||||
FileReference []byte
|
||||
Date int32
|
||||
DcID int32
|
||||
HasStickers bool
|
||||
Sizes []byte
|
||||
CreatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type PrivateMessage struct {
|
||||
ID int64
|
||||
SenderUserID int64
|
||||
RecipientUserID int64
|
||||
RandomID int64
|
||||
MessageDate int32
|
||||
Body string
|
||||
Entities []byte
|
||||
CreatedAt pgtype.Timestamptz
|
||||
EditDate int32
|
||||
Silent bool
|
||||
Noforwards bool
|
||||
ReplyToMsgID int32
|
||||
ReplyToPeerType string
|
||||
ReplyToPeerID int64
|
||||
ReplyToTopID int32
|
||||
QuoteText string
|
||||
QuoteEntities []byte
|
||||
QuoteOffset int32
|
||||
FwdFromPeerType string
|
||||
FwdFromPeerID int64
|
||||
FwdFromName string
|
||||
FwdDate int32
|
||||
Media []byte
|
||||
}
|
||||
|
||||
type ProfilePhoto struct {
|
||||
OwnerPeerType string
|
||||
OwnerPeerID int64
|
||||
PhotoID int64
|
||||
Date int32
|
||||
Active bool
|
||||
SortOrder int64
|
||||
CreatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type StickerSet struct {
|
||||
ID int64
|
||||
AccessHash int64
|
||||
ShortName string
|
||||
Title string
|
||||
Count int32
|
||||
Hash int32
|
||||
SetKind string
|
||||
Official bool
|
||||
Animated bool
|
||||
Videos bool
|
||||
Emojis bool
|
||||
Masks bool
|
||||
Installed bool
|
||||
Archived bool
|
||||
InstalledDate int32
|
||||
ThumbDocumentID int64
|
||||
Thumbs []byte
|
||||
ThumbDcID int32
|
||||
ThumbVersion int32
|
||||
DocumentIds []byte
|
||||
Packs []byte
|
||||
SortOrder int32
|
||||
SystemKey string
|
||||
CreatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type TempAuthKeyBinding struct {
|
||||
TempAuthKeyID int64
|
||||
PermAuthKeyID int64
|
||||
Nonce int64
|
||||
ExpiresAt int32
|
||||
EncryptedMessage []byte
|
||||
CreatedAt pgtype.Timestamptz
|
||||
TempSessionID int64
|
||||
}
|
||||
|
||||
type UpdateState struct {
|
||||
AuthKeyID int64
|
||||
Pts int32
|
||||
Qts int32
|
||||
Date int32
|
||||
Seq int32
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
UserID int64
|
||||
}
|
||||
|
||||
type UploadPart struct {
|
||||
OwnerUserID int64
|
||||
FileID int64
|
||||
Part int32
|
||||
TotalParts int32
|
||||
IsBig bool
|
||||
Bytes []byte
|
||||
CreatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type User struct {
|
||||
ID int64
|
||||
AccessHash int64
|
||||
Phone string
|
||||
FirstName string
|
||||
LastName string
|
||||
Username string
|
||||
CountryCode string
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
Verified bool
|
||||
Support bool
|
||||
About string
|
||||
LastSeenAt int64
|
||||
}
|
||||
|
||||
type UserRecentReaction struct {
|
||||
UserID int64
|
||||
ReactionType string
|
||||
ReactionValue string
|
||||
ReactionDate int32
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type UserSavedReactionTag struct {
|
||||
UserID int64
|
||||
ReactionType string
|
||||
ReactionValue string
|
||||
Title string
|
||||
ReactionCount int32
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type UserTopReaction struct {
|
||||
UserID int64
|
||||
ReactionType string
|
||||
ReactionValue string
|
||||
ReactionCount int32
|
||||
ReactionDate int32
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type UserUpdateEvent struct {
|
||||
UserID int64
|
||||
Pts int32
|
||||
PtsCount int32
|
||||
Date int32
|
||||
EventType string
|
||||
MessageBoxID *int32
|
||||
PeerType *string
|
||||
PeerID *int64
|
||||
MaxID int32
|
||||
StillUnreadCount int32
|
||||
CreatedAt pgtype.Timestamptz
|
||||
EventBool bool
|
||||
EventPeers []byte
|
||||
PeerSettings []byte
|
||||
MessageIds []byte
|
||||
DialogFilter []byte
|
||||
FilterOrder []byte
|
||||
FolderPeers []byte
|
||||
FilterID int32
|
||||
TagsEnabled bool
|
||||
}
|
||||
|
||||
type UserUpdateWatermark struct {
|
||||
UserID int64
|
||||
ContiguousPts int32
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
80
internal/store/postgres/sqlcgen/temp_auth_key.sql.go
Normal file
80
internal/store/postgres/sqlcgen/temp_auth_key.sql.go
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: temp_auth_key.sql
|
||||
|
||||
package sqlcgen
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
const getTempAuthKeyBinding = `-- name: GetTempAuthKeyBinding :one
|
||||
SELECT
|
||||
temp_auth_key_id,
|
||||
perm_auth_key_id,
|
||||
nonce,
|
||||
temp_session_id,
|
||||
expires_at,
|
||||
encrypted_message
|
||||
FROM temp_auth_key_bindings
|
||||
WHERE temp_auth_key_id = $1
|
||||
`
|
||||
|
||||
type GetTempAuthKeyBindingRow struct {
|
||||
TempAuthKeyID int64
|
||||
PermAuthKeyID int64
|
||||
Nonce int64
|
||||
TempSessionID int64
|
||||
ExpiresAt int32
|
||||
EncryptedMessage []byte
|
||||
}
|
||||
|
||||
func (q *Queries) GetTempAuthKeyBinding(ctx context.Context, tempAuthKeyID int64) (GetTempAuthKeyBindingRow, error) {
|
||||
row := q.db.QueryRow(ctx, getTempAuthKeyBinding, tempAuthKeyID)
|
||||
var i GetTempAuthKeyBindingRow
|
||||
err := row.Scan(
|
||||
&i.TempAuthKeyID,
|
||||
&i.PermAuthKeyID,
|
||||
&i.Nonce,
|
||||
&i.TempSessionID,
|
||||
&i.ExpiresAt,
|
||||
&i.EncryptedMessage,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const upsertTempAuthKeyBinding = `-- name: UpsertTempAuthKeyBinding :exec
|
||||
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)
|
||||
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()
|
||||
`
|
||||
|
||||
type UpsertTempAuthKeyBindingParams struct {
|
||||
TempAuthKeyID int64
|
||||
PermAuthKeyID int64
|
||||
Nonce int64
|
||||
TempSessionID int64
|
||||
ExpiresAt int32
|
||||
EncryptedMessage []byte
|
||||
}
|
||||
|
||||
func (q *Queries) UpsertTempAuthKeyBinding(ctx context.Context, arg UpsertTempAuthKeyBindingParams) error {
|
||||
_, err := q.db.Exec(ctx, upsertTempAuthKeyBinding,
|
||||
arg.TempAuthKeyID,
|
||||
arg.PermAuthKeyID,
|
||||
arg.Nonce,
|
||||
arg.TempSessionID,
|
||||
arg.ExpiresAt,
|
||||
arg.EncryptedMessage,
|
||||
)
|
||||
return err
|
||||
}
|
||||
103
internal/store/postgres/sqlcgen/update_state.sql.go
Normal file
103
internal/store/postgres/sqlcgen/update_state.sql.go
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: update_state.sql
|
||||
|
||||
package sqlcgen
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
const deleteUpdateState = `-- name: DeleteUpdateState :exec
|
||||
DELETE FROM update_states
|
||||
WHERE auth_key_id = $1
|
||||
AND user_id = $2
|
||||
`
|
||||
|
||||
type DeleteUpdateStateParams struct {
|
||||
AuthKeyID int64
|
||||
UserID int64
|
||||
}
|
||||
|
||||
func (q *Queries) DeleteUpdateState(ctx context.Context, arg DeleteUpdateStateParams) error {
|
||||
_, err := q.db.Exec(ctx, deleteUpdateState, arg.AuthKeyID, arg.UserID)
|
||||
return err
|
||||
}
|
||||
|
||||
const deleteUpdateStatesByAuthKey = `-- name: DeleteUpdateStatesByAuthKey :exec
|
||||
DELETE FROM update_states
|
||||
WHERE auth_key_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteUpdateStatesByAuthKey(ctx context.Context, authKeyID int64) error {
|
||||
_, err := q.db.Exec(ctx, deleteUpdateStatesByAuthKey, authKeyID)
|
||||
return err
|
||||
}
|
||||
|
||||
const getUpdateState = `-- name: GetUpdateState :one
|
||||
SELECT auth_key_id, user_id, pts, qts, date, seq
|
||||
FROM update_states
|
||||
WHERE auth_key_id = $1
|
||||
AND user_id = $2
|
||||
`
|
||||
|
||||
type GetUpdateStateParams struct {
|
||||
AuthKeyID int64
|
||||
UserID int64
|
||||
}
|
||||
|
||||
type GetUpdateStateRow struct {
|
||||
AuthKeyID int64
|
||||
UserID int64
|
||||
Pts int32
|
||||
Qts int32
|
||||
Date int32
|
||||
Seq int32
|
||||
}
|
||||
|
||||
func (q *Queries) GetUpdateState(ctx context.Context, arg GetUpdateStateParams) (GetUpdateStateRow, error) {
|
||||
row := q.db.QueryRow(ctx, getUpdateState, arg.AuthKeyID, arg.UserID)
|
||||
var i GetUpdateStateRow
|
||||
err := row.Scan(
|
||||
&i.AuthKeyID,
|
||||
&i.UserID,
|
||||
&i.Pts,
|
||||
&i.Qts,
|
||||
&i.Date,
|
||||
&i.Seq,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const upsertUpdateState = `-- name: UpsertUpdateState :exec
|
||||
INSERT INTO update_states (auth_key_id, user_id, pts, qts, date, seq)
|
||||
VALUES ($1, $2, $3, $4, $5, $6)
|
||||
ON CONFLICT (auth_key_id, user_id) DO UPDATE SET
|
||||
pts = EXCLUDED.pts,
|
||||
qts = EXCLUDED.qts,
|
||||
date = EXCLUDED.date,
|
||||
seq = EXCLUDED.seq,
|
||||
updated_at = now()
|
||||
`
|
||||
|
||||
type UpsertUpdateStateParams struct {
|
||||
AuthKeyID int64
|
||||
UserID int64
|
||||
Pts int32
|
||||
Qts int32
|
||||
Date int32
|
||||
Seq int32
|
||||
}
|
||||
|
||||
func (q *Queries) UpsertUpdateState(ctx context.Context, arg UpsertUpdateStateParams) error {
|
||||
_, err := q.db.Exec(ctx, upsertUpdateState,
|
||||
arg.AuthKeyID,
|
||||
arg.UserID,
|
||||
arg.Pts,
|
||||
arg.Qts,
|
||||
arg.Date,
|
||||
arg.Seq,
|
||||
)
|
||||
return err
|
||||
}
|
||||
426
internal/store/postgres/sqlcgen/user.sql.go
Normal file
426
internal/store/postgres/sqlcgen/user.sql.go
Normal file
|
|
@ -0,0 +1,426 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: user.sql
|
||||
|
||||
package sqlcgen
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
const createUser = `-- name: CreateUser :one
|
||||
INSERT INTO users (access_hash, phone, first_name, last_name, username, country_code)
|
||||
VALUES ($1, $2, $3, $4, $5, $6)
|
||||
RETURNING id, access_hash, phone, first_name, last_name, username, country_code, created_at, updated_at, verified, support, about, last_seen_at
|
||||
`
|
||||
|
||||
type CreateUserParams struct {
|
||||
AccessHash int64
|
||||
Phone string
|
||||
FirstName string
|
||||
LastName string
|
||||
Username string
|
||||
CountryCode string
|
||||
}
|
||||
|
||||
func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error) {
|
||||
row := q.db.QueryRow(ctx, createUser,
|
||||
arg.AccessHash,
|
||||
arg.Phone,
|
||||
arg.FirstName,
|
||||
arg.LastName,
|
||||
arg.Username,
|
||||
arg.CountryCode,
|
||||
)
|
||||
var i User
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.AccessHash,
|
||||
&i.Phone,
|
||||
&i.FirstName,
|
||||
&i.LastName,
|
||||
&i.Username,
|
||||
&i.CountryCode,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.Verified,
|
||||
&i.Support,
|
||||
&i.About,
|
||||
&i.LastSeenAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getUserByID = `-- name: GetUserByID :one
|
||||
SELECT id, access_hash, phone, first_name, last_name, username, country_code, created_at, updated_at, verified, support, about, last_seen_at FROM users WHERE id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetUserByID(ctx context.Context, id int64) (User, error) {
|
||||
row := q.db.QueryRow(ctx, getUserByID, id)
|
||||
var i User
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.AccessHash,
|
||||
&i.Phone,
|
||||
&i.FirstName,
|
||||
&i.LastName,
|
||||
&i.Username,
|
||||
&i.CountryCode,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.Verified,
|
||||
&i.Support,
|
||||
&i.About,
|
||||
&i.LastSeenAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getUserByPhone = `-- name: GetUserByPhone :one
|
||||
SELECT id, access_hash, phone, first_name, last_name, username, country_code, created_at, updated_at, verified, support, about, last_seen_at FROM users WHERE phone = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetUserByPhone(ctx context.Context, phone string) (User, error) {
|
||||
row := q.db.QueryRow(ctx, getUserByPhone, phone)
|
||||
var i User
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.AccessHash,
|
||||
&i.Phone,
|
||||
&i.FirstName,
|
||||
&i.LastName,
|
||||
&i.Username,
|
||||
&i.CountryCode,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.Verified,
|
||||
&i.Support,
|
||||
&i.About,
|
||||
&i.LastSeenAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getUserByUsername = `-- name: GetUserByUsername :one
|
||||
SELECT id, access_hash, phone, first_name, last_name, username, country_code, created_at, updated_at, verified, support, about, last_seen_at FROM users WHERE lower(username) = lower($1) AND username <> ''
|
||||
`
|
||||
|
||||
func (q *Queries) GetUserByUsername(ctx context.Context, lower string) (User, error) {
|
||||
row := q.db.QueryRow(ctx, getUserByUsername, lower)
|
||||
var i User
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.AccessHash,
|
||||
&i.Phone,
|
||||
&i.FirstName,
|
||||
&i.LastName,
|
||||
&i.Username,
|
||||
&i.CountryCode,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.Verified,
|
||||
&i.Support,
|
||||
&i.About,
|
||||
&i.LastSeenAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getUsersByIDs = `-- name: GetUsersByIDs :many
|
||||
SELECT id, access_hash, phone, first_name, last_name, username, country_code, created_at, updated_at, verified, support, about, last_seen_at
|
||||
FROM users
|
||||
WHERE id = ANY($1::bigint[])
|
||||
ORDER BY id
|
||||
`
|
||||
|
||||
func (q *Queries) GetUsersByIDs(ctx context.Context, ids []int64) ([]User, error) {
|
||||
rows, err := q.db.Query(ctx, getUsersByIDs, ids)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []User
|
||||
for rows.Next() {
|
||||
var i User
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.AccessHash,
|
||||
&i.Phone,
|
||||
&i.FirstName,
|
||||
&i.LastName,
|
||||
&i.Username,
|
||||
&i.CountryCode,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.Verified,
|
||||
&i.Support,
|
||||
&i.About,
|
||||
&i.LastSeenAt,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getUsersByPhones = `-- name: GetUsersByPhones :many
|
||||
SELECT id, access_hash, phone, first_name, last_name, username, country_code, created_at, updated_at, verified, support, about, last_seen_at
|
||||
FROM users
|
||||
WHERE phone = ANY($1::text[])
|
||||
ORDER BY id
|
||||
`
|
||||
|
||||
func (q *Queries) GetUsersByPhones(ctx context.Context, phones []string) ([]User, error) {
|
||||
rows, err := q.db.Query(ctx, getUsersByPhones, phones)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []User
|
||||
for rows.Next() {
|
||||
var i User
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.AccessHash,
|
||||
&i.Phone,
|
||||
&i.FirstName,
|
||||
&i.LastName,
|
||||
&i.Username,
|
||||
&i.CountryCode,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.Verified,
|
||||
&i.Support,
|
||||
&i.About,
|
||||
&i.LastSeenAt,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const searchUsers = `-- name: SearchUsers :many
|
||||
WITH matched AS (
|
||||
SELECT
|
||||
u.id,
|
||||
u.access_hash,
|
||||
COALESCE(NULLIF(c.contact_phone, ''), u.phone)::text AS phone,
|
||||
COALESCE(NULLIF(c.contact_first_name, ''), u.first_name)::text AS first_name,
|
||||
COALESCE(c.contact_last_name, u.last_name)::text AS last_name,
|
||||
u.about,
|
||||
u.username,
|
||||
u.country_code,
|
||||
u.verified,
|
||||
u.support,
|
||||
u.last_seen_at,
|
||||
(c.contact_user_id IS NOT NULL)::boolean AS contact,
|
||||
COALESCE(c.mutual, false)::boolean AS mutual,
|
||||
CASE
|
||||
WHEN $2::text <> '' AND u.phone = $2::text THEN 0
|
||||
WHEN lower(u.username) = $3::text THEN 1
|
||||
WHEN lower(COALESCE(NULLIF(c.contact_first_name, ''), u.first_name)) = $3::text THEN 2
|
||||
WHEN lower(u.first_name) = $3::text THEN 3
|
||||
WHEN c.contact_user_id IS NOT NULL THEN 4
|
||||
ELSE 5
|
||||
END AS rank
|
||||
FROM users u
|
||||
LEFT JOIN contacts c ON c.user_id = $4::bigint AND c.contact_user_id = u.id
|
||||
WHERE u.id <> $4::bigint
|
||||
AND $3::text <> ''
|
||||
AND (
|
||||
($2::text <> '' AND u.phone LIKE $2::text || '%')
|
||||
OR lower(u.username) LIKE $5::text || '%' ESCAPE '\'
|
||||
OR lower(u.first_name) LIKE '%' || $5::text || '%' ESCAPE '\'
|
||||
OR lower(u.last_name) LIKE '%' || $5::text || '%' ESCAPE '\'
|
||||
OR lower(trim(u.first_name || ' ' || u.last_name)) LIKE '%' || $5::text || '%' ESCAPE '\'
|
||||
OR lower(c.contact_first_name) LIKE '%' || $5::text || '%' ESCAPE '\'
|
||||
OR lower(c.contact_last_name) LIKE '%' || $5::text || '%' ESCAPE '\'
|
||||
OR lower(trim(c.contact_first_name || ' ' || c.contact_last_name)) LIKE '%' || $5::text || '%' ESCAPE '\'
|
||||
)
|
||||
)
|
||||
SELECT
|
||||
id,
|
||||
access_hash,
|
||||
phone,
|
||||
first_name,
|
||||
last_name,
|
||||
about,
|
||||
username,
|
||||
country_code,
|
||||
verified,
|
||||
support,
|
||||
last_seen_at,
|
||||
contact,
|
||||
mutual
|
||||
FROM matched
|
||||
ORDER BY contact DESC, rank, id
|
||||
LIMIT $1
|
||||
`
|
||||
|
||||
type SearchUsersParams struct {
|
||||
LimitCount int32
|
||||
PhoneQuery string
|
||||
QueryLower string
|
||||
CurrentUserID int64
|
||||
QueryLike string
|
||||
}
|
||||
|
||||
type SearchUsersRow struct {
|
||||
ID int64
|
||||
AccessHash int64
|
||||
Phone string
|
||||
FirstName string
|
||||
LastName string
|
||||
About string
|
||||
Username string
|
||||
CountryCode string
|
||||
Verified bool
|
||||
Support bool
|
||||
LastSeenAt int64
|
||||
Contact bool
|
||||
Mutual bool
|
||||
}
|
||||
|
||||
func (q *Queries) SearchUsers(ctx context.Context, arg SearchUsersParams) ([]SearchUsersRow, error) {
|
||||
rows, err := q.db.Query(ctx, searchUsers,
|
||||
arg.LimitCount,
|
||||
arg.PhoneQuery,
|
||||
arg.QueryLower,
|
||||
arg.CurrentUserID,
|
||||
arg.QueryLike,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []SearchUsersRow
|
||||
for rows.Next() {
|
||||
var i SearchUsersRow
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.AccessHash,
|
||||
&i.Phone,
|
||||
&i.FirstName,
|
||||
&i.LastName,
|
||||
&i.About,
|
||||
&i.Username,
|
||||
&i.CountryCode,
|
||||
&i.Verified,
|
||||
&i.Support,
|
||||
&i.LastSeenAt,
|
||||
&i.Contact,
|
||||
&i.Mutual,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const updateUserLastSeen = `-- name: UpdateUserLastSeen :exec
|
||||
UPDATE users
|
||||
SET last_seen_at = GREATEST(last_seen_at, $1::bigint),
|
||||
updated_at = now()
|
||||
WHERE id = $2::bigint
|
||||
`
|
||||
|
||||
type UpdateUserLastSeenParams struct {
|
||||
LastSeenAt int64
|
||||
ID int64
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateUserLastSeen(ctx context.Context, arg UpdateUserLastSeenParams) error {
|
||||
_, err := q.db.Exec(ctx, updateUserLastSeen, arg.LastSeenAt, arg.ID)
|
||||
return err
|
||||
}
|
||||
|
||||
const updateUserProfile = `-- name: UpdateUserProfile :one
|
||||
UPDATE users
|
||||
SET first_name = $2,
|
||||
last_name = $3,
|
||||
about = $4,
|
||||
updated_at = now()
|
||||
WHERE id = $1
|
||||
RETURNING id, access_hash, phone, first_name, last_name, username, country_code, created_at, updated_at, verified, support, about, last_seen_at
|
||||
`
|
||||
|
||||
type UpdateUserProfileParams struct {
|
||||
ID int64
|
||||
FirstName string
|
||||
LastName string
|
||||
About string
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateUserProfile(ctx context.Context, arg UpdateUserProfileParams) (User, error) {
|
||||
row := q.db.QueryRow(ctx, updateUserProfile,
|
||||
arg.ID,
|
||||
arg.FirstName,
|
||||
arg.LastName,
|
||||
arg.About,
|
||||
)
|
||||
var i User
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.AccessHash,
|
||||
&i.Phone,
|
||||
&i.FirstName,
|
||||
&i.LastName,
|
||||
&i.Username,
|
||||
&i.CountryCode,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.Verified,
|
||||
&i.Support,
|
||||
&i.About,
|
||||
&i.LastSeenAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateUserUsername = `-- name: UpdateUserUsername :one
|
||||
UPDATE users
|
||||
SET username = $2,
|
||||
updated_at = now()
|
||||
WHERE id = $1
|
||||
RETURNING id, access_hash, phone, first_name, last_name, username, country_code, created_at, updated_at, verified, support, about, last_seen_at
|
||||
`
|
||||
|
||||
type UpdateUserUsernameParams struct {
|
||||
ID int64
|
||||
Username string
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateUserUsername(ctx context.Context, arg UpdateUserUsernameParams) (User, error) {
|
||||
row := q.db.QueryRow(ctx, updateUserUsername, arg.ID, arg.Username)
|
||||
var i User
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.AccessHash,
|
||||
&i.Phone,
|
||||
&i.FirstName,
|
||||
&i.LastName,
|
||||
&i.Username,
|
||||
&i.CountryCode,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.Verified,
|
||||
&i.Support,
|
||||
&i.About,
|
||||
&i.LastSeenAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
1307
internal/store/postgres/sqlcgen/user_update_event.sql.go
Normal file
1307
internal/store/postgres/sqlcgen/user_update_event.sql.go
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue