feat(desktop): drop parked review flow, add publish management
SaaS 侧人工审核后才创建 publish job,desktop 不再做二次审核:移除 manual/waiting_user/parked/from_parked 状态机与 LeaseFromParked 查询, desktop client 只执行发布并新增"发布管理"页(待发布队列 / 历史 / 再次 发送)。同时抽离 @geo/publisher-platforms 共享适配器包、新增 Redis-based desktop_presence 与 publish_record_support,刷新 admin-web 发布弹窗与 媒体库;plan A / spec 文档同步口径。
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
-- name: ListDesktopAccountsByClient :many
|
||||
-- name: ListDesktopAccountsByUser :many
|
||||
SELECT
|
||||
desktop_id,
|
||||
tenant_id,
|
||||
@@ -9,6 +9,7 @@ SELECT
|
||||
platform_uid,
|
||||
account_fingerprint,
|
||||
display_name,
|
||||
avatar_url,
|
||||
health,
|
||||
verified_at,
|
||||
tags,
|
||||
@@ -19,7 +20,8 @@ SELECT
|
||||
updated_at
|
||||
FROM platform_accounts
|
||||
WHERE workspace_id = sqlc.arg(workspace_id)
|
||||
AND client_id = sqlc.arg(client_id)
|
||||
AND user_id = sqlc.arg(user_id)
|
||||
AND deleted_at IS NULL
|
||||
ORDER BY platform_id, display_name, created_at DESC;
|
||||
|
||||
-- name: GetDesktopAccountByDesktopID :one
|
||||
@@ -33,6 +35,7 @@ SELECT
|
||||
platform_uid,
|
||||
account_fingerprint,
|
||||
display_name,
|
||||
avatar_url,
|
||||
health,
|
||||
verified_at,
|
||||
tags,
|
||||
@@ -57,6 +60,7 @@ SELECT
|
||||
platform_uid,
|
||||
account_fingerprint,
|
||||
display_name,
|
||||
avatar_url,
|
||||
health,
|
||||
verified_at,
|
||||
tags,
|
||||
@@ -82,6 +86,7 @@ INSERT INTO platform_accounts (
|
||||
platform_id,
|
||||
platform_uid,
|
||||
nickname,
|
||||
avatar_url,
|
||||
status,
|
||||
metadata_json,
|
||||
last_check_at,
|
||||
@@ -101,6 +106,7 @@ VALUES (
|
||||
sqlc.arg(platform_id),
|
||||
sqlc.arg(platform_uid),
|
||||
sqlc.arg(display_name)::text,
|
||||
sqlc.narg(avatar_url),
|
||||
sqlc.arg(legacy_status),
|
||||
sqlc.narg(metadata_json),
|
||||
sqlc.narg(verified_at),
|
||||
@@ -116,6 +122,7 @@ DO UPDATE SET
|
||||
client_id = EXCLUDED.client_id,
|
||||
user_id = EXCLUDED.user_id,
|
||||
nickname = EXCLUDED.nickname,
|
||||
avatar_url = COALESCE(EXCLUDED.avatar_url, platform_accounts.avatar_url),
|
||||
status = EXCLUDED.status,
|
||||
metadata_json = COALESCE(EXCLUDED.metadata_json, platform_accounts.metadata_json),
|
||||
last_check_at = COALESCE(EXCLUDED.last_check_at, platform_accounts.last_check_at),
|
||||
@@ -142,6 +149,7 @@ RETURNING
|
||||
platform_uid,
|
||||
account_fingerprint,
|
||||
display_name,
|
||||
avatar_url,
|
||||
health,
|
||||
verified_at,
|
||||
tags,
|
||||
@@ -176,6 +184,7 @@ RETURNING
|
||||
platform_uid,
|
||||
account_fingerprint,
|
||||
display_name,
|
||||
avatar_url,
|
||||
health,
|
||||
verified_at,
|
||||
tags,
|
||||
@@ -204,6 +213,7 @@ RETURNING
|
||||
platform_uid,
|
||||
account_fingerprint,
|
||||
display_name,
|
||||
avatar_url,
|
||||
health,
|
||||
verified_at,
|
||||
tags,
|
||||
@@ -231,6 +241,7 @@ RETURNING
|
||||
platform_uid,
|
||||
account_fingerprint,
|
||||
display_name,
|
||||
avatar_url,
|
||||
health,
|
||||
verified_at,
|
||||
tags,
|
||||
@@ -258,6 +269,7 @@ RETURNING
|
||||
platform_uid,
|
||||
account_fingerprint,
|
||||
display_name,
|
||||
avatar_url,
|
||||
health,
|
||||
verified_at,
|
||||
tags,
|
||||
|
||||
@@ -23,6 +23,19 @@ VALUES (
|
||||
sqlc.narg(client_version),
|
||||
sqlc.narg(channel)
|
||||
)
|
||||
ON CONFLICT (id) DO UPDATE
|
||||
SET tenant_id = EXCLUDED.tenant_id,
|
||||
workspace_id = EXCLUDED.workspace_id,
|
||||
user_id = EXCLUDED.user_id,
|
||||
token_hash = EXCLUDED.token_hash,
|
||||
device_name = EXCLUDED.device_name,
|
||||
os = EXCLUDED.os,
|
||||
cpu_arch = EXCLUDED.cpu_arch,
|
||||
client_version = EXCLUDED.client_version,
|
||||
channel = EXCLUDED.channel,
|
||||
last_seen_at = now(),
|
||||
last_rotated_at = now(),
|
||||
revoked_at = NULL
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetDesktopClientByTokenHash :one
|
||||
@@ -32,6 +45,14 @@ WHERE token_hash = sqlc.arg(token_hash)
|
||||
AND revoked_at IS NULL
|
||||
LIMIT 1;
|
||||
|
||||
-- name: GetDesktopClientByID :one
|
||||
SELECT *
|
||||
FROM desktop_clients
|
||||
WHERE id = sqlc.arg(id)
|
||||
AND workspace_id = sqlc.arg(workspace_id)
|
||||
AND revoked_at IS NULL
|
||||
LIMIT 1;
|
||||
|
||||
-- name: RotateDesktopClientToken :one
|
||||
UPDATE desktop_clients
|
||||
SET token_hash = sqlc.arg(token_hash),
|
||||
|
||||
@@ -31,8 +31,7 @@ INSERT INTO desktop_tasks (
|
||||
kind,
|
||||
payload,
|
||||
status,
|
||||
dedup_key,
|
||||
parked_reason
|
||||
dedup_key
|
||||
)
|
||||
VALUES (
|
||||
sqlc.arg(desktop_id),
|
||||
@@ -45,8 +44,7 @@ VALUES (
|
||||
sqlc.arg(kind),
|
||||
sqlc.arg(payload),
|
||||
sqlc.arg(status),
|
||||
sqlc.narg(dedup_key),
|
||||
sqlc.narg(parked_reason)
|
||||
sqlc.narg(dedup_key)
|
||||
)
|
||||
RETURNING *;
|
||||
|
||||
@@ -77,7 +75,6 @@ SET active_attempt_id = sqlc.arg(attempt_id),
|
||||
lease_expires_at = now() + interval '10 minutes',
|
||||
status = 'in_progress',
|
||||
attempts = t.attempts + 1,
|
||||
parked_reason = NULL,
|
||||
updated_at = now()
|
||||
FROM candidate
|
||||
WHERE t.desktop_id = candidate.desktop_id
|
||||
@@ -90,28 +87,12 @@ SET active_attempt_id = sqlc.arg(attempt_id),
|
||||
lease_expires_at = now() + interval '10 minutes',
|
||||
status = 'in_progress',
|
||||
attempts = attempts + 1,
|
||||
parked_reason = NULL,
|
||||
updated_at = now()
|
||||
WHERE desktop_id = sqlc.arg(desktop_id)
|
||||
AND target_client_id = sqlc.arg(client_id)
|
||||
AND status = 'queued'
|
||||
RETURNING *;
|
||||
|
||||
-- name: LeaseParkedDesktopTask :one
|
||||
UPDATE desktop_tasks
|
||||
SET active_attempt_id = sqlc.arg(attempt_id),
|
||||
lease_token_hash = sqlc.arg(lease_token_hash),
|
||||
lease_expires_at = now() + interval '10 minutes',
|
||||
status = 'in_progress',
|
||||
attempts = attempts + 1,
|
||||
parked_reason = NULL,
|
||||
updated_at = now()
|
||||
WHERE desktop_id = sqlc.arg(desktop_id)
|
||||
AND target_client_id = sqlc.arg(client_id)
|
||||
AND status = 'waiting_user'
|
||||
AND active_attempt_id IS NULL
|
||||
RETURNING *;
|
||||
|
||||
-- name: ExtendDesktopTaskLease :one
|
||||
UPDATE desktop_tasks
|
||||
SET lease_expires_at = now() + interval '10 minutes',
|
||||
@@ -121,19 +102,6 @@ WHERE desktop_id = sqlc.arg(desktop_id)
|
||||
AND status = 'in_progress'
|
||||
RETURNING *;
|
||||
|
||||
-- name: ParkDesktopTask :one
|
||||
UPDATE desktop_tasks
|
||||
SET status = 'waiting_user',
|
||||
active_attempt_id = NULL,
|
||||
lease_token_hash = NULL,
|
||||
lease_expires_at = NULL,
|
||||
parked_reason = sqlc.arg(parked_reason),
|
||||
updated_at = now()
|
||||
WHERE desktop_id = sqlc.arg(desktop_id)
|
||||
AND lease_token_hash = sqlc.arg(lease_token_hash)
|
||||
AND status = 'in_progress'
|
||||
RETURNING *;
|
||||
|
||||
-- name: CompleteDesktopTask :one
|
||||
UPDATE desktop_tasks
|
||||
SET status = sqlc.arg(status),
|
||||
@@ -142,7 +110,6 @@ SET status = sqlc.arg(status),
|
||||
active_attempt_id = NULL,
|
||||
lease_token_hash = NULL,
|
||||
lease_expires_at = NULL,
|
||||
parked_reason = NULL,
|
||||
updated_at = now()
|
||||
WHERE desktop_id = sqlc.arg(desktop_id)
|
||||
AND lease_token_hash = sqlc.arg(lease_token_hash)
|
||||
@@ -156,7 +123,6 @@ SET status = 'aborted',
|
||||
active_attempt_id = NULL,
|
||||
lease_token_hash = NULL,
|
||||
lease_expires_at = NULL,
|
||||
parked_reason = NULL,
|
||||
updated_at = now()
|
||||
WHERE desktop_id = sqlc.arg(desktop_id)
|
||||
AND lease_token_hash = sqlc.arg(lease_token_hash)
|
||||
@@ -170,11 +136,10 @@ SET status = 'aborted',
|
||||
active_attempt_id = NULL,
|
||||
lease_token_hash = NULL,
|
||||
lease_expires_at = NULL,
|
||||
parked_reason = NULL,
|
||||
updated_at = now()
|
||||
WHERE desktop_id = sqlc.arg(desktop_id)
|
||||
AND target_client_id = sqlc.arg(client_id)
|
||||
AND status IN ('queued', 'waiting_user')
|
||||
AND status = 'queued'
|
||||
RETURNING *;
|
||||
|
||||
-- name: TenantCancelDesktopTask :one
|
||||
@@ -184,11 +149,10 @@ SET status = 'aborted',
|
||||
active_attempt_id = NULL,
|
||||
lease_token_hash = NULL,
|
||||
lease_expires_at = NULL,
|
||||
parked_reason = NULL,
|
||||
updated_at = now()
|
||||
WHERE desktop_id = sqlc.arg(desktop_id)
|
||||
AND workspace_id = sqlc.arg(workspace_id)
|
||||
AND status IN ('queued', 'waiting_user')
|
||||
AND status = 'queued'
|
||||
RETURNING *;
|
||||
|
||||
-- name: ReconcileDesktopTask :one
|
||||
@@ -205,7 +169,6 @@ SET status = CASE
|
||||
active_attempt_id = NULL,
|
||||
lease_token_hash = NULL,
|
||||
lease_expires_at = NULL,
|
||||
parked_reason = NULL,
|
||||
attempts = attempts + CASE WHEN sqlc.arg(status)::text = 'retry' THEN 1 ELSE 0 END,
|
||||
updated_at = now()
|
||||
WHERE desktop_id = sqlc.arg(desktop_id)
|
||||
@@ -220,11 +183,10 @@ SET status = 'unknown',
|
||||
active_attempt_id = NULL,
|
||||
lease_token_hash = NULL,
|
||||
lease_expires_at = NULL,
|
||||
parked_reason = NULL,
|
||||
updated_at = now()
|
||||
WHERE target_client_id = sqlc.arg(client_id)
|
||||
AND workspace_id = sqlc.arg(workspace_id)
|
||||
AND status IN ('waiting_user', 'in_progress');
|
||||
AND status = 'in_progress';
|
||||
|
||||
-- name: CreateDesktopTaskAttempt :one
|
||||
INSERT INTO desktop_task_attempts (
|
||||
|
||||
Reference in New Issue
Block a user