Skip to content

Commit 1e9421b

Browse files
author
Bjornskjald
authored
Modified queue creation to receive more delta messages (#65)
2 parents 17f23f0 + 5f37a2c commit 1e9421b

File tree

1 file changed

+51
-13
lines changed

1 file changed

+51
-13
lines changed

src/Client.ts

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -215,29 +215,62 @@ export default class Client extends (EventEmitter as { new(): ClientEmitter }) {
215215
}
216216

217217
private async createQueue (seqId: number) {
218-
const obj = {
219-
delta_batch_size: 125,
220-
max_deltas_able_to_process: 1250,
221-
sync_api_version: 3,
222-
encoding: 'JSON',
223218

219+
// sync_api_version 3: You receive /t_ms payloads as json
220+
// sync_api_version 10: You receiove /t_ms payloads as thrift,
221+
// and connectQueue() does not have to be called.
222+
// Note that connectQueue() should always use 10 instead.
223+
224+
const obj = (
225+
{
224226
initial_titan_sequence_id: seqId,
225-
device_id: this.session.deviceId.deviceId,
227+
delta_batch_size: 125,
228+
device_params: {
229+
image_sizes: {
230+
0: '4096x4096',
231+
4: '312x312',
232+
1: '768x768',
233+
2: '420x420',
234+
3: '312x312'
235+
},
236+
animated_image_format: 'WEBP,GIF',
237+
animated_image_sizes: {
238+
0: '4096x4096',
239+
4: '312x312',
240+
1: '768x768',
241+
2: '420x420',
242+
3: '312x312'
243+
}
244+
},
226245
entity_fbid: this.session.tokens.uid,
227-
246+
sync_api_version: 3, // Must be 3 instead of 10 to receive json payloads
247+
encoding: 'JSON', // Must be removed if using sync_api_version 10
228248
queue_params: {
229-
buzz_on_deltas_enabled: 'false',
249+
// Array of numbers -> Some bitwise encoding scheme -> base64. Numbers range from 0 to 67
250+
// Decides what type of /t_ms delta messages you get. Flags unknown, copy-pasted from app.
251+
client_delta_sync_bitmask: 'Amvr2dBlf7PNgA',
230252
graphql_query_hashes: {
231-
xma_query_id: '10153919431161729'
253+
xma_query_id: '306810703252313'
232254
},
233-
234255
graphql_query_params: {
235-
'10153919431161729': {
236-
xma_id: '<ID>'
256+
306810703252313: {
257+
xma_id: '<ID>',
258+
small_preview_width: 624,
259+
small_preview_height: 312,
260+
large_preview_width: 1536,
261+
large_preview_height: 768,
262+
full_screen_width: 4096,
263+
full_screen_height: 4096,
264+
blur: 0.0,
265+
nt_context: {
266+
styles_id: 'fe1fd5357bb40c81777dc915dfbd6aa4',
267+
pixel_ratio: 3.0
268+
}
237269
}
238270
}
239271
}
240272
}
273+
)
241274

242275
await this.mqttApi.sendPublish(
243276
'/messenger_sync_create_queue',
@@ -246,10 +279,15 @@ export default class Client extends (EventEmitter as { new(): ClientEmitter }) {
246279
}
247280

248281
private async connectQueue (seqId) {
282+
283+
// If createQueue() uses sync_api_version 10, this does not need to be called, and you will not receive json payloads.
284+
// If this does not use sync_api_version 10, you will not receive all messages (e.g. reactions )
285+
// Send the thrift-equivalent payload to /t_ms_gd and you will receive mostly thrift-encoded payloads instead.
286+
249287
const obj = {
250288
delta_batch_size: 125,
251289
max_deltas_able_to_process: 1250,
252-
sync_api_version: 3,
290+
sync_api_version: 10, // Must be 10 to receive some messages
253291
encoding: 'JSON',
254292

255293
last_seq_id: seqId,

0 commit comments

Comments
 (0)