@bluedot-innovation/models 7.5.4 → 7.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/__tests__/project/project.spec.js +8 -20
- package/package.json +1 -1
- package/schemas/Webhook.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -387,11 +387,11 @@ describe('Project', () => {
|
|
|
387
387
|
it(`should throw an error if structure is mobivity and taregt_id is not a body field`, (done) => {
|
|
388
388
|
project.webhooks[0].type = "register"
|
|
389
389
|
project.webhooks[0].structure = "mobivity"
|
|
390
|
-
project.webhooks[0].body = {"message_text": "test-value", "
|
|
390
|
+
project.webhooks[0].body = {"message_text": "test-value", "username": "test-value"}
|
|
391
391
|
let Project = new ProjectModel(project)
|
|
392
392
|
Project.validate((err, res) => {
|
|
393
393
|
assert.exists(err)
|
|
394
|
-
assert.match(err.message, /mobivity webhooks require "username", "target_id"
|
|
394
|
+
assert.match(err.message, /mobivity webhooks require "username", "target_id" and "message_text" body fields to be present/)
|
|
395
395
|
done()
|
|
396
396
|
})
|
|
397
397
|
})
|
|
@@ -399,23 +399,11 @@ describe('Project', () => {
|
|
|
399
399
|
it(`should throw an error if structure is mobivity and message_text is not a body field`, (done) => {
|
|
400
400
|
project.webhooks[0].type = "register"
|
|
401
401
|
project.webhooks[0].structure = "mobivity"
|
|
402
|
-
project.webhooks[0].body = {"target_id": "test-value", "
|
|
402
|
+
project.webhooks[0].body = {"target_id": "test-value", "username": "test-value"}
|
|
403
403
|
let Project = new ProjectModel(project)
|
|
404
404
|
Project.validate((err, res) => {
|
|
405
405
|
assert.exists(err)
|
|
406
|
-
assert.match(err.message, /mobivity webhooks require "username", "target_id"
|
|
407
|
-
done()
|
|
408
|
-
})
|
|
409
|
-
})
|
|
410
|
-
|
|
411
|
-
it(`should throw an error if structure is mobivity and url is not a body field`, (done) => {
|
|
412
|
-
project.webhooks[0].type = "register"
|
|
413
|
-
project.webhooks[0].structure = "mobivity"
|
|
414
|
-
project.webhooks[0].body = {"target_id": "test-value", "message_text": "test-value", "username": "test-value"}
|
|
415
|
-
let Project = new ProjectModel(project)
|
|
416
|
-
Project.validate((err, res) => {
|
|
417
|
-
assert.exists(err)
|
|
418
|
-
assert.match(err.message, /mobivity webhooks require "username", "target_id", "url" and "message_text" body fields to be present/)
|
|
406
|
+
assert.match(err.message, /mobivity webhooks require "username", "target_id" and "message_text" body fields to be present/)
|
|
419
407
|
done()
|
|
420
408
|
})
|
|
421
409
|
})
|
|
@@ -423,11 +411,11 @@ describe('Project', () => {
|
|
|
423
411
|
it(`should throw an error if structure is mobivity and username is not a body field`, (done) => {
|
|
424
412
|
project.webhooks[0].type = "register"
|
|
425
413
|
project.webhooks[0].structure = "mobivity"
|
|
426
|
-
project.webhooks[0].body = {"target_id": "test-value", "message_text": "
|
|
414
|
+
project.webhooks[0].body = {"target_id": "test-value", "message_text": "est-value"}
|
|
427
415
|
let Project = new ProjectModel(project)
|
|
428
416
|
Project.validate((err, res) => {
|
|
429
417
|
assert.exists(err)
|
|
430
|
-
assert.match(err.message, /mobivity webhooks require "username", "target_id"
|
|
418
|
+
assert.match(err.message, /mobivity webhooks require "username", "target_id" and "message_text" body fields to be present/)
|
|
431
419
|
done()
|
|
432
420
|
})
|
|
433
421
|
})
|
|
@@ -439,7 +427,7 @@ describe('Project', () => {
|
|
|
439
427
|
let Project = new ProjectModel(project)
|
|
440
428
|
Project.validate((err, res) => {
|
|
441
429
|
assert.exists(err)
|
|
442
|
-
assert.match(err.message, /mobivity webhooks require "username", "target_id"
|
|
430
|
+
assert.match(err.message, /mobivity webhooks require "username", "target_id" and "message_text" body fields to be present/)
|
|
443
431
|
done()
|
|
444
432
|
})
|
|
445
433
|
})
|
|
@@ -451,7 +439,7 @@ describe('Project', () => {
|
|
|
451
439
|
let Project = new ProjectModel(project)
|
|
452
440
|
Project.validate((err, res) => {
|
|
453
441
|
assert.exists(err)
|
|
454
|
-
assert.match(err.message, /mobivity webhooks require "username", "target_id"
|
|
442
|
+
assert.match(err.message, /mobivity webhooks require "username", "target_id" and "message_text" body fields to be present/)
|
|
455
443
|
done()
|
|
456
444
|
})
|
|
457
445
|
})
|
package/package.json
CHANGED
package/schemas/Webhook.js
CHANGED
|
@@ -21,7 +21,7 @@ function validateMobivityRequiredFields(structure){
|
|
|
21
21
|
return false;
|
|
22
22
|
}
|
|
23
23
|
const bodyKeys = Object.keys(webhookBodyFields)
|
|
24
|
-
if(!bodyKeys.includes("username") || !bodyKeys.includes("target_id") || !bodyKeys.includes("message_text")
|
|
24
|
+
if(!bodyKeys.includes("username") || !bodyKeys.includes("target_id") || !bodyKeys.includes("message_text")){
|
|
25
25
|
return false;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -45,7 +45,7 @@ let WebhookSchema = new mongoose.Schema({
|
|
|
45
45
|
default: 'standard',
|
|
46
46
|
validate: [
|
|
47
47
|
{validator: validateTealiumRequiredFields, msg: 'tealium webhooks require "tealium_account" and "tealium_profile" body fields to be present'},
|
|
48
|
-
{validator: validateMobivityRequiredFields, msg: 'mobivity webhooks require "username", "target_id"
|
|
48
|
+
{validator: validateMobivityRequiredFields, msg: 'mobivity webhooks require "username", "target_id" and "message_text" body fields to be present'}
|
|
49
49
|
]
|
|
50
50
|
}
|
|
51
51
|
}, {
|