Skip to content

Commit

Permalink
Merge pull request #21 from duboisp/post
Browse files Browse the repository at this point in the history
minor edit to allow addEmailPOST + fix cyclic error
  • Loading branch information
GormFrank authored Apr 1, 2020
2 parents 5b276ce + 4828c57 commit e282fc7
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 22 deletions.
36 changes: 14 additions & 22 deletions controllers/subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ exports.addEmailPOST = async ( req, res, next ) => {
if ( !reqbody || _validHosts.indexOf(host) === -1 || keyDecrypt < currEpoc ) {

console.log( "addEmailPOST: noauth" );
console.log( e );
res.redirect( _errorPage );
return true;
}
Expand All @@ -178,8 +177,7 @@ exports.addEmailPOST = async ( req, res, next ) => {

// No topic = no good
if ( !topic || !topic.inputErrURL || !topic.thankURL || !topic.failURL ) {
console.log( "addEmailPOST: no topic" );
console.log( e );
console.log( "addEmailPOST: no topic" );
res.redirect( _errorPage );
return true;
}
Expand Down Expand Up @@ -517,36 +515,30 @@ sendNotifyConfirmEmail = async ( email, confirmCode, templateId, NotifyKey ) =>
.catch( ( e ) => {
// Log the Notify errors

const currDate = new Date();
const currDate = new Date(),
errDetails = e.error.errors[0];

// notify_logs entry - this can be async
dbConn.collection( "notify_logs" ).updateOne(
{ _id: templateId },
dbConn.collection( "notify_logs" ).insertOne(
{
$setOnInsert: {
_id: templateId,
createdAt: currDate
},
$push: {
errLogs: {
createdAt: currDate,
e: e
}
},
$currentDate: {
lastUpdated: true
}
createdAt: currDate,
templateId: templateId,
e: errDetails.error,
msg: errDetails.message,
statusCode: e.error.status_code,
err: e.toString(),
code: confirmCode
},
{ upsert: true }
).catch( (e2) => {
console.log( "sendNotifyConfirmEmail: notify_logs" );
console.log( "sendNotifyConfirmEmail: notify_logs: " + confirmCode );
console.log( e2 );
console.log( e );
});

// TODO: evaluate if we need to trigger something else

console.log( "sendNotifyConfirmEmail: sendEmail" );
console.log( e );
console.log( "sendNotifyConfirmEmail: sendEmail " + confirmCode );
});
}

Expand Down
32 changes: 32 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,38 @@ db.topics.insertOne( {
})
```

Same, but to update an existing topic

```
db.topics.updateOne( {
_id: "test"
},
{
$set: {
thankURL: "https://canada.ca/en.html",
inputErrURL: "https://canada.ca/en.html",
failURL: "https://canada.ca/en.html"
}
}
);
```

To remove it
```
db.topics.updateOne( {
_id: "test"
},
{
$unset: {
thankURL: "",
inputErrURL: "",
failURL: ""
}
}
);
```


### Going live with a topic

You need to:
Expand Down

0 comments on commit e282fc7

Please sign in to comment.