Handle Google token failures and report Google Calendar status (Feature 16) (#128)
CI / ci (push) Successful in 4m27s
CI / ci (push) Successful in 4m27s
Co-authored-by: orchestrator-agent <20+orchestrator-agent@code.cubecraftcreations.com>
This commit was merged in pull request #128.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
-- 0015_google_reconnect_required: when Google refuses the stored grant
|
||||
-- (invalid_grant on refresh, or HTTP 401 from the Calendar API) the
|
||||
-- connection is kept as reconnect required: its refresh token is cleared
|
||||
-- and last_sync_error says why. SQLite cannot drop a NOT NULL constraint,
|
||||
-- so the table is rebuilt with refresh_token_ct nullable. A row without a
|
||||
-- refresh token always carries the reason. No table references
|
||||
-- integrations_google.
|
||||
|
||||
CREATE TABLE integrations_google_new (
|
||||
id INTEGER PRIMARY KEY CHECK (id = 1),
|
||||
refresh_token_ct BLOB,
|
||||
calendar_id TEXT,
|
||||
calendar_name TEXT,
|
||||
connected_at TEXT NOT NULL,
|
||||
last_sync_error TEXT,
|
||||
created_at TEXT NOT NULL,
|
||||
updated_at TEXT NOT NULL,
|
||||
CHECK (refresh_token_ct IS NOT NULL OR last_sync_error IS NOT NULL)
|
||||
);
|
||||
|
||||
INSERT INTO integrations_google_new (
|
||||
id, refresh_token_ct, calendar_id, calendar_name, connected_at,
|
||||
last_sync_error, created_at, updated_at
|
||||
)
|
||||
SELECT id, refresh_token_ct, calendar_id, calendar_name, connected_at,
|
||||
last_sync_error, created_at, updated_at
|
||||
FROM integrations_google;
|
||||
|
||||
DROP TABLE integrations_google;
|
||||
|
||||
ALTER TABLE integrations_google_new RENAME TO integrations_google;
|
||||
@@ -112,6 +112,14 @@ UPDATE integrations_google
|
||||
SET calendar_id = ?, calendar_name = ?, updated_at = ?
|
||||
WHERE id = 1;
|
||||
|
||||
-- name: ClearIntegrationsGoogleToken :execrows
|
||||
-- Records that Google refuses the stored grant: clears the refresh token and
|
||||
-- sets last_sync_error, keeping the chosen calendar. Affects no row when
|
||||
-- nothing is connected.
|
||||
UPDATE integrations_google
|
||||
SET refresh_token_ct = NULL, last_sync_error = ?, updated_at = ?
|
||||
WHERE id = 1;
|
||||
|
||||
-- name: DeleteIntegrationsGoogle :exec
|
||||
DELETE FROM integrations_google
|
||||
WHERE id = 1;
|
||||
|
||||
Reference in New Issue
Block a user