emailer and resume start
ci / docker_image (push) Successful in 1m34s
ci / deploy (push) Successful in 16s

This commit is contained in:
2025-03-23 12:26:12 -05:00
parent 4f9e770270
commit 1877aee8a5
11 changed files with 292 additions and 167 deletions
+33
View File
@@ -10,6 +10,7 @@ import {
type Posting,
type Application
} from '$lib/types';
import { sendEmployerNotificationEmail } from '$lib/emailer.server';
export async function createUser(user: User): Promise<number> {
const password_hash: string = await bcrypt.hash(user.password!, 12);
@@ -700,6 +701,9 @@ export async function createApplication(application: Application): Promise<numbe
RETURNING id;
`;
sendEmployerNotificationEmail(application.postingId).catch((err) => {
console.error('Failed to send employer notification email: ', err);
});
return response[0].id;
}
@@ -764,3 +768,32 @@ export async function setUserCompanyId(userId: number, companyId: number): Promi
WHERE id = ${userId};
`;
}
export async function getNotificationInfo(
postingId: number
): Promise<{ title: string; emails: string[] }> {
const data = await sql`
WITH posting_data AS (
SELECT title, company_id
FROM postings
WHERE id = ${postingId}
),
user_emails AS (
SELECT email
FROM users
WHERE company_id = (SELECT company_id FROM posting_data)
)
SELECT
(SELECT title FROM posting_data) AS title,
(SELECT json_agg(email) FROM user_emails) AS emails;
`;
if (!data || !data[0]) {
error(404, 'Posting not found');
}
return {
title: data[0].title,
emails: data[0].emails
};
}