feat: get impersonation token implementation

This commit is contained in:
nihonium 2025-12-06 04:03:04 +03:00
parent 066c44d08a
commit e67f0d7e5a
Signed by: nihonium
GPG key ID: 0251623741027CFC
7 changed files with 209 additions and 95 deletions

View file

@ -33,8 +33,6 @@ CREATE TABLE users (
last_login timestamptz
);
CREATE TABLE studios (
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
studio_name text NOT NULL UNIQUE,
@ -106,7 +104,8 @@ CREATE TABLE signals (
CREATE TABLE external_services (
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
name text UNIQUE NOT NULL
name text UNIQUE NOT NULL,
auth_token text
);
CREATE TABLE external_ids (

View file

@ -193,8 +193,9 @@ type ExternalID struct {
}
type ExternalService struct {
ID int64 `json:"id"`
Name string `json:"name"`
ID int64 `json:"id"`
Name string `json:"name"`
AuthToken *string `json:"auth_token"`
}
type Image struct {

View file

@ -74,6 +74,19 @@ func (q *Queries) DeleteUserTitle(ctx context.Context, arg DeleteUserTitleParams
return i, err
}
const getExternalServiceByToken = `-- name: GetExternalServiceByToken :one
SELECT id, name, auth_token
FROM external_services
WHERE auth_token = $1
`
func (q *Queries) GetExternalServiceByToken(ctx context.Context, authToken *string) (ExternalService, error) {
row := q.db.QueryRow(ctx, getExternalServiceByToken, authToken)
var i ExternalService
err := row.Scan(&i.ID, &i.Name, &i.AuthToken)
return i, err
}
const getImageByID = `-- name: GetImageByID :one
SELECT id, storage_type, image_path
FROM images