Skip to content

Commit

Permalink
[FEAT]: 群 @ 消息支持消息扩展
Browse files Browse the repository at this point in the history
  • Loading branch information
rchht committed Dec 5, 2024
1 parent b8cad2d commit 9b5c54c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/io/rong/example/message/MessageExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,9 @@ public static void main(String[] args) throws Exception {
.setIsPersisted(0)
.setIsCounted(0)
.setIsIncludeSender(0)
.setContentAvailable(0);
.setContentAvailable(0)
.setExpansion(true)
.setExtraContent(new HashMap<String, String>());
ResponseResult mentionResult = rongCloud.message.group.sendMention(mentionMessage);

System.out.println("group mention result: " + mentionResult.toString());
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/io/rong/methods/message/group/Group.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ public MessageResult sendMention(MentionMessage message) throws Exception {
if (message.getContentAvailable() != null) {
sb.append("&contentAvailable=").append(URLEncoder.encode(message.getContentAvailable().toString(), UTF8));
}
if (message.getExpansion() != null) {
sb.append("&expansion=").append(URLEncoder.encode(message.getExpansion().toString(), UTF8));
if (message.getExtraContent() != null) {
sb.append("&extraContent=").append(URLEncoder.encode(JSON.toJSONString(message.getExtraContent()), UTF8));
}
}
if (message.getMsgRandom() != null){
sb.append("&msgRandom=").append(message.getMsgRandom());
}
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/io/rong/models/message/MentionMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import io.rong.util.GsonUtil;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* @author rongcloud
Expand All @@ -28,6 +30,15 @@ public class MentionMessage {
public Integer isIncludeSender;
private Integer contentAvailable;
private Long msgRandom;
/**
* 是否为可扩展消息,默认为 false,设为 true 时终端在收到该条消息后,可对该条消息设置扩展信息(可选)。暂不支持海外数据中心
*/
public Boolean expansion;

/**
* 扩展消息内容,expansion 为true 的时候生效
*/
public Map<String, String> extraContent;

public MentionMessage() {
}
Expand Down Expand Up @@ -185,4 +196,22 @@ public MentionMessage setMsgRandom(Long msgRandom) {
this.msgRandom = msgRandom;
return this;
}

public Boolean getExpansion() {
return expansion;
}

public MentionMessage setExpansion(Boolean expansion) {
this.expansion = expansion;
return this;
}

public Map<String, String> getExtraContent() {
return extraContent;
}

public MentionMessage setExtraContent(Map<String, String> extraContent) {
this.extraContent = extraContent;
return this;
}
}

0 comments on commit 9b5c54c

Please sign in to comment.