Closed Krishna8077078 closed 3 years ago
@Krishna8077078
Contacts are from your phone contact book (its were created by you). You are able to post/update/get/delete the contact's book via API.
Connectycube user is creating by each new user. It isn't expect that contact's name and user's name are match.
A private dialog's name depends on the opponent's full_name
(user_A sees user_B's name and vice versa).
Try to match contact's phone number
with user phone
and user id
with dialog's occupants_ids
array.
const userPhoneNumber = someContact.phone;
const user = await ConnectyCube.users.get({ phone: userPhoneNumber })); // get Connectycube user by phone number
const dialogsListResponse = await ConnectyCube.chat.dialog.list({ type: 3, name: user.full_name }); // get a response with private dialogs and matched name from server
const dialogs = dialogsListResponse.items; // dialogs from the response
const dialog = dialogs.find(dialog => dialog.occupants_ids.some(id => (id === user.id))); // find the dialogs
// or try this:
const userPhoneNumber = someContact.phone;
const user = await ConnectyCube.users.get({ phone: userPhoneNumber }));
const dialogsListResponse = await ConnectyCube.chat.dialog.list({ type: 3, occupants_ids: { in: user.id } });
const dialogs = dialogsListResponse.items[0];
How to filter dialog user name with phonebook contact name is this possible??