Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-04-18 00:52:30 +00:00
co-authored by renee-png
parent d59f87961e
commit 1b454bf090
3 changed files with 104 additions and 9 deletions
+60
View File
@@ -968,6 +968,63 @@ export type Database = {
},
]
}
email_logs: {
Row: {
bcc_addresses: string[]
body_html: string | null
body_text: string | null
case_id: string | null
cc_addresses: string[]
context: string | null
created_at: string
error_message: string | null
from_address: string | null
id: string
reply_to: string | null
sent_at: string
sent_by: string | null
status: string
subject: string
to_addresses: string[]
}
Insert: {
bcc_addresses?: string[]
body_html?: string | null
body_text?: string | null
case_id?: string | null
cc_addresses?: string[]
context?: string | null
created_at?: string
error_message?: string | null
from_address?: string | null
id?: string
reply_to?: string | null
sent_at?: string
sent_by?: string | null
status?: string
subject: string
to_addresses?: string[]
}
Update: {
bcc_addresses?: string[]
body_html?: string | null
body_text?: string | null
case_id?: string | null
cc_addresses?: string[]
context?: string | null
created_at?: string
error_message?: string | null
from_address?: string | null
id?: string
reply_to?: string | null
sent_at?: string
sent_by?: string | null
status?: string
subject?: string
to_addresses?: string[]
}
Relationships: []
}
expenses: {
Row: {
amount: number
@@ -1789,6 +1846,7 @@ export type Database = {
smtp_settings: {
Row: {
created_at: string
default_bcc: string | null
enabled: boolean
from_email: string
from_name: string | null
@@ -1804,6 +1862,7 @@ export type Database = {
}
Insert: {
created_at?: string
default_bcc?: string | null
enabled?: boolean
from_email: string
from_name?: string | null
@@ -1819,6 +1878,7 @@ export type Database = {
}
Update: {
created_at?: string
default_bcc?: string | null
enabled?: boolean
from_email?: string
from_name?: string | null
-9
View File
@@ -742,12 +742,3 @@ const rootRouteChildren: RootRouteChildren = {
export const routeTree = rootRouteImport
._addFileChildren(rootRouteChildren)
._addFileTypes<FileRouteTypes>()
import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
@@ -0,0 +1,44 @@
-- Add BCC default to SMTP settings
ALTER TABLE public.smtp_settings
ADD COLUMN IF NOT EXISTS default_bcc text;
-- Email log table
CREATE TABLE IF NOT EXISTS public.email_logs (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
sent_at timestamptz NOT NULL DEFAULT now(),
sent_by uuid,
to_addresses text[] NOT NULL DEFAULT '{}',
cc_addresses text[] NOT NULL DEFAULT '{}',
bcc_addresses text[] NOT NULL DEFAULT '{}',
reply_to text,
from_address text,
subject text NOT NULL,
body_html text,
body_text text,
status text NOT NULL DEFAULT 'sent',
error_message text,
context text,
case_id uuid,
created_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS email_logs_sent_at_idx ON public.email_logs (sent_at DESC);
CREATE INDEX IF NOT EXISTS email_logs_sent_by_idx ON public.email_logs (sent_by);
CREATE INDEX IF NOT EXISTS email_logs_case_id_idx ON public.email_logs (case_id);
ALTER TABLE public.email_logs ENABLE ROW LEVEL SECURITY;
DROP POLICY IF EXISTS email_logs_select ON public.email_logs;
CREATE POLICY email_logs_select ON public.email_logs
FOR SELECT TO authenticated
USING (public.is_admin(auth.uid()) OR sent_by = auth.uid());
DROP POLICY IF EXISTS email_logs_insert ON public.email_logs;
CREATE POLICY email_logs_insert ON public.email_logs
FOR INSERT TO authenticated
WITH CHECK (auth.uid() IS NOT NULL);
DROP POLICY IF EXISTS email_logs_delete ON public.email_logs;
CREATE POLICY email_logs_delete ON public.email_logs
FOR DELETE TO authenticated
USING (public.is_admin(auth.uid()));