ConnectyCube / connectycube-flutter-samples

Code samples for Flutter, based on ConnectyCube platform
https://developers.connectycube.com/flutter/
Apache License 2.0
85 stars 90 forks source link

Multiple Calls to createDialog(..) with the Same Values (You and John, Private) Create New Dialogs? #291

Closed jostney closed 1 year ago

jostney commented 1 year ago

We've recently started receiving reports from our users about encountering the issue of 'Sometimes I don't see messages.' This question is being raised to address this problem.

In a scenario involving three screens:

ExploreUsersScreen: A list of random users
ChatDialogsScreen: A list of dialogs from previous conversations
ChatScreen: A screen for one-on-one chat conversations

And the possible navigations:

ExploreUsersScreen --> ChatScreen
ChatDialogsScreen --> ChatScreen

Here's the situation: Imagine you've just installed the app, and initially, you have no ongoing conversations. You then select a user (John) from the ExploreUsersScreen, which takes you to the ChatScreen. The following code is executed successfully, allowing you to send and receive messages. Everything seems to be working fine:

await createDialog(CubeDialog(
    CubeDialogType.PRIVATE,
    occupantsIds: [John's ID],
));

Now, if you navigate to the ChatDialogsScreen, you can see the dialog with John:

final dialogs = await getDialogs(additionalParams);
final dialogWithJohn = dialogs.items[0];

However, an issue arises after some time. Let's assume you choose John again from the ExploreUsersScreen. The same createDialog(...) method is executed again, but this time it creates a new dialog:

// A new dialog is created..
await createDialog(CubeDialog(
    CubeDialogType.PRIVATE,
    occupantsIds: [John's ID],
));

This behavior results in the creation of multiple dialogs for the same user, causing the 'Sometimes I don't see messages' problem.

TatankaConCube commented 1 year ago

hmmm... could you please try to reproduce this issue on your side and collect the full log from your app? please don't cut and don't filter logs, provide them in view as you can get in the log console. The provided pieces of code should work as you described, the previously created private dialog should be returned.

jostney commented 1 year ago

ChatDialogsScreen --> ChatScreen

Working[GoRouter] pushing /chat
[+12500 ms] flutter: CB-SDK: : =========================================================
[        ] flutter: === REQUEST ==== a17982fa-93ce-442e-8fd4-d60d7d00c9b7 ===
[        ] flutter: REQUEST
[        ] flutter:   GET https://api.connectycube.com/chat/Message?chat_dialog_id=64dc6d801bc1bcaf73573cde&limit=50&skip=0&sort_desc=date_sent
[        ] flutter: HEADERS
[        ] flutter:   {Content-type: application/json, ConnectyCube-REST-API-Version: 0.1.1, CB-SDK: Flutter 2.7.1, CB-Token: 9A8F4CB0E4012D09C0B7B52F628A2CDC0BCF}
[        ] flutter: BODY
[        ] flutter:
[        ] flutter:
[ +209 ms] 10.12.0 - [FirebaseAnalytics][I-ACS023051] Logging event: origin, name, params: am, adunit_exposure (_xu), {
[        ]     ad_unit_id (_ai) = ca-app-pub-3940256099942544/2934735716;
[        ]     exposure_time (_xt) = 21512;
[        ]     ga_event_origin (_o) = am;
[        ]     ga_screen_class (_sc) = FlutterViewController;
[        ]     ga_screen_id (_si) = -5635390968912678819;
[        ] }
[        ] 10.12.0 - [FirebaseAnalytics][I-ACS023073] Debug mode is enabled. Marking event as debug and real-time. Event name, parameters: adunit_exposure (_xu), {
[        ]     ad_unit_id (_ai) = ca-app-pub-3940256099942544/2934735716;
[        ]     exposure_time (_xt) = 21512;
[        ]     ga_debug (_dbg) = 1;
[        ]     ga_event_origin (_o) = am;
[        ]     ga_realtime (_r) = 1;
[   +6 ms]     ga_screen_class (_sc) = FlutterViewController;
[        ]     ga_screen_id (_si) = -5635390968912678819;
[        ] }
[   +4 ms] 10.12.0 - [FirebaseAnalytics][I-ACS023072] Event logged. Event name, event params: adunit_exposure (_xu), {
[        ]     ad_unit_id (_ai) = ca-app-pub-3940256099942544/2934735716;
[        ]     exposure_time (_xt) = 21512;
[        ]     ga_debug (_dbg) = 1;
[        ]     ga_event_origin (_o) = am;
[        ]     ga_realtime (_r) = 1;
[        ]     ga_screen_class (_sc) = FlutterViewController;
[        ]     ga_screen_id (_si) = -5635390968912678819;
[        ] }
[        ] 10.12.0 - [FirebaseAnalytics][I-ACS002002] Measurement timer scheduled to fire in approx. (s): 0.9844779968261719
[        ] 10.12.0 - [FirebaseAnalytics][I-ACS023051] Logging event: origin, name, params: am, ad_exposure (_xa), {
[        ]     exposure_time (_xt) = 21512;
[        ]     ga_event_origin (_o) = am;
[        ]     ga_screen_class (_sc) = FlutterViewController;
[        ]     ga_screen_id (_si) = -5635390968912678819;
[        ] }
[        ] 10.12.0 - [FirebaseAnalytics][I-ACS023073] Debug mode is enabled. Marking event as debug and real-time. Event name, parameters: ad_exposure (_xa), {
[        ]     exposure_time (_xt) = 21512;
[        ]     ga_debug (_dbg) = 1;
[        ]     ga_event_origin (_o) = am;
[        ]     ga_realtime (_r) = 1;
[        ]     ga_screen_class (_sc) = FlutterViewController;
[        ]     ga_screen_id (_si) = -5635390968912678819;
[        ] }
[   +1 ms] 10.12.0 - [FirebaseAnalytics][I-ACS023072] Event logged. Event name, event params: ad_exposure (_xa), {
[        ]     exposure_time (_xt) = 21512;
[        ]     ga_debug (_dbg) = 1;
[        ]     ga_event_origin (_o) = am;
[        ]     ga_realtime (_r) = 1;
[        ]     ga_screen_class (_sc) = FlutterViewController;
[        ]     ga_screen_id (_si) = -5635390968912678819;
[        ] }
[log] ---Xmpp Sending:---
[log] <r xmlns="urn:xmpp:sm:3"/>
[log] ---Xmpp Receiving:---
[log] <a xmlns='urn:xmpp:sm:3' h='7'/>
[ +583 ms] flutter: CB-SDK: : *********************************************************
[        ] flutter: *** RESPONSE *** 200 *** a17982fa-93ce-442e-8fd4-d60d7d00c9b7 ***
[        ] flutter: HEADERS
[  +13 ms] flutter:   {cb-token-expirationdate: 2023-08-25 16:03:08 UTC, connection: keep-alive, date: Fri, 25 Aug 2023 14:03:08 GMT, strict-transport-security: max-age=15768000; includeSubDomains, content-length: 2720, access-control-expose-headers: CB-Token-ExpirationDate, Date, content-type: application/json; charset=utf-8, server: nginx/1.25.0}
[        ] flutter: BODY
[        ] flutter:   {"skip":0,"limit":50,"items":[{"_id":"64e2d708d51fcd3981b7a0d4","chat_dialog_id":"64dc6d801bc1bcaf73573cde","message":"I cannot read your messages","date_sent":1692587784,"sender_id":10011894,"recipient_id":7002326,"created_at":"2023-08-21T03:16:24Z","updated_at":"2023-08-23T23:47:12Z","read_ids":[10011894,7002326],"delivered_ids":[10011894,7002326],"reactions":null,"views_count":0,"attachments":[],"edited_at":null,"read":1},{"_id":"64e2be86f737402f4438efeb","chat_dialog_id":"64dc6d801bc1bcaf73573cde","message":"my internet bed","date_sent":1692581510,"sender_id":7002326,"recipient_id":10011894,"created_at":"2023-08-21T01:31:50Z","updated_at":"2023-08-23T23:47:12Z","read_ids":[7002326],"delivered_ids":[7002326,10011894],"reactions":null,"views_count":0,"attachments":[],"edited_at":null,"read":0},{"_id":"64e2be71f737402f4438efea","chat_dialog_id":"64dc6d801bc1bcaf73573cde","message":"hello ","date_sent":1692581490,"sender_id":7002326,"recipient_id":10011894,"created_at":"2023-08-21T01:31:29Z","updated_at":"2023-08-23T23:47:12Z","read_ids":[7002326],"delivered_ids":[7002326,10011894],"reactions":null,"views_count":0,"attachments":[],"edited_at":null,"read":0},{"_id":"64e2bc43290547eea1348805","chat_dialog_id":"64dc6d801bc1bcaf73573cde","message":"where are you from ","date_sent":1692580931,"sender_id":7002326,"recipient_id":10011894,"created_at":"2023-08-21T01:22:11Z","updated_at":"2023-08-23T23:47:12Z","read_ids":[7002326],"delivered_ids":[7002326,10011894],"reactions":null,"views_count":0,"attachments":[],"edited_at":null,"read":0},{"_id":"64e24b6cf7eeb4bb1ddbc17e","chat_dialog_id":"64dc6d801bc1bcaf73573cde","message":"Hello","date_sent":1692552044,"sender_id":10011894,"recipient_id":7002326,"created_at":"2023-08-20T17:20:44Z","updated_at":"2023-08-23T23:47:12Z","read_ids":[10011894,7002326],"delivered_ids":[10011894,7002326],"reactions":null,"views_count":0,"attachments":[],"edited_at":null,"read":1},{"_id":"64e1fca30368a38598c3104e","chat_dialog_id":"64dc6d801bc1bcaf73573cde","message":"hi","date_sent":1692531876,"sender_id":7002326,"recipient_id":10011894,"created_at":"2023-08-20T11:44:35Z","updated_at":"2023-08-23T23:47:12Z","read_ids":[7002326],"delivered_ids":[7002326,10011894],"reactions":null,"views_count":0,"attachments":[],"edited_at":null,"read":0},{"_id":"64dc6d7fb303d4f42c25ba99","chat_dialog_id":"64dc6d801bc1bcaf73573cde","message":"Hello. Just curious, from what country are you?","date_sent":1692167552,"sender_id":10011894,"recipient_id":7002326,"created_at":"2023-08-16T06:32:32Z","updated_at":"2023-08-23T23:47:12Z","read_ids":[10011894,7002326],"delivered_ids":[10011894,7002326],"reactions":null,"views_count":0,"attachments":[],"edited_at":null,"read":1}]}
[        ] flutter:
[ +423 ms] 10.12.0 - [FirebaseAnalytics][I-ACS002001] Measurement timer fired
[        ] 10.12.0 - [FirebaseAnalytics][I-ACS002003] Measurement timer canceled
[   +2 ms] 10.12.0 - [FirebaseAnalytics][I-ACS023105] Event is not subject to real-time event count daily limit. Marking an event as real-time. Event name, parameters: adunit_exposure (_xu), {
[        ]     ad_unit_id (_ai) = ca-app-pub-3940256099942544/2934735716;
[        ]     exposure_time (_xt) = 21512;
[        ]     ga_debug (_dbg) = 1;
[        ]     ga_event_origin (_o) = am;
[        ]     ga_realtime (_r) = 1;
[        ]     ga_screen_class (_sc) = FlutterViewController;
[   +1 ms]     ga_screen_id (_si) = -5635390968912678819;
[        ] }
[        ] 10.12.0 - [FirebaseAnalytics][I-ACS023105] Event is not subject to real-time event count daily limit. Marking an event as real-time. Event name, parameters: ad_exposure (_xa), {
[        ]     exposure_time (_xt) = 21512;
[        ]     ga_debug (_dbg) = 1;
[        ]     ga_event_origin (_o) = am;
[        ]     ga_realtime (_r) = 1;
[        ]     ga_screen_class (_sc) = FlutterViewController;
[        ]     ga_screen_id (_si) = -5635390968912678819;
[        ] }
[  +10 ms] 10.12.0 - [FirebaseAnalytics][I-ACS012018] Saving bundle. size (bytes): 541
[        ] 10.12.0 - [FirebaseAnalytics][I-ACS023116] Bundle added to the upload queue. BundleID, timestamp (ms): 822, 1692972187851
[  +24 ms] 10.12.0 - [FirebaseAnalytics][I-ACS023039] Measurement data sent to network. Timestamp (ms), data: 1692972188930, <APMPBMeasurementBatch: 0x2836bb130>
[   +4 ms] 10.12.0 - [FirebaseAnalytics][I-ACS900000] Uploading data. Host: https://app-measurement.com/a
[ +213 ms] 10.12.0 - [FirebaseAnalytics][I-ACS901006] Received SSL challenge for host. Host: https://app-measurement.com/a
[ +160 ms] 10.12.0 - [FirebaseAnalytics][I-ACS023044] Successful upload. Got network response. Code, size: 204, 0
[   +2 ms] 10.12.0 - [FirebaseAnalytics][I-ACS002002] Measurement timer scheduled to fire in approx. (s): -0.4606239795684814
[   +9 ms] 10.12.0 - [FirebaseAnalytics][I-ACS002003] Measurement timer canceled
[+1634 ms] [connection] nw_resolver_start_query_timer_block_invoke [C39.1.1] Query fired: did not receive all answers in time for app-measurement.com:443
[log] ---Xmpp Sending:---
[log] <r xmlns="urn:xmpp:sm:3"/>
[log] ---Xmpp Receiving:---
[log] <a xmlns='urn:xmpp:sm:3' h='7'/>
[+3313 ms] Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service
[log] ---Xmpp Sending:---
[log] <r xmlns="urn:xmpp:sm:3"/>
[log] ---Xmpp Receiving:---
[log] <a xmlns='urn:xmpp:sm:3' h='7'/>
jostney commented 1 year ago

ExploreUsersScreen --> ChatScreen (problem)

[GoRouter] pushing /chat
[+55825 ms] flutter: CB-SDK: : =========================================================
[        ] flutter: === REQUEST ==== 0cfd5e47-4b27-4773-8071-e6ae0841f6d7 ===
[        ] flutter: REQUEST
[        ] flutter:   POST https://api.connectycube.com/chat/Dialog
[        ] flutter: HEADERS
[        ] flutter:   {Content-type: application/json, ConnectyCube-REST-API-Version: 0.1.1, CB-SDK: Flutter 2.7.1, CB-Token: 9A8F4CB0E4012D09C0B7B52F628A2CDC0BCF}
[        ] flutter: BODY
[        ] flutter:   {"type":3,"occupants_ids":[10011894]}
[        ] flutter:
[ +280 ms] 10.12.0 - [FirebaseAnalytics][I-ACS023051] Logging event: origin, name, params: am, adunit_exposure (_xu), {
[        ]     ad_unit_id (_ai) = ca-app-pub-3940256099942544/2934735716;
[        ]     exposure_time (_xt) = 13816;
[        ]     ga_event_origin (_o) = am;
[        ]     ga_screen_class (_sc) = FlutterViewController;
[        ]     ga_screen_id (_si) = -5635390968912678819;
[        ] }
[        ] 10.12.0 - [FirebaseAnalytics][I-ACS023073] Debug mode is enabled. Marking event as debug and real-time. Event name, parameters: adunit_exposure (_xu), {
[        ]     ad_unit_id (_ai) = ca-app-pub-3940256099942544/2934735716;
[        ]     exposure_time (_xt) = 13816;
[        ]     ga_debug (_dbg) = 1;
[        ]     ga_event_origin (_o) = am;
[        ]     ga_realtime (_r) = 1;
[        ]     ga_screen_class (_sc) = FlutterViewController;
[        ]     ga_screen_id (_si) = -5635390968912678819;
[        ] }
[  +31 ms] 10.12.0 - [FirebaseAnalytics][I-ACS023072] Event logged. Event name, event params: adunit_exposure (_xu), {
[        ]     ad_unit_id (_ai) = ca-app-pub-3940256099942544/2934735716;
[        ]     exposure_time (_xt) = 13816;
[        ]     ga_debug (_dbg) = 1;
[        ]     ga_event_origin (_o) = am;
[        ]     ga_realtime (_r) = 1;
[        ]     ga_screen_class (_sc) = FlutterViewController;
[        ]     ga_screen_id (_si) = -5635390968912678819;
[        ] }
[        ] 10.12.0 - [FirebaseAnalytics][I-ACS002002] Measurement timer scheduled to fire in approx. (s): 0.9555227756500244
[   +1 ms] 10.12.0 - [FirebaseAnalytics][I-ACS023051] Logging event: origin, name, params: am, ad_exposure (_xa), {
[        ]     exposure_time (_xt) = 13816;
[        ]     ga_event_origin (_o) = am;
[        ]     ga_screen_class (_sc) = FlutterViewController;
[        ]     ga_screen_id (_si) = -5635390968912678819;
[        ] }
[   +1 ms] 10.12.0 - [FirebaseAnalytics][I-ACS023073] Debug mode is enabled. Marking event as debug and real-time. Event name, parameters: ad_exposure (_xa), {
[        ]     exposure_time (_xt) = 13816;
[        ]     ga_debug (_dbg) = 1;
[        ]     ga_event_origin (_o) = am;
[        ]     ga_realtime (_r) = 1;
[        ]     ga_screen_class (_sc) = FlutterViewController;
[        ]     ga_screen_id (_si) = -5635390968912678819;
[        ] }
[   +4 ms] 10.12.0 - [FirebaseAnalytics][I-ACS023072] Event logged. Event name, event params: ad_exposure (_xa), {
[        ]     exposure_time (_xt) = 13816;
[        ]     ga_debug (_dbg) = 1;
[        ]     ga_event_origin (_o) = am;
[        ]     ga_realtime (_r) = 1;
[        ]     ga_screen_class (_sc) = FlutterViewController;
[        ]     ga_screen_id (_si) = -5635390968912678819;
[        ] }
[ +436 ms] flutter: CB-SDK: : *********************************************************
[        ] flutter: *** RESPONSE *** 201 *** 0cfd5e47-4b27-4773-8071-e6ae0841f6d7 ***
[        ] flutter: HEADERS
[   +1 ms] flutter:   {cb-token-expirationdate: 2023-08-25 16:09:40 UTC, connection: keep-alive, date: Fri, 25 Aug 2023 14:09:40 GMT, strict-transport-security: max-age=15768000; includeSubDomains, content-length: 501, access-control-expose-headers: CB-Token-ExpirationDate, Date, content-type: application/json; charset=utf-8, server: nginx/1.25.0}
[        ] flutter: BODY
[        ] flutter:   {"_id":"64dc6d54558c7f00184a8929","user_id":10011894,"created_at":"2023-08-16T06:31:48Z","updated_at":"2023-08-16T06:31:48Z","name":"lelinapat14@gmail.com","type":3,"photo":null,"occupants_ids":[10011894,7002326],"occupants_count":2,"is_e2ee":false,"is_muted":false,"last_message":null,"last_message_date_sent":null,"last_message_id":null,"last_message_user_id":null,"last_message_status":null,"unread_messages_count":0,"pinned_messages_ids":[],"description":null,"xmpp_room_jid":null,"admins_ids":[]}
[        ] flutter:
[   +2 ms] flutter: CB-SDK: : =========================================================
[        ] flutter: === REQUEST ==== b04bc149-1cdc-4c19-af9b-9f3967af054a ===
[        ] flutter: REQUEST
[        ] flutter:   GET https://api.connectycube.com/chat/Message?chat_dialog_id=64dc6d54558c7f00184a8929&limit=50&skip=0&sort_desc=date_sent
[        ] flutter: HEADERS
[   +2 ms] flutter:   {Content-type: application/json, ConnectyCube-REST-API-Version: 0.1.1, CB-SDK: Flutter 2.7.1, CB-Token: 9A8F4CB0E4012D09C0B7B52F628A2CDC0BCF}
[        ] flutter: BODY
[        ] flutter:
[        ] flutter:
[ +517 ms] 10.12.0 - [FirebaseAnalytics][I-ACS002001] Measurement timer fired
[        ] 10.12.0 - [FirebaseAnalytics][I-ACS002003] Measurement timer canceled
[   +3 ms] 10.12.0 - [FirebaseAnalytics][I-ACS023105] Event is not subject to real-time event count daily limit. Marking an event as real-time. Event name, parameters: adunit_exposure (_xu), {
[        ]     ad_unit_id (_ai) = ca-app-pub-3940256099942544/2934735716;
[        ]     exposure_time (_xt) = 13816;
[        ]     ga_debug (_dbg) = 1;
[        ]     ga_event_origin (_o) = am;
[        ]     ga_realtime (_r) = 1;
[        ]     ga_screen_class (_sc) = FlutterViewController;
[        ]     ga_screen_id (_si) = -5635390968912678819;
[        ] }
[        ] 10.12.0 - [FirebaseAnalytics][I-ACS023105] Event is not subject to real-time event count daily limit. Marking an event as real-time. Event name, parameters: ad_exposure (_xa), {
[        ]     exposure_time (_xt) = 13816;
[        ]     ga_debug (_dbg) = 1;
[        ]     ga_event_origin (_o) = am;
[        ]     ga_realtime (_r) = 1;
[        ]     ga_screen_class (_sc) = FlutterViewController;
[        ]     ga_screen_id (_si) = -5635390968912678819;
[        ] }
[  +11 ms] 10.12.0 - [FirebaseAnalytics][I-ACS012018] Saving bundle. size (bytes): 536
[        ] 10.12.0 - [FirebaseAnalytics][I-ACS023116] Bundle added to the upload queue. BundleID, timestamp (ms): 825, 1692972580213
[  +29 ms] 10.12.0 - [FirebaseAnalytics][I-ACS023039] Measurement data sent to network. Timestamp (ms), data: 1692972581274, <APMPBMeasurementBatch: 0x2836ab3a0>
[  +13 ms] 10.12.0 - [FirebaseAnalytics][I-ACS900000] Uploading data. Host: https://app-measurement.com/a
[  +17 ms] flutter: CB-SDK: : *********************************************************
[        ] flutter: *** RESPONSE *** 200 *** b04bc149-1cdc-4c19-af9b-9f3967af054a ***
[        ] flutter: HEADERS
[        ] flutter:   {cb-token-expirationdate: 2023-08-25 16:09:41 UTC, connection: keep-alive, date: Fri, 25 Aug 2023 14:09:41 GMT, strict-transport-security: max-age=15768000; includeSubDomains, content-length: 32, access-control-expose-headers: CB-Token-ExpirationDate, Date, content-type: application/json; charset=utf-8, server: nginx/1.25.0}
[        ] flutter: BODY
[        ] flutter:   {"skip":0,"limit":50,"items":[]}
[        ] flutter:
[ +160 ms] 10.12.0 - [FirebaseAnalytics][I-ACS901006] Received SSL challenge for host. Host: https://app-measurement.com/a
[ +117 ms] 10.12.0 - [FirebaseAnalytics][I-ACS023044] Successful upload. Got network response. Code, size: 204, 0
[   +1 ms] 10.12.0 - [FirebaseAnalytics][I-ACS002002] Measurement timer scheduled to fire in approx. (s): -0.3752399682998657
[  +10 ms] 10.12.0 - [FirebaseAnalytics][I-ACS002003] Measurement timer canceled
[log] ---Xmpp Sending:---
[log] <r xmlns="urn:xmpp:sm:3"/>
[+1715 ms] [connection] nw_resolver_start_query_timer_block_invoke [C47.1.1] Query fired: did not receive all answers in time for app-measurement.com:443
[log] ---Xmpp Receiving:---
[log] <a xmlns='urn:xmpp:sm:3' h='7'/>
TatankaConCube commented 1 year ago

hmmm... it is strange, looks like you have a few private dialogs with the same users

could you please print to the log the full list of items you receive in this part of code and share here

final dialogs = await getDialogs(additionalParams); final dialogWithJohn = dialogs.items[0];

jostney commented 1 year ago

A sample user id of having problem : 10011894

final Map<String, dynamic> additionalParams = {'limit': limit, 'skip': skip};
final dialogs = await getDialogs(additionalParams);
var dialogsOf10011894 = dialogs?.items.where((e) => e.occupantsIds?.contains(10011894) == true).toList();
image

Seems connectycube backend created two private dialogs with 10011894

TatankaConCube commented 1 year ago

are these dialogs new or old? what is created_at field?

jostney commented 1 year ago
[
   {
      "_id":64dc6d801bc1bcaf73573cde,
      "last_message":"I cannot read your messages",
      "last_message_date_sent":1692587784,
      "last_message_user_id":10011894,
      "photo":null,
      "user_id":10011894,
      "xmpp_room_jid":null,
      "unread_messages_count":0,
      "name":XXXXXXXXXX
      "type":3,
      "description":null,
      "occupants_count":null,
      "occupants_ids":[
         7002326,
         10011894
      ],
      "pinned_messages_ids":null,
      "admins_ids":[

      ],
      "data":null,
      "last_message_status":null,
      "last_message_id":64e2d708d51fcd3981b7a0d4,
      "is_e2ee":null,
      "is_muted":false,
      "id":null,
      "created_at":"2023-08-16T06":"32":32.000Z,
      "updated_at":"2023-08-21T03":"16":24.000Z
   },
   {
      "_id":64dc6d54558c7f00184a8929,
      "last_message":null,
      "last_message_date_sent":null,
      "last_message_user_id":null,
      "photo":null,
      "user_id":10011894,
      "xmpp_room_jid":null,
      "unread_messages_count":0,
      "name":XXXXXXXXXX,
      "type":3,
      "description":null,
      "occupants_count":2,
      "occupants_ids":[
         10011894,
         7002326
      ],
      "pinned_messages_ids":[

      ],
      "admins_ids":[

      ],
      "data":null,
      "last_message_status":null,
      "last_message_id":null,
      "is_e2ee":false,
      "is_muted":false,
      "id":null,
      "created_at":"2023-08-16T06":"31":48.000Z,
      "updated_at":"2023-08-16T06":"31":48.000Z
   }
TatankaConCube commented 1 year ago

could you please provide a full log with reproducing the bug process? looks like you have some cases when your app creates a few private dialogs. it is impossible in the common flow and we cant reproduce it on our side

TatankaConCube commented 1 year ago

is it possible that you send two requests at the same time asynchronously (without waiting for the result of the first one)? I reproduced it only in this case and in case the user hasn't had a private dialog with this user before.

jostney commented 1 year ago

It appears that there might be a backend issue at play here. I haven't reinvented anything; the only action I've taken or am taking is:

await createDialog(CubeDialog(
    CubeDialogType.PRIVATE,
    occupantsIds: [John's ID],
));

Another possibility is that both of these individuals simply wanted to chat at the same time. Let's consider a scenario involving John and Angeline:

await createDialog(CubeDialog(
    CubeDialogType.PRIVATE,
    occupantsIds: [Angeline's ID],
));
await createDialog(CubeDialog(
    CubeDialogType.PRIVATE,
    occupantsIds: [John's ID],
));

However, this scenario isn't feasible :)

TatankaConCube commented 1 year ago

could you please provide the full log (without any cutting or filtering) with the creation of a new private dialog and chatting there? please try to create a new dialog with a user with whom you haven't had any private chats before, the better way for reproducing the issue is to use two new users. if have any personal information in your logs, you can send the log to our support team e-mail support@connectycube.com

TatankaConCube commented 1 year ago

@jostney our back-end team prepared the fix but we need to check it first, could you provide steps for reproducing cause we can't reproduce it on our side?

also, the back-end team can delete duplicate dialogs without messages for your app, can we do it?

jostney commented 1 year ago

@TatankaConCube I caught the issue!

Part1

// A dialog is created with Elisa
await createDialog(CubeDialog(
    CubeDialogType.PRIVATE,
    occupantsIds: [Elisa's ID],
));
// A dialog is created with Elisa
await createDialog(CubeDialog(
    CubeDialogType.PRIVATE,
    occupantsIds: [Elisa's ID],
));

✅ Until this point everything is worked as expected

  Map<String, dynamic> additionalParams = {'limit': limit, 'skip': skip};
  var dialogs = await getDialogs(additionalParams);

❌ A new dialog(dialog id 64f7573b1bc1bcaf737edd57) with Elisa returned.

jostney commented 1 year ago

Part 2

// A dialog is created with Elisa
await createDialog(CubeDialog(
    CubeDialogType.PRIVATE,
    occupantsIds: [Elisa's ID],
));

We can say create dialog keeps returning 64f756bcd99a1e002f5aee8d, but with zero messages. Messages are stored in dialog 64f7573b1bc1bcaf737edd57 If send message on dialog 64f756bcd99a1e002f5aee8d, the message is appears on 64f7573b1bc1bcaf737edd57

jostney commented 1 year ago

Sure the duplicated dialogs can be deleted

TatankaConCube commented 1 year ago

Hi @jostney, the back-end team reported that they have updated the API Server and Chat Server. Also, they have deleted the duplicated dialogs without messages for your app. Could you please recheck the issue on your side again?

jostney commented 1 year ago

Hi @TatankaConCube

✅ The issue seems fixed! I didn't face with it again.