1
0
mirror of https://github.com/oceanprotocol/webtasks synced 2025-01-08 21:04:03 +01:00

fix exisiting users detection

This commit is contained in:
Matthias Kretschmann 2018-10-30 12:52:37 +01:00
parent b9cd283ab6
commit bac7e7c694
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -78,10 +78,12 @@ server.post('/newsletter/:email', (req, res) => {
request.get(baseOptions, (error, response, body) => { request.get(baseOptions, (error, response, body) => {
if (error) res.send(error) if (error) res.send(error)
const data = JSON.parse(body)
// Member exists and is subscribed // Member exists and is subscribed
if (body.status === 'subscribed') { if (data.status === 'subscribed') {
// Patch in native GDPR permissions // Patch in native GDPR permissions
addMarketingPermissions(body, () => { addMarketingPermissions(data, () => {
res.send('{ "status": "exists" }') res.send('{ "status": "exists" }')
}) })
} else { } else {
@ -89,12 +91,14 @@ server.post('/newsletter/:email', (req, res) => {
request.put(optionsCreate, (error2, response, body2) => { request.put(optionsCreate, (error2, response, body2) => {
if (error2) res.send(error2) if (error2) res.send(error2)
if (Number.isInteger(body2.status)) { const data2 = JSON.parse(body2)
if (Number.isInteger(data2.status)) {
res.send(body2) res.send(body2)
} }
// Patch in native GDPR permissions // Patch in native GDPR permissions
addMarketingPermissions(body2, () => { addMarketingPermissions(data2, () => {
res.send('{ "status": "created" }') res.send('{ "status": "created" }')
}) })
}) })