Skip to content

Commit

Permalink
Merge pull request #178 from watchout-tw/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
KTRNJack authored Apr 17, 2024
2 parents 7245331 + 627ad40 commit 036a0e1
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions lib/firestore.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// import axios from 'axios'
import firebase from 'firebase/app'
import firebaseConfig from '../config/firebase.config'
import 'firebase/auth'
import 'firebase/firestore'
import { makeReference, parseReference } from './watchout'
import firebaseConfig from '../config/firebase.config'
import { authorTypes, defaultPubDest } from './bunko'
import * as cookie from './cookie'
import * as core from './core'
import * as util from './util'
import * as cookie from './cookie'
import { makeReference, parseReference } from './watchout'

let bunkoApp
let bunkoAuth
Expand Down Expand Up @@ -158,6 +158,12 @@ function getUpdateInfo(date = new Date()) {
}
}

function getCreatedInfo(date = new Date()) {
return {
createdAt: date
}
}

function getMetadataUpdateInfo(date = new Date()) {
return {
updatedAt: date,
Expand Down Expand Up @@ -1020,10 +1026,8 @@ async function updateNewsletter(newsletterID, newsletter) {
}

async function addPromotionEmails(email, from) {
const promotionEmail = {
email,
from
}
let promotionEmail = { email, from }
promotionEmail = Object.assign(promotionEmail, getCreatedInfo())
let ref = bunkoFS.collection('promotion-emails').doc()
await ref.set(promotionEmail)
}
Expand All @@ -1039,6 +1043,17 @@ async function getCivilguideHash(id) {
return hashObj
}

async function getPromotionEmails() {
let item = []
const snapshot = await bunkoFS.collection('promotion-emails').get()
if(snapshot) {
snapshot.forEach(data => {
item.push(Object.assign(data.data(), { id: data.id }))
})
}
return item
}

export const bunko = {
countDocs,
getDocs,
Expand Down Expand Up @@ -1086,7 +1101,8 @@ export const bunko = {
addNewsletter,
updateNewsletter,
addPromotionEmails,
getCivilguideHash
getCivilguideHash,
getPromotionEmails
}

async function getAncms() {
Expand Down

0 comments on commit 036a0e1

Please sign in to comment.