NIMSDK-AOS  9.16.0
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.qchat.model.QChatSystemNotificationImpl;
10 import com.netease.nimlib.util.StringUtil;
11 import java.util.ArrayList;
12 import java.util.List;
13 import java.util.Map;
14 
19 
20  private static final String TAG = "SendSystemNotification";
21 
25  @NonNull
26  private final Long serverId;
30  private final Long channelId;
34  private final List<String> toAccids;
38  private String body;
42  private String attach;
46  private Map<String, Object> extension;
50  private Integer status;
54  private Map<String, Object> pushPayload;
58  private String pushContent;
63  private boolean persistEnable = false;
67  private boolean pushEnable = false;
71  private boolean needBadge = true;
75  private boolean needPushNick = true;
76 
80  private boolean isRouteEnable = true;
81 
85  private String env;
86 
95  private final Integer toType;
96 
102  @NonNull
103  private final String uuid;
104 
105  // QChatSystemMsgToType.SERVER:如果只填了serverId,则发送给serverId下的所有人
106 
107 
108 
113  public QChatSendSystemNotificationParam(long serverId) {
114  this(serverId, 0L, new ArrayList<>(), QChatSystemMessageToType.SERVER.getValue());
115  }
116 
122  public QChatSendSystemNotificationParam(long serverId, long channelId) {
123  this(serverId, channelId, new ArrayList<>(), QChatSystemMessageToType.CHANNEL.getValue());
124  }
125 
131  public QChatSendSystemNotificationParam(long serverId, List<String> toAccids) {
132  this(serverId, 0L, toAccids, QChatSystemMessageToType.SERVER_ACCIDS.getValue());
133  }
134 
141  public QChatSendSystemNotificationParam(long serverId, long channelId, List<String> toAccids) {
142  this(serverId, channelId, toAccids, QChatSystemMessageToType.CHANNEL_ACCIDS.getValue());
143  }
144 
145  private QChatSendSystemNotificationParam(long serverId, long channelId, List<String> toAccids, int toType) {
146  this.serverId = serverId;
147  if (channelId > 0) {
148  this.channelId = channelId;
149  } else {
150  this.channelId = null;
151  }
152  this.toAccids = toAccids;
153 
154  this.toType = toType;
155 
156  this.uuid = StringUtil.get32UUID();
157  }
158 
163  public String getBody() {
164  return body;
165  }
166 
171  public void setBody(String body) {
172  this.body = body;
173  }
174 
179  public void setAttach(String attach) {
180  this.attach = attach;
181  }
182 
187  public void setExtension(Map<String, Object> extension) {
188  this.extension = extension;
189  }
190 
195  public void setStatus(Integer status) {
196  this.status = status;
197  }
198 
203  public void setPushPayload(Map<String, Object> pushPayload) {
204  this.pushPayload = pushPayload;
205  }
206 
211  public void setPushContent(String pushContent) {
212  this.pushContent = pushContent;
213  }
214 
219  @NonNull
220  public Long getServerId() {
221  return serverId;
222  }
223 
228  public Long getChannelId() {
229  return channelId;
230  }
231 
236  public List<String> getToAccids() {
237  return toAccids;
238  }
239 
244  public String getAttach() {
245  return attach;
246  }
247 
252  public Map<String, Object> getExtension() {
253  return extension;
254  }
255 
260  public Integer getStatus() {
261  return status;
262  }
263 
268  public Map<String, Object> getPushPayload() {
269  return pushPayload;
270  }
271 
276  public String getPushContent() {
277  return pushContent;
278  }
279 
284  public boolean isPersistEnable() {
285  return persistEnable;
286  }
287 
292  public void setPersistEnable(boolean persistEnable) {
293  if (persistEnable && (toAccids == null || toAccids.isEmpty())) {
294  if (BuildConfig.DEBUG) {
295  throw new IllegalArgumentException("set persistEnable = true only if toAccids is not null");
296  } else {
297  Log.e(TAG, "set persistEnable = true only if toAccids is not null");
298  }
299  }
300  this.persistEnable = persistEnable;
301  }
302 
307  @NonNull
308  public Integer getToType() {
309  return toType;
310  }
311 
316  public boolean isPushEnable() {
317  return pushEnable;
318  }
319 
324  public void setPushEnable(boolean pushEnable) {
325  this.pushEnable = pushEnable;
326  }
327 
332  public boolean isNeedBadge() {
333  return needBadge;
334  }
335 
340  public void setNeedBadge(boolean needBadge) {
341  this.needBadge = needBadge;
342  }
343 
348  public boolean isNeedPushNick() {
349  return needPushNick;
350  }
351 
356  public void setNeedPushNick(boolean needPushNick) {
357  this.needPushNick = needPushNick;
358  }
359 
364  public boolean isRouteEnable() {
365  return isRouteEnable;
366  }
367 
372  public void setRouteEnable(boolean routeEnable) {
373  isRouteEnable = routeEnable;
374  }
375 
382  public String getEnv() {
383  return env;
384  }
385 
392  public void setEnv(String env) {
393  this.env = env;
394  }
395 
402  }
403 
408  @NonNull
409  public String getUuid() {
410  return uuid;
411  }
412 
418  return QChatSystemNotificationImpl.from(this);
419  }
420 }
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配置不同的抄送和回调地址