<commit_before>import path from 'path';
import express from 'express';
import horizon from '@horizon/server';
import nodemailer from 'nodemailer';
import bodyParser from 'body-parser';
import devProps from '../../config/webpack/devProps';
import config from '../../config/page';
import gifnoc from '../../config/gifnoc';
import wedding from '../../config/wedding';
import variables from '../../config/variables';
import apiKeys from '../../config/keys';
import fxns from '../utils/fxns';
import { r, r_internal } from './db';

const app = express();

const googleMapsApi = apiKeys.googleMaps;
app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
app.use('/static', express.static(path.join(process.cwd(), '.build')));

/**
 * @TODO move the html out of the server dir
 */
const host = process.env.NODE_ENV === 'production' ? '' : `http://127.0.0.1:${devProps.webpackPort}`;
const bundle = `${host}/static/client.bundle.js`;
const styles = `${host}/static/styles.css`;
// const images = `${host}/static/images/`;
const faviconUrl = wedding.favicon;

const coupleOne = wedding.couple[0].name.first;
const coupleTwo = wedding.couple[1].name.first;

const couple = `${coupleOne} & ${coupleTwo}`;
const coupleInitials = fxns.coupleInitials();
const weddingDate = new Date(wedding.date);
const weddingDay = weddingDate.getDate();
const weddingMonth = parseInt(weddingDate.getMonth() + 1, 10);
const weddingYear = weddingDate.getFullYear().toString().slice(-2);
const prettyWeddingDate = `${weddingMonth}·${weddingDay}·${weddingYear}`;

const transporter = nodemailer.createTransport(`smtps://${gifnoc.gmail.user}%40gmail.com:${<EMAIL>`);
const mailOptions = {
  from: `${couple} <${<EMAIL>>`,
  subject: `RSVP Received: ${coupleInitials} | ${prettyWeddingDate}`
};

const sendErrorEmail = (reqBody) => {
  const errorMessage = `Error!<br/>Cannot send email notification.<br/>Not Found in DB<br/>${JSON.stringify(reqBody)}`;
  const mailOptionsCloned = Object.assign(
    { to: wedding.email, html: errorMessage },
    mailOptions
  );

  transporter.sendMail(mailOptionsCloned, function(error, info){
    if (error) {
      return console.log(error);
    }
    console.log('Message sent: ' + info.response);
  });
};

app.post('/notify', (req) => {
  if (req.body && req.body.id) {
    r_internal.table('collections').get('invitations').run()
    .then(function(result) {
      r.table(result.table).get(req.body.id).run().then((invitation) => {

        if (invitation && invitation.processed) {
          const processed = invitation.processed;
          // signature
          const attendingMsg = processed.attendingNamesStr
            ? `Attending:<br/>${processed.attendingNamesStr}`
            : '';

          const plusMsg = processed.plusMessage
            ? `<br/>${processed.plusMessage}`
            : '';

          const signature = `Love,<br/>${couple}`;

          const style = `color:${variables.black};font-family:Garamond,Palatino,serif; font-size: 12pt;`;
          // the body of the email
          const body = `
            <div style="${style}">
              <p>Hello ${processed.salutationNamesStr},</p>
              <p>${processed.rsvpReceivedMessage}</p>
              <p>${attendingMsg}${plusMsg}</p>
              <p>${signature}</p>
            </div>`;

          const sendTo = process.env.NODE_ENV !== 'production' ? wedding.email : processed.toEmails;
<commit_msg>Email alert - changed font family<commit_after>import path from 'path';
import express from 'express';
import horizon from '@horizon/server';
import nodemailer from 'nodemailer';
import bodyParser from 'body-parser';
import devProps from '../../config/webpack/devProps';
import config from '../../config/page';
import gifnoc from '../../config/gifnoc';
import wedding from '../../config/wedding';
import variables from '../../config/variables';
import apiKeys from '../../config/keys';
import fxns from '../utils/fxns';
import { r, r_internal } from './db';

const app = express();

const googleMapsApi = apiKeys.googleMaps;
app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
app.use('/static', express.static(path.join(process.cwd(), '.build')));

/**
 * @TODO move the html out of the server dir
 */
const host = process.env.NODE_ENV === 'production' ? '' : `http://127.0.0.1:${devProps.webpackPort}`;
const bundle = `${host}/static/client.bundle.js`;
const styles = `${host}/static/styles.css`;
// const images = `${host}/static/images/`;
const faviconUrl = wedding.favicon;

const coupleOne = wedding.couple[0].name.first;
const coupleTwo = wedding.couple[1].name.first;

const couple = `${coupleOne} & ${coupleTwo}`;
const coupleInitials = fxns.coupleInitials();
const weddingDate = new Date(wedding.date);
const weddingDay = weddingDate.getDate();
const weddingMonth = parseInt(weddingDate.getMonth() + 1, 10);
const weddingYear = weddingDate.getFullYear().toString().slice(-2);
const prettyWeddingDate = `${weddingMonth}·${weddingDay}·${weddingYear}`;

const transporter = nodemailer.createTransport(`smtps://${gifnoc.gmail.user}%40gmail.com:${<EMAIL>`);
const mailOptions = {
  from: `${couple} <${<EMAIL>>`,
  subject: `RSVP Received: ${coupleInitials} | ${prettyWeddingDate}`
};

const sendErrorEmail = (reqBody) => {
  const errorMessage = `Error!<br/>Cannot send email notification.<br/>Not Found in DB<br/>${JSON.stringify(reqBody)}`;
  const mailOptionsCloned = Object.assign(
    { to: wedding.email, html: errorMessage },
    mailOptions
  );

  transporter.sendMail(mailOptionsCloned, function(error, info){
    if (error) {
      return console.log(error);
    }
    console.log('Message sent: ' + info.response);
  });
};

app.post('/notify', (req) => {
  if (req.body && req.body.id) {
    r_internal.table('collections').get('invitations').run()
    .then(function(result) {
      r.table(result.table).get(req.body.id).run().then((invitation) => {

        if (invitation && invitation.processed) {
          const processed = invitation.processed;
          // signature
          const attendingMsg = processed.attendingNamesStr
            ? `Attending:<br/>${processed.attendingNamesStr}`
            : '';

          const plusMsg = processed.plusMessage
            ? `<br/>${processed.plusMessage}`
            : '';

          const signature = `Love,<br/>${couple}`;

          const style = `color:${variables.black};font-family: Helvetica, Arial, sans-serif; font-size: 12pt;`;
          // the body of the email
          const body = `
            <div style="${style}">
              <p>Hello ${processed.salutationNamesStr},</p>
              <p>${processed.rsvpReceivedMessage}</p>
              <p>${attendingMsg}${plusMsg}</p>
              <p>${signature}</p>
            </div>`;

          const sendTo = process.env.NODE_ENV !== 'production' ? wedding.email : processed.toEmails;

{'fraction_non_alphanumeric': 0.17533606078316774, 'fraction_numerical': 0.004675628287551139, 'mean_word_length': 3.542136695421367, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3997036', 'n_tokens_mistral': 2117, 'n_tokens_neox': 2103, 'n_words': 439}