NIMSDK-AOS  10.6.0
QChatSendMessageParam.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.qchat.param;
2 
3 import androidx.annotation.NonNull;
4 
5 import com.netease.nimlib.qchat.QChatAuthCache;
6 import com.netease.nimlib.qchat.model.QChatMessageImpl;
12 import com.netease.nimlib.util.StringUtil;
13 
14 import java.util.List;
15 import java.util.Map;
16 
20 public class QChatSendMessageParam {
21 
22  private static final String TAG = "QChatSendMessageParam";
26  @NonNull
27  private final Long serverId;
31  @NonNull
32  private final Long channelId;
36  @NonNull
37  private final MsgTypeEnum type;
41  private String body;
45  private String attach;
49  private Map<String, Object> extension;
53  private Map<String, Object> pushPayload;
57  private String pushContent;
61  private List<String> mentionedAccidList;
65  private List<Long> mentionedRoleIdList;
69  private boolean mentionedAll = false;
73  private boolean historyEnable = true;
77  private boolean pushEnable = true;
81  private boolean needBadge = true;
85  private boolean needPushNick = true;
89  private boolean isRouteEnable = true;
90 
91 
97  private final String uuid;
98 
102  private Integer serverStatus;
106  private String env;
110  private QChatMessageAntiSpamOption antiSpamOption;
111 
115  private Integer subType;
116 
123  public QChatSendMessageParam(long serverId, long channelId, @NonNull MsgTypeEnum type) {
124  this.serverId = serverId;
125  this.channelId = channelId;
126  this.type = type;
127 
128  this.uuid = StringUtil.get32UUID();
129  }
130 
135  public void setBody(String body) {
136  this.body = body;
137  }
138 
143  public void setAttach(String attach) {
144  this.attach = attach;
145  }
146 
151  public void setAttachment(MsgAttachment attachment) {
152  this.attach = attachment.toJson(false);
153  }
154 
159  public void setExtension(Map<String, Object> extension) {
160  this.extension = extension;
161  }
162 
167  public void setPushPayload(Map<String, Object> pushPayload) {
168  this.pushPayload = pushPayload;
169  }
170 
175  public void setPushContent(String pushContent) {
176  this.pushContent = pushContent;
177  }
178 
183  public void setMentionedAccidList(List<String> mentionedAccidList) {
184  this.mentionedAccidList = mentionedAccidList;
185  }
186 
191  public void setMentionedRoleIdList(List<Long> mentionedRoleIdList) {
192  this.mentionedRoleIdList = mentionedRoleIdList;
193  }
194 
199  public void setMentionedAll(boolean mentionedAll) {
200  this.mentionedAll = mentionedAll;
201  }
202 
207  public void setHistoryEnable(boolean historyEnable) {
208  this.historyEnable = historyEnable;
209  }
210 
215  public void setPushEnable(boolean pushEnable) {
216  this.pushEnable = pushEnable;
217  }
218 
223  public void setNeedBadge(boolean needBadge) {
224  this.needBadge = needBadge;
225  }
226 
231  public void setNeedPushNick(boolean needPushNick) {
232  this.needPushNick = needPushNick;
233  }
234 
239  @NonNull
240  public Long getServerId() {
241  return serverId;
242  }
243 
248  @NonNull
249  public Long getChannelId() {
250  return channelId;
251  }
252 
257  @NonNull
258  public MsgTypeEnum getType() {
259  return type;
260  }
261 
266  public String getBody() {
267  return body;
268  }
269 
274  public String getAttach() {
275  return attach;
276  }
277 
282  public Map<String, Object> getExtension() {
283  return extension;
284  }
285 
290  public Map<String, Object> getPushPayload() {
291  return pushPayload;
292  }
293 
298  public String getPushContent() {
299  return pushContent;
300  }
301 
306  public List<String> getMentionedAccidList() {
307  return mentionedAccidList;
308  }
309 
314  public List<Long> getMentionedRoleIdList() {
315  return mentionedRoleIdList;
316  }
317 
322  public boolean isMentionedAll() {
323  return mentionedAll;
324  }
325 
330  public boolean isHistoryEnable() {
331  return historyEnable;
332  }
333 
338  public boolean isPushEnable() {
339  return pushEnable;
340  }
341 
346  public boolean isNeedBadge() {
347  return needBadge;
348  }
349 
354  public boolean isNeedPushNick() {
355  return needPushNick;
356  }
357 
362  public String getUuid() {
363  return uuid;
364  }
365 
370  public Integer getServerStatus() {
371  return serverStatus;
372  }
377  public void setServerStatus(Integer serverStatus) {
378  this.serverStatus = serverStatus;
379  }
380 
386  return antiSpamOption;
387  }
388 
393  public void setAntiSpamOption(QChatMessageAntiSpamOption antiSpamOption) {
394  this.antiSpamOption = antiSpamOption;
395  }
396 
401  public boolean isRouteEnable() {
402  return isRouteEnable;
403  }
404 
409  public void setRouteEnable(boolean routeEnable) {
410  isRouteEnable = routeEnable;
411  }
412 
419  public String getEnv() {
420  return env;
421  }
422 
429  public void setEnv(String env) {
430  this.env = env;
431  }
432 
437  public Integer getSubType() {
438  return subType;
439  }
440 
445  public void setSubType(Integer subType) {
446  this.subType = subType;
447  }
448 
449  private QChatMessageImpl qChatMessage;
450 
455  public synchronized QChatMessage toQChatMessage() {
456  if (qChatMessage == null) {
457  qChatMessage = QChatMessageImpl.fromParam(this);
458  QChatLoginParam loginData = QChatAuthCache.getInstance().getLoginData();
459  if(loginData != null)
460  {
461  qChatMessage.setFromAccount(loginData.getAccount());
462  }
463  qChatMessage.setDirect(MsgDirectionEnum.Out);
464  }else
465  {
466  QChatMessageImpl.fromParam(this,qChatMessage);
467  }
468 
469  return qChatMessage;
470  }
471 }
boolean isRouteEnable()
是否需要抄送,默认true
void setPushEnable(boolean pushEnable)
设置是否需要推送
List< Long > getMentionedRoleIdList()
设置@身份组的RoleId列表
boolean isNeedBadge()
是否需要消息计数,默认true
Map< String, Object > getPushPayload()
获取推送payload
String getEnv()
获取环境变量 用户可以根据不同的env配置不同的抄送和回调地址
void setSubType(Integer subType)
设置消息子类型
boolean isPushEnable()
是否需要推送,默认true
void setPushPayload(Map< String, Object > pushPayload)
设置推送payload
void setEnv(String env)
设置环境变量 用户可以根据不同的env配置不同的抄送和回调地址
void setAttachment(MsgAttachment attachment)
设置消息附件
void setNeedPushNick(boolean needPushNick)
设置是否需要推送昵称
QChatSendMessageParam(long serverId, long channelId, @NonNull MsgTypeEnum type)
void setAttach(String attach)
设置消息附件,通过MsgAttachment::toJson(false)获得
void setMentionedRoleIdList(List< Long > mentionedRoleIdList)
设置@身份组的RoleId列表
synchronized QChatMessage toQChatMessage()
将QChatSendMessageParam转换成QChatMessage
Map< String, Object > getExtension()
获取扩展字段
void setServerStatus(Integer serverStatus)
如果设置状态,状态只能设置成自定义的状态(status>= 10000),否则提示414参数错误
void setRouteEnable(boolean routeEnable)
设置是否需要抄送
QChatMessageAntiSpamOption getAntiSpamOption()
获取消息反垃圾配置选项
boolean isNeedPushNick()
是否需要推送昵称,默认true
void setAntiSpamOption(QChatMessageAntiSpamOption antiSpamOption)
设置消息反垃圾配置选项
void setExtension(Map< String, Object > extension)
设置扩展字段
String toJson(boolean send)
将消息附件序列化为字符串,存储到消息数据库或发送到服务器。
void setHistoryEnable(boolean historyEnable)
设置是否消息是否存储云端历史
void setNeedBadge(boolean needBadge)
设置是否需要消息计数
boolean isHistoryEnable()
是否消息在云端存储,默认true
void setPushContent(String pushContent)
设置推送文案
void setMentionedAccidList(List< String > mentionedAccidList)
设置@账号列表
void setMentionedAll(boolean mentionedAll)
设置是否@所有人