Created
May 7, 2019 12:48
-
-
Save KeKs0r/e49dc45bfed892285d64049ee20e6de2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const functions = require("firebase-functions"); | |
const got = require("got"); | |
const _ = require("lodash"); | |
const notifyNewSignup = functions | |
.runWith({ memory: "128MB" }) | |
.region("europe-west1") | |
.auth.user() | |
.onCreate(user => { | |
const email = user.email; | |
const displayName = user.displayName; | |
const provider = _.get(user, "providerData.0.providerId"); | |
const url = functions.config().slack.url; | |
if (!url) { | |
console.warn("You need to define the slack webhook URL"); | |
} | |
const text = `New user signup: ${displayName} (${email}) via ${provider}`; | |
return got.post(url, { | |
body: JSON.stringify({ | |
text, | |
username: "User Registration", | |
icon_emoji: ":sparkles:" | |
}) | |
}); | |
}); | |
module.exports = notifyNewSignup; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment