a tool for shared writing and social publishing
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

add to home if logged in

+17
+17
actions/createNewLeafletFromTemplate.ts
··· 18 18 } from "drizzle/schema"; 19 19 import { sql } from "drizzle-orm"; 20 20 import { redirect } from "next/navigation"; 21 + import { cookies } from "next/headers"; 21 22 22 23 let supabase = createServerClient<Database>( 23 24 process.env.NEXT_PUBLIC_SUPABASE_API_URL as string, ··· 29 30 template_id: string, 30 31 redirectUser?: boolean, 31 32 ) { 33 + let auth_token = cookies().get("auth_token")?.value; 32 34 let res = await supabase 33 35 .from("permission_tokens") 34 36 .select("*, permission_token_rights(*)") ··· 118 120 }) 119 121 .returning(); 120 122 123 + if (auth_token) { 124 + await tx.execute(sql` 125 + WITH auth_token AS ( 126 + SELECT identities.id as identity_id 127 + FROM email_auth_tokens 128 + LEFT JOIN identities ON email_auth_tokens.identity = identities.id 129 + WHERE email_auth_tokens.id = ${auth_token} 130 + AND email_auth_tokens.confirmed = true 131 + AND identities.id IS NOT NULL 132 + ) 133 + INSERT INTO permission_token_on_homepage (token, identity) 134 + SELECT ${permissionToken.id}, identity_id 135 + FROM auth_token 136 + `); 137 + } 121 138 return { permissionToken, rights, entity_set }; 122 139 }); 123 140