mirror of
https://github.com/domfelipe/mika-agent-assist.git
synced 2026-08-07 11:56:45 +00:00
Changes
Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com>
This commit is contained in:
parent
2c5ca61b19
commit
71d0c59d69
6 changed files with 466 additions and 0 deletions
|
|
@ -123,6 +123,18 @@ async function upsertSubscription(data: any, env: PaddleEnv) {
|
|||
|
||||
// Atualiza paddle_customer_id no profile
|
||||
await supabase.from('profiles').update({ paddle_customer_id: customerId }).eq('id', userId);
|
||||
|
||||
// Provisiona agent_instance se ainda não existir (idempotente via unique index em user_id).
|
||||
// TODO Fase 5: dispatch provisioning job (criar container Docker na VPS via Coolify API)
|
||||
if (status === 'active' || status === 'trialing') {
|
||||
const { error: agentErr } = await supabase
|
||||
.from('agent_instances')
|
||||
.insert({ user_id: userId, status: 'provisioning' });
|
||||
// 23505 = já existe (esperado para usuários retornando), ignora
|
||||
if (agentErr && agentErr.code !== '23505') {
|
||||
console.error('Failed to provision agent_instance:', agentErr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function markCanceled(data: any, env: PaddleEnv) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue