Skip to content

Commit

Permalink
fix: no document to update errors (#940)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmo314 committed Feb 7, 2023
1 parent 8269171 commit 3fb4f73
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions functions/src/subscriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ export const subscribe = functions.https.onCall(async (data, context) => {
functions.logger.info("updating last active time");

// update the metadata for this channel to indicate the last active time.
await profile.ref.update({
await profile.ref.set({
lastActiveAt: admin.firestore.FieldValue.serverTimestamp(),
});
}, { merge: true });

if (profile.get("twitch") && profile.get("twitch")["id"] == channelId) {
functions.logger.info("checking eventsub subscriptions.");
Expand All @@ -70,9 +70,9 @@ export const subscribe = functions.https.onCall(async (data, context) => {
.firestore()
.collection("channels")
.doc(`${provider}:${channelId}`)
.update({
.set({
lastActiveAt: admin.firestore.FieldValue.serverTimestamp(),
});
}, { merge: true });

// if there are no messages logged, this is a new user.
if (profile.get("lastActiveAt") == null) {
Expand Down

0 comments on commit 3fb4f73

Please sign in to comment.