Skip to content

Commit dcbe36f

Browse files
authored
Merge pull request #132 from jpush/dev
Dev
2 parents 55f57a6 + 34b37c1 commit dcbe36f

File tree

4 files changed

+89
-13
lines changed

4 files changed

+89
-13
lines changed

android/src/io/jchat/android/JMessageModule.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public class JMessageModule extends ReactContextBaseJavaModule {
105105

106106
private Context mContext;
107107
private JMessageUtils mJMessageUtils;
108-
private static HashMap<String, GroupApprovalEvent> groupApprovalEventHashMap;
108+
public static HashMap<String, GroupApprovalEvent> groupApprovalEventHashMap;
109109

110110
public JMessageModule(ReactApplicationContext reactContext, boolean shutdownToast) {
111111
super(reactContext);
@@ -1874,7 +1874,7 @@ public void processApplyJoinGroup(final ReadableMap map, final Callback success,
18741874
Boolean isRespondInviter = map.getBoolean(Constant.IS_RESPOND_INVITER);
18751875
ReadableArray array = map.getArray(Constant.EVENTS);
18761876

1877-
List<GroupApprovalEvent> groupApprovalEventList = new ArrayList<>();
1877+
final List<GroupApprovalEvent> groupApprovalEventList = new ArrayList<>();
18781878

18791879
for (int i = 0; i < array.size(); i++) {
18801880
GroupApprovalEvent groupApprovalEvent = groupApprovalEventHashMap.get(array.getString(i));
@@ -1900,8 +1900,23 @@ public void gotResult(int status, String desc) {
19001900
});
19011901

19021902
} else {
1903-
// 忽略拒绝处理,直接返回成功信息
1904-
mJMessageUtils.handleCallback(0, "", success, fail);
1903+
// 批量处理只有接受,插件做循环单拒绝
1904+
for (int i = 0; i < groupApprovalEventList.size(); i++) {
1905+
GroupApprovalEvent groupApprovalEvent = groupApprovalEventList.get(i);
1906+
final int finalI = i;
1907+
groupApprovalEvent.refuseGroupApproval(groupApprovalEvent.getFromUsername(),
1908+
groupApprovalEvent.getfromUserAppKey(),
1909+
reason,
1910+
new BasicCallback() {
1911+
@Override
1912+
public void gotResult(int status, String desc) {
1913+
// 统一返回最后一个拒绝结果
1914+
if(finalI == groupApprovalEventList.size()-1){
1915+
mJMessageUtils.handleCallback(status, desc, success, fail);
1916+
}
1917+
}
1918+
});
1919+
}
19051920
}
19061921
} catch (Exception e) {
19071922
e.printStackTrace();

document/API.md

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ import JMessage from 'jmessage-react-plugin';
3535
- [dissolveGroup](#dissolvegroup)
3636
- [getGroupIds](#getgroupids)
3737
- [getGroupInfo](#getgroupinfo)
38+
- [updateGroupInfo](#updategroupinfo)
39+
- [addGroupMembers](#addgroupmembers)
40+
- [removeGroupMembers](#removegroupmembers)
3841
- [聊天](#聊天)
3942
- [createSendMessage](#createsendmessage)
4043
- [sendMessage](#sendmessage)
@@ -460,6 +463,71 @@ JMessage.getGroupInfo(
460463

461464
- id(string): 指定群组
462465

466+
### updateGroupInfo
467+
468+
更新群组信息。
469+
470+
#### 示例
471+
472+
```js
473+
JMessage.updateGroupInfo({ id: 'groupId' ,newName: 'group_name', newDesc: 'group_desc' },
474+
() => {
475+
// do something.
476+
477+
}, (error) => {
478+
var code = error.code
479+
var desc = error.description
480+
})
481+
```
482+
483+
#### 参数说明
484+
485+
- id (string): 指定操作的群 groupId
486+
- newName (string): 群组名。不支持 "\n" 和 "\r" 字符,长度限制为 0 ~ 64 Byte。
487+
- newDesc (string): 群组描述。长度限制为 0 ~ 250 Byte。
488+
489+
### addGroupMembers
490+
491+
批量添加群成员
492+
493+
#### 示例
494+
```js
495+
JMessage.addGroupAdmins({ id: 'group_id', usernameArray: ['ex_username1', 'ex_username2'], appKey: 'appkey' },
496+
() => { //
497+
// do something.
498+
499+
}, (error) => {
500+
var code = error.code
501+
var desc = error.description
502+
})
503+
```
504+
505+
#### 参数说明
506+
- id (string): 指定操作的群 groupId
507+
- usernameArray (array<string>): 被添加的的用户名数组。
508+
- appKey: 被添加用户所属应用的 AppKey。如果不填,默认为当前应用。
509+
510+
### removeGroupMembers
511+
512+
批量删除群成员
513+
514+
#### 示例
515+
```js
516+
JMessage.removeGroupMembers({ id: 'group_id', usernameArray: ['ex_username1', 'ex_username2'], appKey: 'appkey' },
517+
() => { //
518+
// do something.
519+
520+
}, (error) => {
521+
var code = error.code
522+
var desc = error.description
523+
})
524+
```
525+
526+
#### 参数说明
527+
- id (string): 指定操作的群 groupId
528+
- usernameArray (array<string>): 被添加的的用户名数组。
529+
- appKey: 被添加用户所属应用的 AppKey。如果不填,默认为当前应用。
530+
463531
### addGroupAdmins
464532

465533
批量添加管理员
@@ -547,7 +615,7 @@ JMessage.getPublicGroupInfos({ appKey: 'my_appkey', start: 0, count: 20 },
547615

548616
#### 示例
549617
```js
550-
JMessage.applyJoinGroup({ appKey: 'group_id', reason: 'Hello I from ...' },
618+
JMessage.applyJoinGroup({ groupId: 'group_id', reason: 'Hello I from ...' },
551619
() => {
552620
// do something.
553621

index.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,15 +1203,8 @@ export default class JMessage {
12031203
static getChatRoomConversationList(callback) {
12041204
JMessageModule.getChatRoomConversationList(callback);
12051205
}
1206-
1207-
12081206

12091207

1210-
1211-
1212-
1213-
1214-
12151208
/**
12161209
* 获取所有会话未读消息总数
12171210
* @param {function} callback = function([{count: number}])

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jmessage-react-plugin",
3-
"version": "2.5.1",
3+
"version": "2.5.3",
44
"description": "a jmessage plugin for react native application",
55
"main": "index.js",
66
"repository": {

0 commit comments

Comments
 (0)