Skip to content
This repository was archived by the owner on Apr 3, 2019. It is now read-only.

Commit 5a1535a

Browse files
authored
fix(devices): Rename pushbox capability to messages and add messages.sendtab capability (#335) r=@rfk
1 parent 2129ede commit 5a1535a

File tree

5 files changed

+18
-16
lines changed

5 files changed

+18
-16
lines changed

db-server/test/backend/db_tests.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ function makeMockDevice(tokenId) {
100100
callbackPublicKey: 'foo',
101101
callbackAuthKey: 'bar',
102102
callbackIsExpired: false,
103-
capabilities: ['pushbox']
103+
capabilities: ['messages']
104104
}
105105
device.deviceId = newUuid()
106106
return device
@@ -476,7 +476,7 @@ module.exports = function (config, DB) {
476476
assert.equal(sessions[0].deviceCallbackPublicKey, 'foo')
477477
assert.equal(sessions[0].deviceCallbackAuthKey, 'bar')
478478
assert.equal(sessions[0].deviceCallbackIsExpired, false)
479-
assert.deepEqual(sessions[0].deviceCapabilities, ['pushbox'])
479+
assert.deepEqual(sessions[0].deviceCapabilities, ['messages'])
480480
})
481481
})
482482

@@ -994,15 +994,15 @@ module.exports = function (config, DB) {
994994

995995
it('should fail to update a device with unknown capabilities', () => {
996996
const newDevice = Object.assign({}, deviceInfo, {
997-
capabilities: ['unknown', 'newpushbox']
997+
capabilities: ['unknown', 'newmessages']
998998
})
999999
return db.updateDevice(accountData.uid, deviceInfo.deviceId, newDevice)
10001000
.then(assert.fail, (err) => {
10011001
assert.equal(err.code, 400, 'err.code')
10021002
assert.equal(err.errno, 139, 'err.errno')
10031003
return db.accountDevices(accountData.uid)
10041004
})
1005-
.then((devices) => assert.deepEqual(devices[0].capabilities, ['pushbox']))
1005+
.then((devices) => assert.deepEqual(devices[0].capabilities, ['messages']))
10061006
})
10071007

10081008
it('capabilities are not cleared if not specified', () => {
@@ -1012,7 +1012,7 @@ module.exports = function (config, DB) {
10121012
.then(() => {
10131013
return db.accountDevices(accountData.uid)
10141014
})
1015-
.then((devices) => assert.deepEqual(devices[0].capabilities, ['pushbox']))
1015+
.then((devices) => assert.deepEqual(devices[0].capabilities, ['messages']))
10161016
})
10171017

10181018
it('capabilities are overwritten on update', () => {

db-server/test/backend/remote.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ module.exports = function(cfg, makeServer) {
528528
assert(s.deviceCallbackPublicKey)
529529
assert.equal(s.deviceCallbackURL, 'fake callback URL')
530530
assert.equal(s.deviceCallbackIsExpired, false)
531-
assert.deepEqual(s.deviceCapabilities, ['pushbox'])
531+
assert.deepEqual(s.deviceCapabilities, ['messages'])
532532
assert(s.deviceCreatedAt)
533533
assert(s.deviceId)
534534
assert.equal(s.deviceName, 'fake device name')
@@ -599,7 +599,7 @@ module.exports = function(cfg, makeServer) {
599599
.then(function(r) {
600600
assert.equal(r.obj.length, 0, 'devices is empty')
601601
const myDevice = Object.assign({}, user.device, {
602-
capabilities: ['unknown', 'pushbox']
602+
capabilities: ['unknown', 'messages']
603603
})
604604
return client.putThen('/account/' + user.accountId + '/device/' + user.deviceId, myDevice)
605605
.then(() => {

db-server/test/fake.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ module.exports.newUserDataHex = function() {
7676
callbackPublicKey: base64_65(),
7777
callbackAuthKey: base64_16(),
7878
callbackIsExpired: false,
79-
capabilities: ['pushbox']
79+
capabilities: ['messages']
8080
}
8181

8282
// keyFetchToken

docs/API.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ Content-Type: application/json
666666
"callbackPublicKey": "BCp93zru09_hab2Bg37LpTNG__Pw6eMPEP2hrQpwuytoj3h4chXpGc-3qqdKyqjuvAiEupsnOd_RLyc7erJHWgA",
667667
"callbackAuthKey": "w3b14Zjc-Afj2SDOLOyong",
668668
"callbackIsExpired": false,
669-
"capabilities": ["pushbox"],
669+
"capabilities": ["messages"],
670670
"uaBrowser": "Firefox",
671671
"uaBrowserVersion": "42",
672672
"uaOS": "Android",
@@ -725,7 +725,7 @@ Content-Type: application/json
725725
"callbackPublicKey": "BCp93zru09_hab2Bg37LpTNG__Pw6eMPEP2hrQpwuytoj3h4chXpGc-3qqdKyqjuvAiEupsnOd_RLyc7erJHWgA",
726726
"callbackAuthKey": "w3b14Zjc-Afj2SDOLOyong",
727727
"callbackIsExpired": false,
728-
"capabilities": ["pushbox"]
728+
"capabilities": ["messages"]
729729
}
730730
```
731731

@@ -761,7 +761,7 @@ curl \
761761
"callbackPublicKey": "BCp93zru09_hab2Bg37LpTNG__Pw6eMPEP2hrQpwuytoj3h4chXpGc-3qqdKyqjuvAiEupsnOd_RLyc7erJHWgA",
762762
"callbackAuthKey": "w3b14Zjc-Afj2SDOLOyong",
763763
"callbackIsExpired": false,
764-
"capabilities": ["pushbox"]
764+
"capabilities": ["messages"]
765765
}'
766766
```
767767

@@ -810,7 +810,7 @@ curl \
810810
"callbackPublicKey": "BCp93zru09_hab2Bg37LpTNG__Pw6eMPEP2hrQpwuytoj3h4chXpGc-3qqdKyqjuvAiEupsnOd_RLyc7erJHWgA",
811811
"callbackAuthKey": "w3b14Zjc-Afj2SDOLOyong",
812812
"callbackIsExpired": false,
813-
"capabilities": ["pushbox"]
813+
"capabilities": ["messages"]
814814
}'
815815
```
816816

@@ -924,7 +924,7 @@ Content-Length: 285
924924
"deviceCallbackURL":null,
925925
"deviceCallbackPublicKey":null,
926926
"deviceCallbackIsExpired":false,
927-
"deviceCapabilities":["pushbox"],
927+
"deviceCapabilities":["messages"],
928928
"mustVerify":true,
929929
"tokenVerificationId":"12c41fac80fd6149f3f695e188b5f846"
930930
}
@@ -991,7 +991,7 @@ Content-Length: 285
991991
"deviceCallbackURL":null,
992992
"deviceCallbackPublicKey":null,
993993
"deviceCallbackIsExpired":false,
994-
"deviceCapabilities":["pushbox"],
994+
"deviceCapabilities":["messages"],
995995
"mustVerify":true,
996996
"tokenVerificationId":"12c41fac80fd6149f3f695e188b5f846"
997997
}

lib/db/util.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ const VERIFICATION_METHODS = new Map([
4242

4343
// If you modify one of these maps, modify the other.
4444
const DEVICE_CAPABILITIES = new Map([
45-
['pushbox', 1]
45+
['messages', 1],
46+
['messages.sendtab', 2]
4647
])
4748
const DEVICE_CAPABILITIES_IDS = new Map([
48-
[1, 'pushbox']
49+
[1, 'messages'],
50+
[2, 'messages.sendtab']
4951
])
5052

5153
module.exports = {

0 commit comments

Comments
 (0)