Skip to content

Commit e4dcd96

Browse files
marceloinacioMax Presman
authored andcommitted
Fixed and updated
1 parent fc231eb commit e4dcd96

2 files changed

Lines changed: 7 additions & 12 deletions

File tree

‎src/main/java/com/pubnub/api/endpoints/pubsub/Publish.java‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ public class Publish extends Endpoint<List<Object>, PNPublishResult> {
3636
@Setter
3737
private Boolean replicate;
3838
@Setter
39-
private Boolean storeInHistory;
40-
@Setter
4139
private Integer ttl;
4240

4341
private PublishSequenceManager publishSequenceManager;
@@ -47,7 +45,7 @@ public Publish(PubNub pubnub, PublishSequenceManager providedPublishSequenceMana
4745

4846
this.publishSequenceManager = providedPublishSequenceManager;
4947
this.replicate = true;
50-
this.storeInHistory = true;
48+
this.shouldStore = true;
5149
}
5250

5351
@Override
@@ -64,9 +62,6 @@ protected final void validateParams() throws PubNubException {
6462
if (this.getPubnub().getConfiguration().getPublishKey() == null || this.getPubnub().getConfiguration().getPublishKey().isEmpty()) {
6563
throw PubNubException.builder().pubnubError(PubNubErrorBuilder.PNERROBJ_PUBLISH_KEY_MISSING).build();
6664
}
67-
// if (storeInHistory && ttl == null) {
68-
//
69-
// }
7065
}
7166

7267
@Override
@@ -94,6 +89,9 @@ protected final Call<List<Object>> doWork(Map<String, String> params) throws Pub
9489
if (shouldStore != null) {
9590
if (shouldStore) {
9691
params.put("store", "1");
92+
if (ttl != null) {
93+
params.put("ttl", String.valueOf(ttl));
94+
}
9795
} else {
9896
params.put("store", "0");
9997
}
@@ -105,9 +103,6 @@ protected final Call<List<Object>> doWork(Map<String, String> params) throws Pub
105103
params.put("norep", "true");
106104
}
107105

108-
if (storeInHistory && ttl != null) {
109-
params.put("ttl", String.valueOf(ttl));
110-
}
111106

112107
if (this.getPubnub().getConfiguration().getCipherKey() != null) {
113108
Crypto crypto = new Crypto(this.getPubnub().getConfiguration().getCipherKey());

‎src/test/java/com/pubnub/api/endpoints/pubsub/PublishTest.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ public void testInvalidMeta() throws PubNubException, InterruptedException {
392392
}
393393

394394
@Test
395-
public void testTTLStoreInHistoryDefaultSuccessSync() throws PubNubException, InterruptedException {
395+
public void testTTLShouldStoryDefaultSuccessSync() throws PubNubException, InterruptedException {
396396

397397
stubFor(get(urlPathEqualTo("/publish/myPublishKey/mySubscribeKey/0/coolChannel/0/%22hi%22"))
398398
.willReturn(aResponse().withBody("[1,\"Sent\",\"14598111595318003\"]")));
@@ -405,12 +405,12 @@ public void testTTLStoreInHistoryDefaultSuccessSync() throws PubNubException, In
405405
}
406406

407407
@Test
408-
public void testTTLStoreInHistoryFalseSuccessSync() throws PubNubException, InterruptedException {
408+
public void testTTLShouldStoreFalseSuccessSync() throws PubNubException, InterruptedException {
409409

410410
stubFor(get(urlPathEqualTo("/publish/myPublishKey/mySubscribeKey/0/coolChannel/0/%22hi%22"))
411411
.willReturn(aResponse().withBody("[1,\"Sent\",\"14598111595318003\"]")));
412412

413-
instance.channel("coolChannel").message("hi").storeInHistory(false).sync();
413+
instance.channel("coolChannel").message("hi").shouldStore(false).sync();
414414

415415
List<LoggedRequest> requests = findAll(getRequestedFor(urlMatching("/.*")));
416416
assertEquals(1, requests.size());

0 commit comments

Comments
 (0)