[AC-5716] Cloud.Chats.create with custom_field
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Resolved |
Resolution | Cannot Reproduce |
Resolution Date | 2018-05-20T06:41:09.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | n/a |
Labels | n/a |
Reporter | Emmanuel Francis |
Assignee | Shak Hossain |
Created | 2018-04-27T17:42:00.000+0000 |
Updated | 2018-05-20T06:41:10.000+0000 |
Description
I am trying to create a chat with custom fields as follows
{
message: message,
custom_field:{
"[CUSTOM_chatrooms]chatroom_id":3343
}
};
It creates the chat, but when I query to get chat group as follows it does not return
Cloud.Chats.getChatGroups({
where: {
"[CUSTOM_chatrooms] chatroom_id": 3343
}
},...
Does ACS allow this?
Hello, I believe you have to define chatgroup when creating chats. https://docs.appcelerator.com/arrowdb/latest/#!/api/Chats-method-create Please follow here. Thanks.
chat_group_id won't be available until a chat record is created. chat_group_id is optional. My objective is to create a chat group for the "chat room". So created first chat and passed the room_id, so that later I will pass chat_group_id for future chat message in that "chat room".
Hello, *chat_group_id* Identifies an existing chat group by ID.You must specify either a to_ids list or the chat_group_id for an existing chat group.If you already know the id of a chat group, you can use it to specify which chat group this message should go to. For details please visit this [link](https://docs.appcelerator.com/arrowdb/latest/#!/api/Chats-method-create). Hope this helps. Thanks
You are correct and I did passed the to_ids = ids.join(','), I forgot to mentioned in this ticket. Below is what I passed { message: message, to_ids:ids.join(','), custom_field: { "[CUSTOM_chatrooms]chatroom_id":3343 } };
Here is my full code sample. Please notice the response, chat is created but when I tried to fetch chat group it does not return any record. var Cloud = require('ti.cloud'); var ids = ["5ae4a04500c731a3","5ae424ee48c54b8b"]; Cloud.Chats.create({ to_ids: ids.join(','), message: 'Good morning', custom_field:{ "[CUSTOM_groups]group_id":"abc" } }, function (e) { if(e.success){ Ti.API.info("chat "+ JSON.stringify(e)); // Response 1 Cloud.Chats.getChatGroups({ response_json_depth:2, where: { "[CUSTOM_groups]group_id":"abc" } },function (eg) { Ti.API.info("chat group "+ JSON.stringify(eg)); // Response 2 }); } }); Response 1: {"chats":[{"id":"5ae584378ab","created_at":"2018-04-29T06:06:52+0000"..... // Response 2 chat group {"chat_groups":[],"success":true,"error":false,"meta":{"code":200,"status":"ok","method_name":"getChatGroups"}} NOTE: I have replaced the ids with dummy value above.
Hello [~efrancis], Can you please run the the sample code from [here](https://docs.appcelerator.com/arrowdb/latest/#!/api/Chats-method-get_chat_groups) and let us know how it goes.
The sample code you are referring to or in the documentation does not have where clause. Could you please try my sample above and let me know your result?
Hello [~efrancis], Thanks for your feedback. We are unable to reproduce the issue on our end. Can you please attach a sample test project to reproduce the issue on our end?