-
Notifications
You must be signed in to change notification settings - Fork 220
Expand file tree
/
Copy pathMuteGroupsExample.java
More file actions
72 lines (63 loc) · 2.13 KB
/
MuteGroupsExample.java
File metadata and controls
72 lines (63 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package io.rong.example.user;
import io.rong.CenterEnum;
import io.rong.RongCloud;
import io.rong.methods.user.mute.MuteGroups;
import io.rong.models.Result;
import io.rong.models.group.GroupMember;
import io.rong.models.group.GroupModel;
import io.rong.models.response.GroupMuteMembersListResult;
/**
*
* Example of muting all group members
* @author RongCloud
*
* @version 3.0.0
*/
public class MuteGroupsExample {
/**
* Replace with your App Key
* */
private static final String appKey = "appKey";
/**
* Replace with your App Secret
* */
private static final String appSecret = "appSecret";
/**
* Local test
*
*
* @throws Exception
*/
public static void main(String[] args) throws Exception {
//RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret);
//Custom API endpoint
RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret, CenterEnum.BJ);
MuteGroups muteGroups = rongCloud.user.muteGroups;
/**
*
* Prevent users from sending messages in all joined groups
*/
GroupMember[] members = {new GroupMember().setId("ghJiu7H1"),new GroupMember().setId("ghJiu7H2")};
GroupModel groupModel = new GroupModel()
.setMembers(members)
.setMinute(5);
Result result = muteGroups.add(groupModel);
System.out.println("group.ban.add: " + result.toString());
/**
*
* Retrieve the list of muted users in all groups
*/
groupModel = new GroupModel()
.setMembers(members);
GroupMuteMembersListResult GroupBanResult = (GroupMuteMembersListResult) muteGroups.getList();
System.out.println("group.ban.getList: " + GroupBanResult.toString());
/**
*
* Remove the mute settings for a user in all groups
*/
groupModel = new GroupModel()
.setMembers(members);
Result groupRollBackGagUserResult = muteGroups.remove(groupModel);
System.out.println("group.ban.remove: " + groupRollBackGagUserResult.toString());
}
}