emailer and resume start
This commit is contained in:
@@ -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
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user