quickblox 2.24.0 → 2.24.1-alpha.0

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.
@@ -44,6 +44,7 @@ NOTICE_KNOWN_MODULE_IDS[noticeConsts.NOTICE_MODULE_IDENTIFIER.UPDATED_MESSAGE] =
44
44
  NOTICE_KNOWN_MODULE_IDS[noticeConsts.NOTICE_MODULE_IDENTIFIER.DELETED_MESSAGE] = true;
45
45
  NOTICE_KNOWN_MODULE_IDS[noticeConsts.NOTICE_MODULE_IDENTIFIER.UPDATED_DIALOG] = true;
46
46
  NOTICE_KNOWN_MODULE_IDS[noticeConsts.NOTICE_MODULE_IDENTIFIER.DELETED_DIALOG] = true;
47
+ NOTICE_KNOWN_MODULE_IDS[noticeConsts.NOTICE_MODULE_IDENTIFIER.CREATED_DIALOG] = true;
47
48
 
48
49
  /**
49
50
  * Cross-env: get all direct child elements of `parent` whose tag name equals
@@ -327,6 +328,91 @@ function _parseCustomData(extraParams) {
327
328
  return out;
328
329
  }
329
330
 
331
+ /**
332
+ * Build a partial QBChatDialog object from a dialog-notice <extraParams>.
333
+ * Shared by NoticeUpdatedDialog and NoticeCreatedDialog (SR-2952) — the server
334
+ * sends a full dialog snapshot in both cases. Fields with null/empty values are
335
+ * omitted by the server, so every read is guarded.
336
+ *
337
+ * CreatedDialog additionally carries created_at/updated_at/user_id (creator) and
338
+ * has no last_message* fields (dialog just created); UpdatedDialog carries
339
+ * last_message* and (per server contract) may also carry created_at/updated_at/
340
+ * user_id. Reading them here for both is safe — absent fields are simply skipped.
341
+ *
342
+ * @param {Element} extraParams
343
+ * @param {String} dialogId - already-resolved dialog_id text.
344
+ * @return {Object} partial dialog snapshot.
345
+ */
346
+ function _parseDialogSnapshot(extraParams, dialogId) {
347
+ var dlg = {};
348
+ dlg._id = dialogId;
349
+
350
+ var name = chatUtils.getElementText(extraParams, 'name');
351
+ if (name !== undefined && name !== null && name !== '') {
352
+ dlg.name = name;
353
+ }
354
+ var photo = chatUtils.getElementText(extraParams, 'photo');
355
+ if (photo !== undefined && photo !== null && photo !== '') {
356
+ dlg.photo = photo;
357
+ }
358
+ var typeText = chatUtils.getElementText(extraParams, 'type');
359
+ var typeNum = parseInt(typeText, 10);
360
+ if (!isNaN(typeNum)) {
361
+ dlg.type = typeNum;
362
+ }
363
+ var occupants = _parseNumericIdsCsv(chatUtils.getElementText(extraParams, 'occupants_ids'));
364
+ if (occupants.length > 0) {
365
+ dlg.occupants_ids = occupants;
366
+ }
367
+ var admins = _parseNumericIdsCsv(chatUtils.getElementText(extraParams, 'admin_ids'));
368
+ if (admins.length > 0) {
369
+ dlg.admin_ids = admins;
370
+ }
371
+ var isJoinReqText = chatUtils.getElementText(extraParams, 'is_join_required');
372
+ if (isJoinReqText !== undefined && isJoinReqText !== null && isJoinReqText !== '') {
373
+ var isJoinReq = parseInt(isJoinReqText, 10);
374
+ dlg.is_join_required = isNaN(isJoinReq) ? isJoinReqText : isJoinReq;
375
+ }
376
+ var roomJid = chatUtils.getElementText(extraParams, 'xmpp_room_jid');
377
+ if (roomJid !== undefined && roomJid !== null && roomJid !== '') {
378
+ // Server may pretty-print xmpp_room_jid with surrounding whitespace.
379
+ dlg.xmpp_room_jid = roomJid.trim();
380
+ }
381
+ var customData = _parseCustomData(extraParams);
382
+ if (customData !== undefined) {
383
+ dlg.custom_data = customData;
384
+ }
385
+ // Creation / modification metadata (present on CreatedDialog; also valid on
386
+ // UpdatedDialog per server contract). Kept as ISO-8601 strings verbatim.
387
+ var createdAt = chatUtils.getElementText(extraParams, 'created_at');
388
+ if (createdAt !== undefined && createdAt !== null && createdAt !== '') {
389
+ dlg.created_at = createdAt;
390
+ }
391
+ var updatedAt = chatUtils.getElementText(extraParams, 'updated_at');
392
+ if (updatedAt !== undefined && updatedAt !== null && updatedAt !== '') {
393
+ dlg.updated_at = updatedAt;
394
+ }
395
+ var userIdText = chatUtils.getElementText(extraParams, 'user_id');
396
+ var userId = parseInt(userIdText, 10);
397
+ if (!isNaN(userId)) {
398
+ dlg.user_id = userId;
399
+ }
400
+ // Last message fields (present on UpdatedDialog; absent on a freshly
401
+ // CreatedDialog — the guards below simply skip them then).
402
+ var lmText = chatUtils.getElementText(extraParams, 'last_message');
403
+ if (lmText) { dlg.last_message = lmText; }
404
+ var lmId = chatUtils.getElementText(extraParams, 'last_message_id');
405
+ if (lmId) { dlg.last_message_id = lmId; }
406
+ var lmDsText = chatUtils.getElementText(extraParams, 'last_message_date_sent');
407
+ var lmDs = parseInt(lmDsText, 10);
408
+ if (!isNaN(lmDs)) { dlg.last_message_date_sent = lmDs; }
409
+ var lmUidText = chatUtils.getElementText(extraParams, 'last_message_user_id');
410
+ var lmUid = parseInt(lmUidText, 10);
411
+ if (!isNaN(lmUid)) { dlg.last_message_user_id = lmUid; }
412
+
413
+ return dlg;
414
+ }
415
+
330
416
  /**
331
417
  * Parse a Notice headline stanza into {type, payload} ready for routing.
332
418
  * Returns null if stanza is not a Notice (no urn:xmpp:notice:0 namespace, or
@@ -422,59 +508,12 @@ function _parseNoticeStanza(stanza) {
422
508
  message: msg
423
509
  };
424
510
  }
425
- } else if (type === IDS.UPDATED_DIALOG) {
426
- // Build a partial QBChatDialog object from extraParams (full server snapshot).
427
- var dlg = {};
428
- dlg._id = dialogId;
429
- var name = chatUtils.getElementText(extraParams, 'name');
430
- if (name !== undefined && name !== null && name !== '') {
431
- dlg.name = name;
432
- }
433
- var photo = chatUtils.getElementText(extraParams, 'photo');
434
- if (photo !== undefined && photo !== null && photo !== '') {
435
- dlg.photo = photo;
436
- }
437
- var typeText = chatUtils.getElementText(extraParams, 'type');
438
- var typeNum = parseInt(typeText, 10);
439
- if (!isNaN(typeNum)) {
440
- dlg.type = typeNum;
441
- }
442
- var occupants = _parseNumericIdsCsv(chatUtils.getElementText(extraParams, 'occupants_ids'));
443
- if (occupants.length > 0) {
444
- dlg.occupants_ids = occupants;
445
- }
446
- var admins = _parseNumericIdsCsv(chatUtils.getElementText(extraParams, 'admin_ids'));
447
- if (admins.length > 0) {
448
- dlg.admin_ids = admins;
449
- }
450
- var isJoinReqText = chatUtils.getElementText(extraParams, 'is_join_required');
451
- if (isJoinReqText !== undefined && isJoinReqText !== null && isJoinReqText !== '') {
452
- var isJoinReq = parseInt(isJoinReqText, 10);
453
- dlg.is_join_required = isNaN(isJoinReq) ? isJoinReqText : isJoinReq;
454
- }
455
- var roomJid = chatUtils.getElementText(extraParams, 'xmpp_room_jid');
456
- if (roomJid !== undefined && roomJid !== null && roomJid !== '') {
457
- dlg.xmpp_room_jid = roomJid;
458
- }
459
- var customData = _parseCustomData(extraParams);
460
- if (customData !== undefined) {
461
- dlg.custom_data = customData;
462
- }
463
- // Last message fields.
464
- var lmText = chatUtils.getElementText(extraParams, 'last_message');
465
- if (lmText) { dlg.last_message = lmText; }
466
- var lmId = chatUtils.getElementText(extraParams, 'last_message_id');
467
- if (lmId) { dlg.last_message_id = lmId; }
468
- var lmDsText = chatUtils.getElementText(extraParams, 'last_message_date_sent');
469
- var lmDs = parseInt(lmDsText, 10);
470
- if (!isNaN(lmDs)) { dlg.last_message_date_sent = lmDs; }
471
- var lmUidText = chatUtils.getElementText(extraParams, 'last_message_user_id');
472
- var lmUid = parseInt(lmUidText, 10);
473
- if (!isNaN(lmUid)) { dlg.last_message_user_id = lmUid; }
474
-
511
+ } else if (type === IDS.UPDATED_DIALOG || type === IDS.CREATED_DIALOG) {
512
+ // Full server dialog snapshot. UpdatedDialog and CreatedDialog (SR-2952)
513
+ // share the same shape; they differ only by moduleIdentifier (routing).
475
514
  payload = {
476
515
  kind: 'dialog',
477
- dialog: dlg
516
+ dialog: _parseDialogSnapshot(extraParams, dialogId)
478
517
  };
479
518
  } else {
480
519
  return null;
@@ -521,6 +560,10 @@ function _routeNoticeEvent(chatProxy, parsed) {
521
560
  if (typeof chatProxy.onDialogUpdatedListener === 'function') {
522
561
  Utils.safeCallbackCall(chatProxy.onDialogUpdatedListener, p.dialog);
523
562
  }
563
+ } else if (type === IDS.CREATED_DIALOG) {
564
+ if (typeof chatProxy.onDialogCreatedListener === 'function') {
565
+ Utils.safeCallbackCall(chatProxy.onDialogCreatedListener, p.dialog);
566
+ }
524
567
  }
525
568
  }
526
569
 
@@ -621,6 +664,15 @@ function ChatProxy(service) {
621
664
  this.onMessageReactionChangedListener = null;
622
665
  this.onDialogDeletedListener = null;
623
666
  this.onDialogUpdatedListener = null;
667
+ /**
668
+ * NoticeCreatedDialog listener (SR-2952). Fired when a Group or Private
669
+ * dialog is created and the current user has the Notice feature enabled.
670
+ * Signature: onDialogCreatedListener(dialog). The dialog is a partial
671
+ * snapshot from the creation notice — it carries created_at/updated_at/
672
+ * user_id (creator) but no last_message* fields (the dialog is brand new),
673
+ * and for a private dialog no xmpp_room_jid. Not fired for Public dialogs.
674
+ */
675
+ this.onDialogCreatedListener = null;
624
676
 
625
677
  // [QC-1550] XMPP connection is considered "verified" only after the first
626
678
  // successful pong response. Strophe emits Status.CONNECTED at the transport
@@ -2465,7 +2517,8 @@ ChatProxy.prototype = {
2465
2517
  * Subscribe the current XMPP session to Notice Feature stanzas
2466
2518
  * (urn:xmpp:notice:0). After a successful IQ result the server starts
2467
2519
  * delivering NoticeUpdatedMessage / NoticeDeletedMessage /
2468
- * NoticeUpdatedDialog / NoticeDeletedDialog headline stanzas.
2520
+ * NoticeCreatedDialog / NoticeUpdatedDialog / NoticeDeletedDialog
2521
+ * headline stanzas.
2469
2522
  *
2470
2523
  * The local enabled flag is reset to false on chat disconnect — consumers
2471
2524
  * must call enableNotices() again after a reconnect (intentional divergence
@@ -23,7 +23,8 @@ var NOTICE_MODULE_IDENTIFIER = {
23
23
  UPDATED_MESSAGE: 'NoticeUpdatedMessage',
24
24
  DELETED_MESSAGE: 'NoticeDeletedMessage',
25
25
  UPDATED_DIALOG: 'NoticeUpdatedDialog',
26
- DELETED_DIALOG: 'NoticeDeletedDialog'
26
+ DELETED_DIALOG: 'NoticeDeletedDialog',
27
+ CREATED_DIALOG: 'NoticeCreatedDialog'
27
28
  };
28
29
 
29
30
  module.exports = {
package/src/qbConfig.js CHANGED
@@ -12,8 +12,8 @@
12
12
  */
13
13
 
14
14
  var config = {
15
- version: '2.24.0',
16
- buildNumber: '1180',
15
+ version: '2.24.1-alpha.0',
16
+ buildNumber: '1181',
17
17
  creds: {
18
18
  'appId': 0,
19
19
  'authKey': '',