NIMSDK-AOS  9.16.3
QChatSendSystemNotificationParam.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.qchat.param;
2 
3 import android.util.Log;
4 import androidx.annotation.NonNull;
5 import com.netease.nimlib.BuildConfig;
6 import com.netease.nimlib.log.model.LogDesensitizationConfigHelper;
7 import com.netease.nimlib.qchat.model.QChatSystemNotificationImpl;
11 import com.netease.nimlib.util.StringUtil;
12 import java.util.ArrayList;
13 import java.util.List;
14 import java.util.Map;
15 
20 
21  private static final String TAG = "SendSystemNotification";
22 
26  @NonNull
27  private final Long serverId;
31  private final Long channelId;
35  private final List<String> toAccids;
39  private String body;
43  private String attach;
47  private Map<String, Object> extension;
51  private Integer status;
55  private Map<String, Object> pushPayload;
59  private String pushContent;
64  private boolean persistEnable = false;
68  private boolean pushEnable = false;
72  private boolean needBadge = true;
76  private boolean needPushNick = true;
77 
81  private boolean isRouteEnable = true;
82 
86  private String env;
87 
96  private final Integer toType;
97 
103  @NonNull
104  private final String uuid;
105 
106  // QChatSystemMsgToType.SERVER:如果只填了serverId,则发送给serverId下的所有人
107 
108 
109 
114  public QChatSendSystemNotificationParam(long serverId) {
115  this(serverId, 0L, new ArrayList<>(), QChatSystemMessageToType.SERVER.getValue());
116  }
117 
123  public QChatSendSystemNotificationParam(long serverId, long channelId) {
124  this(serverId, channelId, new ArrayList<>(), QChatSystemMessageToType.CHANNEL.getValue());
125  }
126 
132  public QChatSendSystemNotificationParam(long serverId, List<String> toAccids) {
133  this(serverId, 0L, toAccids, QChatSystemMessageToType.SERVER_ACCIDS.getValue());
134  }
135 
142  public QChatSendSystemNotificationParam(long serverId, long channelId, List<String> toAccids) {
143  this(serverId, channelId, toAccids, QChatSystemMessageToType.CHANNEL_ACCIDS.getValue());
144  }
145 
146  private QChatSendSystemNotificationParam(long serverId, long channelId, List<String> toAccids, int toType) {
147  this.serverId = serverId;
148  if (channelId > 0) {
149  this.channelId = channelId;
150  } else {
151  this.channelId = null;
152  }
153  this.toAccids = toAccids;
154 
155  this.toType = toType;
156 
157  this.uuid = StringUtil.get32UUID();
158  }
159 
164  public String getBody() {
165  return body;
166  }
167 
172  public void setBody(String body) {
173  this.body = body;
174  }
175 
180  public void setAttach(String attach) {
181  this.attach = attach;
182  }
183 
188  public void setExtension(Map<String, Object> extension) {
189  this.extension = extension;
190  }
191 
196  public void setStatus(Integer status) {
197  this.status = status;
198  }
199 
204  public void setPushPayload(Map<String, Object> pushPayload) {
205  this.pushPayload = pushPayload;
206  }
207 
212  public void setPushContent(String pushContent) {
213  this.pushContent = pushContent;
214  }
215 
220  @NonNull
221  public Long getServerId() {
222  return serverId;
223  }
224 
229  public Long getChannelId() {
230  return channelId;
231  }
232 
237  public List<String> getToAccids() {
238  return toAccids;
239  }
240 
245  public String getAttach() {
246  return attach;
247  }
248 
253  public Map<String, Object> getExtension() {
254  return extension;
255  }
256 
261  public Integer getStatus() {
262  return status;
263  }
264 
269  public Map<String, Object> getPushPayload() {
270  return pushPayload;
271  }
272 
277  public String getPushContent() {
278  return pushContent;
279  }
280 
285  public boolean isPersistEnable() {
286  return persistEnable;
287  }
288 
293  public void setPersistEnable(boolean persistEnable) {
294  if (persistEnable && (toAccids == null || toAccids.isEmpty())) {
295  if (BuildConfig.DEBUG) {
296  throw new IllegalArgumentException("set persistEnable = true only if toAccids is not null");
297  } else {
298  if (LogDesensitizationConfigHelper.printToLogcat()) {
299  Log.e(TAG, "set persistEnable = true only if toAccids is not null");
300  }
301  }
302  }
303  this.persistEnable = persistEnable;
304  }
305 
310  @NonNull
311  public Integer getToType() {
312  return toType;
313  }
314 
319  public boolean isPushEnable() {
320  return pushEnable;
321  }
322 
327  public void setPushEnable(boolean pushEnable) {
328  this.pushEnable = pushEnable;
329  }
330 
335  public boolean isNeedBadge() {
336  return needBadge;
337  }
338 
343  public void setNeedBadge(boolean needBadge) {
344  this.needBadge = needBadge;
345  }
346 
351  public boolean isNeedPushNick() {
352  return needPushNick;
353  }
354 
359  public void setNeedPushNick(boolean needPushNick) {
360  this.needPushNick = needPushNick;
361  }
362 
367  public boolean isRouteEnable() {
368  return isRouteEnable;
369  }
370 
375  public void setRouteEnable(boolean routeEnable) {
376  isRouteEnable = routeEnable;
377  }
378 
385  public String getEnv() {
386  return env;
387  }
388 
395  public void setEnv(String env) {
396  this.env = env;
397  }
398 
405  }
406 
411  @NonNull
412  public String getUuid() {
413  return uuid;
414  }
415 
421  return QChatSystemNotificationImpl.from(this);
422  }
423 }
QChatSendSystemNotificationParam(long serverId, List< String > toAccids)
通知给服务器成员
QChatSystemNotificationType getType()
获取系统通知类型,用户发送的系统通知一定是 QChatSystemMsgType.CUSTOM
QChatSendSystemNotificationParam(long serverId, long channelId, List< String > toAccids)
通知给频道成员
CHANNEL_ACCIDS
频道成员,serverId/channelId/toAccids必填
QChatSystemNotification toSystemNotification()
转换成QChatSystemNotification
void setNeedPushNick(boolean needPushNick)
设置是否需要推送昵称
String getEnv()
获取环境变量 用户可以根据不同的env配置不同的抄送和回调地址
void setStatus(Integer status)
如果设置状态,状态只能设置成自定义的状态(status>= 10000),否则提示414参数错误
void setExtension(Map< String, Object > extension)
设置扩展字段
void setPushPayload(Map< String, Object > pushPayload)
设置推送payload
void setEnv(String env)
设置环境变量 用户可以根据不同的env配置不同的抄送和回调地址