|
26 | 26 | import java.util.List; |
27 | 27 | import java.util.Map; |
28 | 28 |
|
| 29 | +import cn.jpush.im.android.api.ChatRoomManager; |
29 | 30 | import cn.jpush.im.android.api.ContactManager; |
30 | 31 | import cn.jpush.im.android.api.JMessageClient; |
31 | 32 | import cn.jpush.im.android.api.callback.CreateGroupCallback; |
@@ -1829,18 +1830,7 @@ public void gotResult(int status, String desc, Integer integer) { |
1829 | 1830 | void createConversation(JSONArray data, CallbackContext callback) { |
1830 | 1831 | try { |
1831 | 1832 | JSONObject params = data.getJSONObject(0); |
1832 | | - String type = params.getString("type"); |
1833 | | - Conversation conversation = null; |
1834 | | - |
1835 | | - if (type.equals("single")) { |
1836 | | - String username = params.getString("username"); |
1837 | | - String appKey = params.has("appKey") ? params.getString("appKey") : ""; |
1838 | | - conversation = Conversation.createSingleConversation(username, appKey); |
1839 | | - |
1840 | | - } else if (type.equals("group")) { |
1841 | | - String groupId = params.getString("groupId"); |
1842 | | - conversation = Conversation.createGroupConversation(Long.parseLong(groupId)); |
1843 | | - } |
| 1833 | + Conversation conversation = JMessageUtils.createConversation(params); |
1844 | 1834 |
|
1845 | 1835 | if (conversation != null) { |
1846 | 1836 | callback.success(toJson(conversation)); |
@@ -1872,6 +1862,10 @@ void deleteConversation(JSONArray data, CallbackContext callback) { |
1872 | 1862 | long groupId = Long.parseLong(params.getString("groupId")); |
1873 | 1863 | JMessageClient.deleteGroupConversation(groupId); |
1874 | 1864 |
|
| 1865 | + } else if (type.equals("chatRoom")) { |
| 1866 | + long roomId = Long.parseLong(params.getString("roomId")); |
| 1867 | + JMessageClient.deleteChatRoomConversation(roomId); |
| 1868 | + |
1875 | 1869 | } else { |
1876 | 1870 | handleResult(ERR_CODE_PARAMETER, "Conversation type is error", callback); |
1877 | 1871 | return; |
@@ -1972,51 +1966,40 @@ void setConversationExtras(JSONArray data, CallbackContext callback) { |
1972 | 1966 | } |
1973 | 1967 |
|
1974 | 1968 | String extraStr = extra == null ? "" : extra.toString(); |
1975 | | - boolean isSuccess = conversation.updateConversationExtra(extraStr); |
| 1969 | + conversation.updateConversationExtra(extraStr); |
| 1970 | + handleResult(toJson(conversation), 0, null, callback); |
1976 | 1971 | } |
1977 | 1972 |
|
1978 | 1973 | // 聊天会话 - end |
1979 | 1974 |
|
1980 | 1975 | // 聊天室 - start |
1981 | 1976 |
|
1982 | | - void getChatroomInfoListOfApp(JSONArray data, CallbackContext callback) { |
1983 | | - ChatroomHandler.getChatroomInfoListOfApp(data, callback); |
1984 | | - } |
1985 | | - |
1986 | | - void getChatroomInfoListOfUser(JSONArray data, CallbackContext callback) { |
1987 | | - ChatroomHandler.getChatroomInfoListOfUser(data, callback); |
1988 | | - } |
1989 | | - |
1990 | | - void getChatroomInfoListById(JSONArray data, CallbackContext callback) { |
1991 | | - ChatroomHandler.getChatroomInfoListById(data, callback); |
1992 | | - } |
1993 | | - |
1994 | | - void getChatroomOwner(JSONArray data, CallbackContext callback) { |
1995 | | - ChatroomHandler.getChatroomOwner(data, callback); |
| 1977 | + void getChatRoomInfoListOfApp(JSONArray data, CallbackContext callback) { |
| 1978 | + ChatRoomHandler.getChatRoomInfoListOfApp(data, callback); |
1996 | 1979 | } |
1997 | 1980 |
|
1998 | | - void enterChatroom(JSONArray data, CallbackContext callback) { |
1999 | | - ChatroomHandler.enterChatroom(data, callback); |
| 1981 | + void getChatRoomInfoListOfUser(JSONArray data, CallbackContext callback) { |
| 1982 | + ChatRoomHandler.getChatRoomInfoListOfUser(data, callback); |
2000 | 1983 | } |
2001 | 1984 |
|
2002 | | - void exitChatroom(JSONArray data, CallbackContext callback) { |
2003 | | - ChatroomHandler.exitChatroom(data, callback); |
| 1985 | + void getChatRoomInfoListById(JSONArray data, CallbackContext callback) { |
| 1986 | + ChatRoomHandler.getChatRoomInfoListById(data, callback); |
2004 | 1987 | } |
2005 | 1988 |
|
2006 | | - void getChatroomConversation(JSONArray data, CallbackContext callback) { |
2007 | | - ChatroomHandler.getChatroomConversation(data, callback); |
| 1989 | + void getChatRoomOwner(JSONArray data, CallbackContext callback) { |
| 1990 | + ChatRoomHandler.getChatRoomOwner(data, callback); |
2008 | 1991 | } |
2009 | 1992 |
|
2010 | | - void getChatroomConversationList(JSONArray data, CallbackContext callback) { |
2011 | | - ChatroomHandler.getChatroomConversationList(data, callback); |
| 1993 | + void enterChatRoom(JSONArray data, CallbackContext callback) { |
| 1994 | + ChatRoomHandler.enterChatRoom(data, callback); |
2012 | 1995 | } |
2013 | 1996 |
|
2014 | | - void createChatroomConversation(JSONArray data, CallbackContext callback) { |
2015 | | - ChatroomHandler.createChatroomConversation(data, callback); |
| 1997 | + void exitChatRoom(JSONArray data, CallbackContext callback) { |
| 1998 | + ChatRoomHandler.exitChatRoom(data, callback); |
2016 | 1999 | } |
2017 | 2000 |
|
2018 | | - void deleteChatroomConversation(JSONArray data, CallbackContext callback) { |
2019 | | - ChatroomHandler.deleteChatroomConversation(data, callback); |
| 2001 | + void getChatRoomConversationList(JSONArray data, CallbackContext callback) { |
| 2002 | + ChatRoomHandler.getChatRoomConversationList(data, callback); |
2020 | 2003 | } |
2021 | 2004 |
|
2022 | 2005 | // 聊天室 - end |
@@ -2288,7 +2271,7 @@ public void onEvent(ChatRoomMessageEvent event) { |
2288 | 2271 | e.printStackTrace(); |
2289 | 2272 | } |
2290 | 2273 |
|
2291 | | - JSONObject eventJson = toJson("receiveChatroomMessage", result); |
| 2274 | + JSONObject eventJson = toJson("receiveChatRoomMessage", result); |
2292 | 2275 | eventSuccess(eventJson); |
2293 | 2276 | } |
2294 | 2277 |
|
|
0 commit comments