This commit is contained in:
MartinBraquet
2025-11-11 21:07:40 +01:00
parent c953a84c1f
commit 8e2fa36d0e
3 changed files with 10 additions and 5 deletions

View File

@@ -25,8 +25,13 @@ export const contact: APIHandler<'contact'> = async (
const continuation = async () => {
try {
let user = null
if (userId) {
user = await pg.oneOrNone(` select name from users where id = $1 `, [userId])
}
const md = jsonToMarkdown(content)
const message: string = `**New Contact Message**\n${md}`
const tile = user ? `New message from ${user.name}` : 'New message'
const message: string = `**${tile}**\n${md}`
await sendDiscordMessage(message, 'contact')
} catch (e) {
console.error('Failed to send discord contact', e)

View File

@@ -8,7 +8,7 @@ create table if not exists
-- Foreign Keys
alter table contact
add constraint contact_user_id_fkey foreign key (user_id) references users (id);
add constraint contact_user_id_fkey foreign key (user_id) references users (id) on delete set null;
-- Row Level Security
alter table contact enable row level security;

View File

@@ -8,15 +8,15 @@ create table if not exists
id text default uuid_generate_v4 () not null,
parent_id text,
parent_type text,
user_id text not null
user_id text
);
-- Foreign Keys
alter table reports
add constraint reports_content_owner_id_fkey foreign key (content_owner_id) references users (id);
add constraint reports_content_owner_id_fkey foreign key (content_owner_id) references users (id) on delete set null;
alter table reports
add constraint reports_user_id_fkey foreign key (user_id) references users (id);
add constraint reports_user_id_fkey foreign key (user_id) references users (id) on delete set null;
-- Row Level Security
alter table reports enable row level security;