Skip to content

Commit 037d260

Browse files
committed
feat: add group api
1 parent 22ae62b commit 037d260

21 files changed

+592
-51
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ If you're using Maven, just add the following dependency in `pom.xml`.
2525
<dependency>
2626
<groupId>io.github.doocs</groupId>
2727
<artifactId>im-server-sdk-java</artifactId>
28-
<version>0.4.10</version>
28+
<version>0.4.11</version>
2929
</dependency>
3030
```
3131

README_CN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ https://doocs.github.io/qcloud-im-server-sdk-java
2525
<dependency>
2626
<groupId>io.github.doocs</groupId>
2727
<artifactId>im-server-sdk-java</artifactId>
28-
<version>0.4.10</version>
28+
<version>0.4.11</version>
2929
</dependency>
3030
```
3131

docs/guide/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 介绍
22

3-
本文档基于腾讯云 IM Server SDK Java <Badge type="tip" text="v0.4.10" vertical="top" /> 编写。
3+
本文档基于腾讯云 IM Server SDK Java <Badge type="tip" text="v0.4.11" vertical="top" /> 编写。
44

55
## 前提条件
66

docs/guide/group.md

+49
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,55 @@ request.setRandom(1223L);
10471047
SendBroadcastMsgResult result = client.group.sendBroadcastMsg(request);
10481048
```
10491049

1050+
## 群消息已读回执
1051+
1052+
App 管理员可以通过该接口对指定成员进行群消息已读回执。
1053+
1054+
::: warning
1055+
该功能仅对旗舰版或企业版客户开放,需 购买旗舰版或企业版套餐包 并在 控制台 > 功能配置 > 群组配置 > 群消息已读回执打开开关后方可使用。
1056+
:::
1057+
1058+
::: tip
1059+
适用的群组类型
1060+
1061+
| 群组类型 ID | 是否支持此 REST API |
1062+
| ----------------- | ------------------------------------------ |
1063+
| Private | 支持,同新版本中的 Work(好友工作群) |
1064+
| Public | 支持 |
1065+
| ChatRoom | 支持,同新版本中的 Meeting(临时会议群)) |
1066+
| AVChatRoom | 不支持 |
1067+
| Community(社群) | 不支持 |
1068+
1069+
即时通信 IM 内置上述群组类型,详情介绍请参见 [群组系统](https://cloud.tencent.com/document/product/269/1502)
1070+
:::
1071+
1072+
使用示例:
1073+
1074+
```java
1075+
GroupMsgReceiptRequest request = new GroupMsgReceiptRequest();
1076+
request.setGroupId("MyFirstGroup");
1077+
request.setFromAccount("test1");
1078+
request.setMsgSeqList(Collections.singletonList(new MsgSeqItem(123L)));
1079+
1080+
GroupMsgReceiptResult result = client.group.groupMsgReceipt(request);
1081+
```
1082+
1083+
## 发送单聊消息已读回执
1084+
1085+
- App 管理员可以通过该接口发送单聊消息已读回执。
1086+
- 用户 A 给用户 B 发送单聊消息,则用户 B 作为消息的接收方,发送消息已读回执。请求中 Operator_Account 字段填用户 B 的 UserID, Peer_Account 字段填用户 A 的 UserID,C2CMsgInfo 中的 From_Account 填用户 A 的 UserID ,To_Account填用户 B 的 UserID。
1087+
1088+
使用示例:
1089+
1090+
```java
1091+
C2cMsgReadReceiptRequest request = new C2cMsgReadReceiptRequest();
1092+
request.setPeerAccount("test1");
1093+
request.setOperatorAccount("test2");
1094+
request.setC2cMsgInfoItemList(Collections.singletonList(new C2cMsgInfoItem("123", "456", "789")));
1095+
1096+
C2cMsgReadReceiptResult result = client.group.c2cMsgReadReceipt(request);
1097+
```
1098+
10501099
## 拉取群消息已读回执信息
10511100

10521101
App 管理员可以通过该接口拉取群消息已读回执信息。

docs/guide/quickstart.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
<dependency>
1111
<groupId>io.github.doocs</groupId>
1212
<artifactId>im-server-sdk-java</artifactId>
13-
<version>0.4.10</version>
13+
<version>0.4.11</version>
1414
</dependency>
1515
```
1616

1717
### Gradle
1818

1919
```gradle
20-
implementation group: 'io.github.doocs', name: 'im-server-sdk-java', version: '0.4.10'
20+
implementation group: 'io.github.doocs', name: 'im-server-sdk-java', version: '0.4.11'
2121
```
2222

2323
### 下载 JAR

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "qcloud-im-server-sdk-java",
3-
"version": "0.4.10",
3+
"version": "0.4.11",
44
"description": "腾讯云 IM 服务端 SDK API 文档 Java 版",
55
"main": "index.js",
66
"scripts": {

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.github.doocs</groupId>
88
<artifactId>im-server-sdk-java</artifactId>
9-
<version>0.4.10</version>
9+
<version>0.4.11</version>
1010
<packaging>jar</packaging>
1111

1212
<name>qcloud-im-server-sdk-java</name>

src/main/java/io/github/doocs/im/core/Group.java

+36
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ public class Group {
6060
public static final String SET_GROUP_ATTR_COMMAND = "set_group_attr";
6161
public static final String MODIFY_GROUP_MSG_COMMAND = "modify_group_msg";
6262
public static final String SEND_BROADCAST_MSG_COMMAND = "send_broadcast_msg";
63+
public static final String GROUP_MSG_RECEIPT_COMMAND = "group_msg_receipt";
64+
public static final String C2C_MSG_READ_RECEIPT_COMMAND = "c2c_msg_read_receipt";
6365
public static final String GET_GROUP_MSG_RECEIPT_COMMAND = "get_group_msg_receipt";
6466
public static final String GET_GROUP_MSG_RECEIPT_DETAIL_COMMAND = "get_group_msg_receipt_detail";
6567
public static final String CREATE_GROUP_TOPIC_COMMAND = "create_topic";
@@ -648,6 +650,40 @@ public SendBroadcastMsgResult sendBroadcastMsg(SendBroadcastMsgRequest sendBroad
648650
return HttpUtil.post(url, sendBroadcastMsgRequest, SendBroadcastMsgResult.class, imClient.getConfig());
649651
}
650652

653+
/**
654+
* 群消息已读回执
655+
*
656+
* @param groupMsgReceiptRequest 请求参数
657+
* @return 结果
658+
* @throws IOException 异常
659+
*/
660+
public GroupMsgReceiptResult groupMsgReceipt(GroupMsgReceiptRequest groupMsgReceiptRequest) throws IOException {
661+
String url = imClient.getUrl(SERVICE_NAME, GROUP_MSG_RECEIPT_COMMAND);
662+
return HttpUtil.post(url, groupMsgReceiptRequest, GroupMsgReceiptResult.class, imClient.getConfig());
663+
}
664+
665+
public GroupMsgReceiptResult groupMsgReceipt(GroupMsgReceiptRequest groupMsgReceiptRequest, long random) throws IOException {
666+
String url = imClient.getUrl(SERVICE_NAME, GROUP_MSG_RECEIPT_COMMAND, random);
667+
return HttpUtil.post(url, groupMsgReceiptRequest, GroupMsgReceiptResult.class, imClient.getConfig());
668+
}
669+
670+
/**
671+
* 发送单聊消息已读回执
672+
*
673+
* @param c2cMsgReadReceiptRequest 请求参数
674+
* @return 结果
675+
* @throws IOException 异常
676+
*/
677+
public C2cMsgReadReceiptResult c2cMsgReadReceipt(C2cMsgReadReceiptRequest c2cMsgReadReceiptRequest) throws IOException {
678+
String url = imClient.getUrl(SERVICE_NAME_OPEN_IM, C2C_MSG_READ_RECEIPT_COMMAND);
679+
return HttpUtil.post(url, c2cMsgReadReceiptRequest, C2cMsgReadReceiptResult.class, imClient.getConfig());
680+
}
681+
682+
public C2cMsgReadReceiptResult c2cMsgReadReceipt(C2cMsgReadReceiptRequest c2cMsgReadReceiptRequest, long random) throws IOException {
683+
String url = imClient.getUrl(SERVICE_NAME_OPEN_IM, C2C_MSG_READ_RECEIPT_COMMAND, random);
684+
return HttpUtil.post(url, c2cMsgReadReceiptRequest, C2cMsgReadReceiptResult.class, imClient.getConfig());
685+
}
686+
651687
/**
652688
* 拉取群消息已读回执信息
653689
*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
package io.github.doocs.im.model.request;
2+
3+
import com.fasterxml.jackson.annotation.JsonInclude;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
6+
import java.io.Serializable;
7+
8+
/**
9+
* @author hyh
10+
* @since 2021/07/29 15:37
11+
*/
12+
@JsonInclude(JsonInclude.Include.NON_NULL)
13+
public class C2cMsgInfoItem implements Serializable {
14+
private static final long serialVersionUID = 2340480215779943454L;
15+
16+
/**
17+
* 消息的发送方 UserID,需与 Peer_Account 保持一致
18+
*/
19+
@JsonProperty("From_Account")
20+
private String fromAccount;
21+
22+
/**
23+
* 消息的接收方 UserID,需与 Operator_Account 保持一致
24+
*/
25+
@JsonProperty("To_Account")
26+
private String toAccount;
27+
28+
/**
29+
* 消息的 MsgKey
30+
*/
31+
@JsonProperty("MsgKey")
32+
private String msgKey;
33+
34+
public String getFromAccount() {
35+
return fromAccount;
36+
}
37+
38+
public void setFromAccount(String fromAccount) {
39+
this.fromAccount = fromAccount;
40+
}
41+
42+
public String getToAccount() {
43+
return toAccount;
44+
}
45+
46+
public void setToAccount(String toAccount) {
47+
this.toAccount = toAccount;
48+
}
49+
50+
public String getMsgKey() {
51+
return msgKey;
52+
}
53+
54+
public void setMsgKey(String msgKey) {
55+
this.msgKey = msgKey;
56+
}
57+
58+
public C2cMsgInfoItem() {
59+
}
60+
61+
public C2cMsgInfoItem(String fromAccount, String toAccount, String msgKey) {
62+
this.fromAccount = fromAccount;
63+
this.toAccount = toAccount;
64+
this.msgKey = msgKey;
65+
}
66+
67+
private C2cMsgInfoItem(Builder builder) {
68+
this.fromAccount = builder.fromAccount;
69+
this.toAccount = builder.toAccount;
70+
this.msgKey = builder.msgKey;
71+
}
72+
73+
public static Builder builder() {
74+
return new Builder();
75+
}
76+
77+
public static final class Builder {
78+
private String fromAccount;
79+
private String toAccount;
80+
private String msgKey;
81+
82+
private Builder() {
83+
}
84+
85+
public C2cMsgInfoItem build() {
86+
return new C2cMsgInfoItem(this);
87+
}
88+
89+
public Builder fromAccount(String fromAccount) {
90+
this.fromAccount = fromAccount;
91+
return this;
92+
}
93+
94+
public Builder toAccount(String toAccount) {
95+
this.toAccount = toAccount;
96+
return this;
97+
}
98+
99+
public Builder msgKey(String msgKey) {
100+
this.msgKey = msgKey;
101+
return this;
102+
}
103+
}
104+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
package io.github.doocs.im.model.request;
2+
3+
import com.fasterxml.jackson.annotation.JsonInclude;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
6+
import java.io.Serializable;
7+
import java.util.List;
8+
9+
/**
10+
* 发送单聊消息已读回执-请求参数
11+
*
12+
* @author bingo
13+
* @since 2024/3/7 15:27
14+
*/
15+
@JsonInclude(JsonInclude.Include.NON_NULL)
16+
public class C2cMsgReadReceiptRequest extends GenericRequest implements Serializable {
17+
@JsonProperty("Operator_Account")
18+
private String operatorAccount;
19+
@JsonProperty("Peer_Account")
20+
private String peerAccount;
21+
22+
@JsonProperty("C2CMsgInfo")
23+
private List<C2cMsgInfoItem> c2cMsgInfoItemList;
24+
25+
public C2cMsgReadReceiptRequest() {
26+
}
27+
28+
public C2cMsgReadReceiptRequest(String operatorAccount, String peerAccount, List<C2cMsgInfoItem> c2cMsgInfoItemList) {
29+
this.operatorAccount = operatorAccount;
30+
this.peerAccount = peerAccount;
31+
this.c2cMsgInfoItemList = c2cMsgInfoItemList;
32+
}
33+
34+
public String getOperatorAccount() {
35+
return operatorAccount;
36+
}
37+
38+
public void setOperatorAccount(String operatorAccount) {
39+
this.operatorAccount = operatorAccount;
40+
}
41+
42+
public String getPeerAccount() {
43+
return peerAccount;
44+
}
45+
46+
public void setPeerAccount(String peerAccount) {
47+
this.peerAccount = peerAccount;
48+
}
49+
50+
public List<C2cMsgInfoItem> getC2cMsgInfoItemList() {
51+
return c2cMsgInfoItemList;
52+
}
53+
54+
public void setC2cMsgInfoItemList(List<C2cMsgInfoItem> c2cMsgInfoItemList) {
55+
this.c2cMsgInfoItemList = c2cMsgInfoItemList;
56+
}
57+
58+
private C2cMsgReadReceiptRequest(Builder builder) {
59+
this.operatorAccount = builder.operatorAccount;
60+
this.peerAccount = builder.peerAccount;
61+
this.c2cMsgInfoItemList = builder.c2cMsgInfoItemList;
62+
}
63+
64+
public static Builder builder() {
65+
return new Builder();
66+
}
67+
68+
public static final class Builder {
69+
private String operatorAccount;
70+
private String peerAccount;
71+
private List<C2cMsgInfoItem> c2cMsgInfoItemList;
72+
73+
public C2cMsgReadReceiptRequest build() {
74+
return new C2cMsgReadReceiptRequest(this);
75+
}
76+
77+
public Builder operatorAccount(String operatorAccount) {
78+
this.operatorAccount = operatorAccount;
79+
return this;
80+
}
81+
82+
public Builder peerAccount(String peerAccount) {
83+
this.peerAccount = peerAccount;
84+
return this;
85+
}
86+
87+
public Builder c2cMsgInfoItemList(List<C2cMsgInfoItem> c2cMsgInfoItemList) {
88+
this.c2cMsgInfoItemList = c2cMsgInfoItemList;
89+
return this;
90+
}
91+
}
92+
}

0 commit comments

Comments
 (0)