feat(go): referral support (#28345)

Co-authored-by: Jack <jack@anoma.ly>
This commit is contained in:
Victor Navarro
2026-05-19 17:51:39 +02:00
committed by GitHub
parent 512e34af83
commit b32f071502
54 changed files with 20809 additions and 206 deletions

View File

@@ -26,6 +26,7 @@ export const subjects = createSubjects({
account: z.object({
accountID: z.string(),
email: z.string(),
newAccount: z.boolean().optional(),
}),
user: z.object({
userID: z.string(),
@@ -142,6 +143,7 @@ export default {
}
// Get account
let newAccount = false
const accountID = await (async () => {
const matches = await Database.use(async (tx) =>
tx
@@ -166,6 +168,7 @@ export default {
if (!accountID) {
console.log("creating account for", email)
accountID = await Account.create({})
newAccount = true
}
await Database.use(async (tx) =>
@@ -215,7 +218,7 @@ export default {
await Workspace.create({ name: "Default" })
}
})
return ctx.subject("account", accountID, { accountID, email })
return ctx.subject("account", accountID, { accountID, email, newAccount })
},
}).fetch(request, env, ctx)
return result