Skip to content

Commit e2a3df9

Browse files
access VanID properly; return in case of failure; prettify
1 parent a54cdb0 commit e2a3df9

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/server/api/schema.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,13 +1349,14 @@ const rootMutations = {
13491349
// If not, return and skip next steps
13501350
try {
13511351
const c = JSON.stringify(contact.customFiels);
1352-
if (!"vanId" in c) return newContact;
1352+
if (c?.VanID === undefined) return newContact;
13531353
} catch (exception) {
1354-
console.log(exception)
1354+
console.log(exception);
1355+
return newContact;
13551356
}
13561357

13571358
console.log(
1358-
"createOptOut VAN"
1359+
`createOptOut VAN ${contact.cell}`
13591360
);
13601361

13611362
const body = {
@@ -1368,13 +1369,13 @@ const rootMutations = {
13681369
}
13691370
},
13701371
"resultCodeId": 205
1371-
}
1372+
};
13721373

13731374
try {
13741375
// I am assuming here that contact has vanID.
13751376
// will need to test
13761377
await Van.postCanvassResponse(contact, organization, body);
1377-
console.log(`canvasOptOut VAN success ${contact}`)
1378+
console.log(`canvasOptOut VAN success ${contact.cell}`)
13781379
} catch (e) {
13791380
console.log(`Error opting out ${contact.cell}: ${e}`);
13801381
} finally {

0 commit comments

Comments
 (0)