Skip to content

Instantly share code, notes, and snippets.

@gastsail
Created November 17, 2019 17:40
Show Gist options
  • Save gastsail/4fbb2639634eb5f66dcc1b089b290379 to your computer and use it in GitHub Desktop.
Save gastsail/4fbb2639634eb5f66dcc1b089b290379 to your computer and use it in GitHub Desktop.
script
exports.onItemCreation = functions.firestore.document('purchases/{purchaseId}')
.onCreate(async(snapshot, context) => {
const itemDataSnap = await snapshot.ref.get()
return admin.firestore().collection('mail').add({
to: [itemDataSnap.data().email],
message: {
subject: 'Your reservation is here !',
html: 'Hey '+ itemDataSnap.data().name +'. This is your reservation for the event and it costs $' + itemDataSnap.data().dollarqty +', thanks for the purchase.',
}
}).then(() => console.log('Queued email for delivery!'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment