Skip to content

Commit f99c821

Browse files
authored
Merge pull request #19 from zhiheng12138/master
多包名功能代码
2 parents 8e86610 + 1ce2b76 commit f99c821

6 files changed

Lines changed: 59 additions & 11 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
## 更新日志
88

9+
### [2018-11-06]V1.2.7.20181228_release
10+
* 多包名功能代码
11+
912
### [2018-11-06]V1.2.7.20181106_release
1013
* fastjson升级版本1.2.51,fix远程代码执行高危安全漏洞
1114

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>com.meizu.flyme</groupId>
77
<artifactId>push-server-sdk</artifactId>
8-
<version>1.2.7.20181106_release</version>
8+
<version>1.2.7.20181128_release</version>
99

1010
<packaging>jar</packaging>
1111
<name>MeizuPushSDK</name>

src/main/java/com/meizu/push/sdk/server/IFlymePush.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,9 @@ public ResultPack<Long> getTaskId(PushType pushType, Message message) throws IOE
236236

237237
VarnishedMessageJson messageJson = new VarnishedMessageJson(noticeBarInfo, noticeExpandInfo, clickTypeInfo, pushTimeInfo, advanceInfo);
238238
addParameter(body, "messageJson", JSON.toJSONString(messageJson));
239+
if (message.getRestrictedPackageNames() != null) {
240+
addParameter(body, "restrictedPackageNames", array2Str(message.getRestrictedPackageNames()));
241+
}
239242
}
240243

241244
HttpResult httpResult = super.post(useSSL, _url, body.toString());
@@ -392,7 +395,9 @@ public ResultPack<Long> pushToApp(PushType pushType, Message message) throws IOE
392395

393396
VarnishedMessageJson messageJson = new VarnishedMessageJson(noticeBarInfo, noticeExpandInfo, clickTypeInfo, pushTimeInfo, advanceInfo);
394397
addParameter(body, "messageJson", JSON.toJSONString(messageJson));
395-
398+
if (message.getRestrictedPackageNames() != null) {
399+
addParameter(body, "restrictedPackageNames", array2Str(message.getRestrictedPackageNames()));
400+
}
396401
}
397402

398403
HttpResult httpResult = super.post(useSSL, _url, body.toString());
@@ -485,7 +490,9 @@ public ResultPack<Long> pushToTag(PushType pushType, Message message, List<Strin
485490

486491
VarnishedMessageJson messageJson = new VarnishedMessageJson(noticeBarInfo, noticeExpandInfo, clickTypeInfo, pushTimeInfo, advanceInfo);
487492
addParameter(body, "messageJson", JSON.toJSONString(messageJson));
488-
493+
if (message.getRestrictedPackageNames() != null) {
494+
addParameter(body, "restrictedPackageNames", array2Str(message.getRestrictedPackageNames()));
495+
}
489496
}
490497

491498
HttpResult httpResult = super.post(useSSL, _url, body.toString());
@@ -648,6 +655,9 @@ private ResultPack<PushResult> pushMessageNoRetry(UserType userType, PushType pu
648655
} else {
649656
return ResultPack.failed("appId is empty");
650657
}
658+
if (message.getRestrictedPackageNames() != null) {
659+
addParameter(body, "restrictedPackageNames", array2Str(message.getRestrictedPackageNames()));
660+
}
651661
if (PushType.DIRECT == pushType) {
652662
UnVarnishedMessage msgInfo = (UnVarnishedMessage) message;
653663

@@ -771,6 +781,16 @@ private ResultPack<PushResult> pushMessageByTaskIdNoRetry(UserType userType, Pus
771781
}
772782
}
773783

784+
private String array2Str(String[] restrictedPackageNames) {
785+
if (restrictedPackageNames == null || restrictedPackageNames.length == 0) {
786+
return null;
787+
}
788+
StringBuilder sb = new StringBuilder(restrictedPackageNames[0]);
789+
for (int i = 1; i < restrictedPackageNames.length; ++i) {
790+
sb.append(",").append(restrictedPackageNames[i]);
791+
}
792+
return sb.toString();
793+
}
774794

775795
enum UserType {
776796

src/main/java/com/meizu/push/sdk/server/model/push/Message.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,20 @@
77
* @date 2016年7月15日
88
* @time 下午7:23:15
99
*/
10-
public abstract class Message implements Serializable{
10+
public abstract class Message implements Serializable {
1111

12-
/**
13-
*
14-
*/
15-
private static final long serialVersionUID = 1L;
12+
private static final long serialVersionUID = 1L;
1613

1714
/**
1815
* 平台注册应用ID
1916
*/
2017
private Long appId;
2118

22-
public static long getSerialVersionUID() {
23-
return serialVersionUID;
24-
}
19+
/**
20+
* 多包名列表
21+
*/
22+
private String[] restrictedPackageNames;
23+
2524

2625
public Long getAppId() {
2726
return appId;
@@ -30,4 +29,12 @@ public Long getAppId() {
3029
public void setAppId(Long appId) {
3130
this.appId = appId;
3231
}
32+
33+
public String[] getRestrictedPackageNames() {
34+
return restrictedPackageNames;
35+
}
36+
37+
public void setRestrictedPackageNames(String[] restrictedPackageNames) {
38+
this.restrictedPackageNames = restrictedPackageNames;
39+
}
3340
}

src/main/java/com/meizu/push/sdk/server/model/push/UnVarnishedMessage.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ public String toString() {
9696

9797
protected UnVarnishedMessage(UnVarnishedMessage.Builder builder) {
9898
super.setAppId(builder.appId);
99+
super.setRestrictedPackageNames(builder.restrictedPackageNames);
99100
this.title = builder.title;
100101
this.content = builder.content;
101102
this.isOffLine = builder.isOffLine;
@@ -109,6 +110,7 @@ protected UnVarnishedMessage(UnVarnishedMessage.Builder builder) {
109110

110111
public static final class Builder {
111112
private Long appId;
113+
private String[] restrictedPackageNames;
112114
private String title;
113115
private String content;
114116
private boolean isOffLine = Boolean.TRUE;
@@ -162,6 +164,11 @@ public UnVarnishedMessage.Builder startTime(Date startTime) {
162164
this.startTime = startTime;
163165
return this;
164166
}
167+
168+
public UnVarnishedMessage.Builder restrictedPackageNames(String[] restrictedPackageNames) {
169+
this.restrictedPackageNames = restrictedPackageNames;
170+
return this;
171+
}
165172

166173
public UnVarnishedMessage build() {
167174
return new UnVarnishedMessage(this);

src/main/java/com/meizu/push/sdk/server/model/push/VarnishedMessage.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ public VarnishedMessage() {
158158

159159
public VarnishedMessage(VarnishedMessage.Builder builder) {
160160
super.setAppId(builder.appId);
161+
super.setRestrictedPackageNames(builder.restrictedPackageNames);
161162
this.noticeBarType = builder.noticeBarType;
162163
this.title = builder.title;
163164
this.content = builder.content;
@@ -336,6 +337,11 @@ public static final class Builder {
336337
*/
337338
private Long appId;
338339

340+
/**
341+
* 多包名列表
342+
*/
343+
private String[] restrictedPackageNames;
344+
339345
/* =============通知栏样式 begin============= */
340346
/**
341347
* 通知栏类型(0, "默认"),(1, "图片") , 【必填,值为0或者1】
@@ -597,6 +603,11 @@ public VarnishedMessage.Builder extra(String key, String value) {
597603
return this;
598604
}
599605

606+
public VarnishedMessage.Builder restrictedPackageNames(String[] restrictedPackageNames) {
607+
this.restrictedPackageNames = restrictedPackageNames;
608+
return this;
609+
}
610+
600611
public VarnishedMessage.Builder notifyKey(String notifyKey) {
601612
this.notifyKey = notifyKey;
602613
return this;

0 commit comments

Comments
 (0)