@@ -5,9 +5,6 @@ import type {
55} from "@supabase/supabase-js" ;
66import { PostgrestError } from "@supabase/supabase-js" ;
77import type { Database } from "@repo/database/dbTypes" ;
8- import type { DGSupabaseClient } from "@repo/database/lib/client" ;
9-
10- type AgentType = Database [ "public" ] [ "Enums" ] [ "AgentType" ] | "group" ;
118
129type PublicTableName = keyof Database [ "public" ] [ "Tables" ] ;
1310type RawTables < TN extends PublicTableName > =
@@ -508,45 +505,3 @@ export const processAndInsertBatch = async <
508505 }
509506 return { ...result , data : processedResults } ;
510507} ;
511-
512- export const getSessionUserData = async (
513- client : DGSupabaseClient ,
514- ) : Promise < {
515- id : string ;
516- name : string ;
517- type : AgentType ;
518- email ?: string ;
519- } | null > => {
520- const session = await client . auth . getSession ( ) ;
521- if ( ! session ?. data ?. session ?. user ) return null ;
522- const { id, email } = session . data . session . user ;
523- if ( email ) {
524- const [ name , host ] = email . split ( "@" ) as [ string , string ] ;
525- if ( host === "database.discoursegraphs.com" && name . endsWith ( "-anon" ) ) {
526- const parts = name . split ( "-" ) ;
527- const spaceId = Number . parseInt ( parts [ 1 ] ! ) ;
528- const spaceReq = await client
529- . from ( "Space" )
530- . select ( "name" )
531- . eq ( "id" , spaceId )
532- . maybeSingle ( ) ;
533- if ( spaceReq . error || ! spaceReq . data ) {
534- return null ;
535- }
536- return { name : spaceReq . data . name , id, type : "anonymous" , email } ;
537- }
538- if ( host === "groups.discoursegraphs.com" ) {
539- return { name, id, email, type : "group" } ;
540- }
541- }
542- const accountReq = await client
543- . from ( "PlatformAccount" )
544- . select ( "name" )
545- . eq ( "dg_account" , session . data . session . user . id )
546- . eq ( "agent_type" , "person" )
547- . maybeSingle ( ) ;
548- if ( accountReq . error || ! accountReq . data ) {
549- return null ;
550- }
551- return { id, name : accountReq . data . name , type : "person" , email } ;
552- } ;
0 commit comments