google-cloud-functions

Firestore cloud function to recursively update subcollection/collectionGroup

点点圈 提交于 2020-05-11 23:49:12
问题 I have this cloud function: import pLimit from "p-limit"; const syncNotificationsAvatar = async ( userId: string, change: Change<DocumentSnapshot> ) => { if (!change.before.get("published") || !change.after.exists) { return; } const before: Profile = change.before.data() as any; const after: Profile = change.after.data() as any; const keysToCompare: (keyof Profile)[] = ["avatar"]; if ( arraysEqual( keysToCompare.map((k) => before[k]), keysToCompare.map((k) => after[k]) ) ) { return; } const

Firestore cloud function to recursively update subcollection/collectionGroup

孤街浪徒 提交于 2020-05-11 23:48:56
问题 I have this cloud function: import pLimit from "p-limit"; const syncNotificationsAvatar = async ( userId: string, change: Change<DocumentSnapshot> ) => { if (!change.before.get("published") || !change.after.exists) { return; } const before: Profile = change.before.data() as any; const after: Profile = change.after.data() as any; const keysToCompare: (keyof Profile)[] = ["avatar"]; if ( arraysEqual( keysToCompare.map((k) => before[k]), keysToCompare.map((k) => after[k]) ) ) { return; } const

Firestore cloud function to recursively update subcollection/collectionGroup

随声附和 提交于 2020-05-11 23:48:22
问题 I have this cloud function: import pLimit from "p-limit"; const syncNotificationsAvatar = async ( userId: string, change: Change<DocumentSnapshot> ) => { if (!change.before.get("published") || !change.after.exists) { return; } const before: Profile = change.before.data() as any; const after: Profile = change.after.data() as any; const keysToCompare: (keyof Profile)[] = ["avatar"]; if ( arraysEqual( keysToCompare.map((k) => before[k]), keysToCompare.map((k) => after[k]) ) ) { return; } const

firebase cloud function authentication: onCreate event doesn't contain displayName

谁说我不能喝 提交于 2020-05-09 16:56:02
问题 I have a cloud function for onCreate that looks like exports.addNewUserToCollection = functions.auth.user().onCreate(event => { const user = event.data; // The Firebase user. var userData = JSON.parse(JSON.stringify(user)); if (!userData.displayName){ userData.displayName = '(no name)' } return db .collection("users") .doc(user.uid) .set(userData); }); it works fine except when the user signs up via email. When the user signs up via email they are prompted for a first and last name and this

firebase cloud function authentication: onCreate event doesn't contain displayName

岁酱吖の 提交于 2020-05-09 16:52:08
问题 I have a cloud function for onCreate that looks like exports.addNewUserToCollection = functions.auth.user().onCreate(event => { const user = event.data; // The Firebase user. var userData = JSON.parse(JSON.stringify(user)); if (!userData.displayName){ userData.displayName = '(no name)' } return db .collection("users") .doc(user.uid) .set(userData); }); it works fine except when the user signs up via email. When the user signs up via email they are prompted for a first and last name and this

Cannot invoke Google Cloud Function from GCP Scheduler

一世执手 提交于 2020-05-09 06:13:34
问题 I've been trying to invoke a GCP function ( --runtime nodejs8 --trigger-http ) from GCP scheduler, both located within the same project. I can only make it work, if I grant unauthenticated access by adding the allUsers member to the functions permissions, with the Cloud Functions-Invoker role applied to it. However, when I only use the service account of the scheduler as the Cloud Functions-Invoker , I get a PERMISSION DENIED Error. I created a hello world example, to show in detail, how my

Cannot invoke Google Cloud Function from GCP Scheduler

谁说胖子不能爱 提交于 2020-05-09 06:12:43
问题 I've been trying to invoke a GCP function ( --runtime nodejs8 --trigger-http ) from GCP scheduler, both located within the same project. I can only make it work, if I grant unauthenticated access by adding the allUsers member to the functions permissions, with the Cloud Functions-Invoker role applied to it. However, when I only use the service account of the scheduler as the Cloud Functions-Invoker , I get a PERMISSION DENIED Error. I created a hello world example, to show in detail, how my

Cannot invoke Google Cloud Function from GCP Scheduler

时间秒杀一切 提交于 2020-05-09 06:12:08
问题 I've been trying to invoke a GCP function ( --runtime nodejs8 --trigger-http ) from GCP scheduler, both located within the same project. I can only make it work, if I grant unauthenticated access by adding the allUsers member to the functions permissions, with the Cloud Functions-Invoker role applied to it. However, when I only use the service account of the scheduler as the Cloud Functions-Invoker , I get a PERMISSION DENIED Error. I created a hello world example, to show in detail, how my

Nodemailer and AWS SES EREFUSED error when using cloud functions

不打扰是莪最后的温柔 提交于 2020-04-30 19:28:48
问题 I'm building a web app with firebase and cloud functions. I have a cloud function that creates a verification code every time an new user wants to subscribe and I need to send via email this verification code. I'm trying to use nodemailer with AWS Simple Email Sender. I have my SMTP credentials for AWS SES and this code works perfectly on my localhost but when I deploy this cloud function to firebase I doesnt work and I get this error. { Error: queryA EREFUSED email-smtp.us-east-1.amazonaws

Parallel writes to Firestore using a Python 3.7 Cloud Function

本小妞迷上赌 提交于 2020-04-30 09:25:05
问题 As we can read in a note in this link about writing to Firestore: For bulk data entry, use a server client library with parallelized individual writes. Batched writes perform better than serialized writes but not better than parallel writes. You should use a server client library for bulk data operations and not a mobile/web SDK. I'm trying to program parallel writes to Firestore in a Python 3.7 Cloud Function. I have never programmed anything in parallel in Python, so I'm trying to use some