@@ -708,113 +708,6 @@ export async function getMailsCount(
708708 return await MailModel . countDocuments ( query ) ;
709709}
710710
711- // export async function updateMail(
712- // mailData: Pick<Mail, "mailId" | "to" | "subject" | "body"> = {},
713- // ctx: GQLContext,
714- // ): Promise<Mail | null> {
715- // checkIfAuthenticated(ctx);
716-
717- // let mail: Mail | null = await MailModel.findOne({
718- // mailId: mailData.mailId,
719- // domain: ctx.subdomain._id,
720- // });
721-
722- // if (!isNotUndefined(mail)) {
723- // throw new Error(responses.item_not_found);
724- // }
725-
726- // if (!checkPermission(ctx.user.permissions, [permissions.manageUsers])) {
727- // throw new Error(responses.action_not_allowed);
728- // }
729-
730- // if (
731- // mailData.subject &&
732- // mailData.subject.length > UIConstants.MAIL_SUBJECT_MAX_LENGTH
733- // ) {
734- // throw new Error(responses.mail_subject_length_exceeded);
735- // }
736-
737- // if (mailData.to) {
738- // mailData.to = removeEmptyMembers(Array.from(new Set(mailData.to)));
739- // }
740-
741- // if (mailData.to && mailData.to.length > UIConstants.MAIL_MAX_RECIPIENTS) {
742- // throw new Error(responses.mail_max_recipients_exceeded);
743- // }
744-
745- // try {
746- // for (const key of Object.keys(mailData)) {
747- // if (key === "mailId") continue;
748-
749- // mail[key] = mailData[key];
750- // }
751-
752- // mail = await (mail as any).save();
753-
754- // return mail;
755- // } catch (e: any) {
756- // error(e.message, {
757- // stack: e.stack,
758- // });
759- // return null;
760- // }
761- // }
762-
763- // const removeEmptyMembers = (arr: string[]) =>
764- // arr.filter((x) => x.trim() !== "");
765-
766- // function isNotUndefined(mail: Mail | null): mail is Mail {
767- // return !!mail;
768- // }
769-
770- // export async function sendMail(mailId: string, ctx: GQLContext): Promise<Mail> {
771- // checkIfAuthenticated(ctx);
772-
773- // let mail: Mail | null = await MailModel.findOne({
774- // mailId: mailId,
775- // domain: ctx.subdomain._id,
776- // });
777-
778- // if (!isNotUndefined(mail)) {
779- // throw new Error(responses.item_not_found);
780- // }
781-
782- // if (!checkPermission(ctx.user.permissions, [permissions.manageUsers])) {
783- // throw new Error(responses.action_not_allowed);
784- // }
785-
786- // if (mail.published) {
787- // throw new Error(responses.mail_already_sent);
788- // }
789-
790- // if (!mail.to || !mail.subject || !mail.body) {
791- // throw new Error(responses.invalid_mail);
792- // }
793-
794- // const from = `${ctx.subdomain.settings.title || ctx.subdomain.name} ${
795- // ctx.user.email
796- // }`;
797-
798- // await send({
799- // from,
800- // to: mail.to,
801- // subject: mail.subject,
802- // body: mail.body,
803- // });
804-
805- // mail.published = true;
806- // try {
807- // await (mail as any).save();
808-
809- // return mail;
810- // } catch (e: any) {
811- // error(e.message, {
812- // stack: e.stack,
813- // });
814- // throw new Error(responses.internal_error);
815- // }
816- // }
817-
818711export async function sendCourseOverMail (
819712 courseId : string ,
820713 email : string ,
0 commit comments