Skip to content

Commit 2bc6c76

Browse files
authored
Merge pull request #104 from HomerSp/work
Fix email and self_entity changing ids server-side. And initial conv list.
2 parents e5dc10b + 3344e4b commit 2bc6c76

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

src/client.coffee

+10
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ module.exports = class Client extends EventEmitter
8888
return Q.reject ABORT
8989
# now intialize the chat using the pvt
9090
@init.initChat @jarstore, pvt
91+
.then =>
92+
@initrecentconversations @init
9193
.then =>
9294
@running = true
9395
@connected = false
@@ -479,6 +481,14 @@ module.exports = class Client extends EventEmitter
479481
], false).then (body) -> # receive as protojson
480482
CLIENT_SYNC_ALL_NEW_EVENTS_RESPONSE.parse body
481483

484+
# Initializes the recent conversations.
485+
initrecentconversations: (init) ->
486+
@chatreq.req('conversations/syncrecentconversations', [
487+
@_requestBodyHeader(),
488+
null
489+
], false).then (body) -> # receive as protojson
490+
data = CLIENT_SYNC_ALL_NEW_EVENTS_RESPONSE.parse body
491+
init.conv_states = data.conversation_state
482492

483493
# Search for people.
484494
searchentities: (search_string, max_results=10) ->

src/init.coffee

+3-2
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,16 @@ module.exports = class Init
7272
# { key: 'ds:3', isError: false, hash: '5', data: [Function] }...
7373
DICT =
7474
apikey: { key:'ds:7', fn: (d) -> d[0][2] }
75-
email: { key:'ds:36', fn: (d) -> d[0][2] }
75+
email: { key:'ds:31', fn: (d) -> d[0][2] }
7676
headerdate: { key:'ds:2', fn: (d) -> d[0][4] }
7777
headerversion: { key:'ds:2', fn: (d) -> d[0][6] }
7878
headerid: { key:'ds:4', fn: (d) -> d[0][7] }
7979
timestamp: { key:'ds:20', fn: (d) -> new Date (d[0][1][4] / 1000) }
80-
self_entity: { key:'ds:21', fn: (d) ->
80+
self_entity: { key:'ds:20', fn: (d) ->
8181
CLIENT_GET_SELF_INFO_RESPONSE.parse(d[0]).self_entity
8282
}
8383
conv_states: { key:'ds:20', fn: (d) ->
84+
# Removed in server-side update
8485
CLIENT_CONVERSATION_STATE_LIST.parse(d[0][3])
8586
}
8687

test/body.html

+1-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@
5858
]
5959
}});</script><script>AF_initDataCallback({key: 'ds:30', isError: false , hash: '27', data:function(){return [["cin:acc","https://myphonenumbers-pa.clients6.google.com"]
6060
]
61-
}});</script><script>AF_initDataCallback({key: 'ds:31', isError: false , hash: '28', data:function(){return [["cic:sc",["AF","DZ","AO","BH","BD","BJ","BF","KH","CM","CG","CD","CI","GH","GU","GN","ID","IQ","IL","JO","KZ","KE","KW","KG","LA","LR","MG","MW","MY","MV","MA","MZ","NE","NG","OM","PK","PS","PH","SA","SN","SC","SL","SO","ZA","LK","TZ","TH","TG","TN","TR","UG","UA","UZ","VN","ZM"]
62-
]
61+
}});</script><script>AF_initDataCallback({key: 'ds:31', isError: false , hash: '37', data:function(){return [["cic:vd","104889609452098951178","[email protected]",0,""]
6362
]
6463
}});</script><script>AF_initDataCallback({key: 'ds:32', isError: false , hash: '29', data:function(){return [["cib:sc",3600,3600,3,600,10]
6564
]

test/test-initparsebody.coffee

-1
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,4 @@ describe 'Init', ->
2222
deql init.headerid, '820F7C523A7BC3A6'
2323
deql init.timestamp, new Date('2016-12-04T22:40:25.771Z')
2424
assert.isNotNull init.self_entity
25-
deql init.conv_states?.length, 3
2625
assert.isNotNull init.entities

0 commit comments

Comments
 (0)