fix email env

This commit is contained in:
Emily
2024-06-02 16:01:57 +02:00
parent 49064f709d
commit 6fb3c9c652
6 changed files with 75 additions and 39 deletions

View File

@@ -2,7 +2,16 @@ import { TProjectCount } from "@schema/ProjectsCounts";
import { ProjectModel } from "@schema/ProjectSchema";
import { UserModel } from "@schema/UserSchema";
import { LimitNotifyModel } from "@schema/broker/LimitNotifySchema";
import { sendLimitEmail50 } from '@services/EmailService';
import EmailService from '@services/EmailService';
import { requireEnv } from "../../shared/utilts/requireEnv";
EmailService.createTransport(
requireEnv('EMAIL_SERVICE'),
requireEnv('EMAIL_HOST'),
requireEnv('EMAIL_USER'),
requireEnv('EMAIL_PASS'),
);
export async function checkLimitsForEmail(projectCounts: TProjectCount) {
@@ -13,7 +22,7 @@ export async function checkLimitsForEmail(projectCounts: TProjectCount) {
if (!project) return;
const owner = await UserModel.findById(project.owner);
if (!owner) return;
await sendLimitEmail50(owner.email);
await EmailService.sendLimitEmail50(owner.email);
await LimitNotifyModel.updateOne({ project_id: projectCounts._id }, { limit1: true, limit2: false, limit3: false }, { upsert: true });
}