У меня есть 2 ссылки на документы в firestore, которые вызывают sendMail
функцию onCreate. Первый работает отлично, а второй - нет. Чтобы различать две функции sendMail
, я изменил имя на sendMailxxx
. Я считаю, что это привело к ошибке. Предоставляется ошибка
TypeError: transporter.sendMailupfill не является функцией
в файле exports.sendMailupfill.functions.firestore.document.onCreate
Как лучше всего определить 2 sendMail
функции в одном индексе. js файл?
Здесь с кодом
// Send the transaction email
exports.sendMail = functions.firestore.document('Companys/{companyid}/Transaction/{transactionid}').onCreate((snap, context) => {
const mailOptions = {
from: 'L App<report@sample.com>', // You can write any mail Address you want this doesn't effect anything,
to: snap.data().companyemailcf, // This mail address should be filled with any mail you want to read it,
bcc: 'admin@test.com',
subject: 'L Fuel , New Tranaction ',
html: `<h1>Confirmed Transaction</h1>
<p>
<b>Datetime: </b>${snap.data().datetime}<br>
<b>User: </b>${snap.data().user}<br>
<b>Vehicle: </b>${snap.data().vehicle}<br>
<b>Account: </b>${snap.data().account}<br>
</p>`
};
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
console.log(error);
return
}
console.log('Message sent: ' + info.response);
});
});
//Send the up-fill email
exports.sendMailupfill = functions.firestore.document('Companys/{companyid}/Upfill/{upfillid}').onCreate((snap, context) => {
const mailOptions = {
from: 'L Fuel App<report@sample.com>',
to: snap.data().companyemailcf, //
subject: 'L Fuel Record, New Tranaction ',
html: `<h1>Confirmed Bulk Tank Up-fill</h1>
<p>
<b>Up-fill date: </b>${snap.data().upfilldate}<br>
<b>Up-fill amount: </b>${snap.data().upfillamount}<br>
<b>Up-fill reference: </b>${snap.data().upfillreference}<br>
</p>`
};
transporter.sendMailupfill(mailOptions, (error, info) => {
if (error) {
console.log(error);
return
}
console.log('Message sent: ' + info.response);
});
}
);