Skip to content

Commit

Permalink
Adding ADVANCED_NOTIFICATIONS for pull notifications create events
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-stanchev committed Jan 20, 2023
1 parent 706854c commit 316a01e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public enum Policy {
EXPAND_RICH_CONTENT("EXPAND_RICH_CONTENT"),
RESTRICT_NON_SYNDICATABLE_CONTENT("RESTRICT_NON_SYNDICATABLE_CONTENT"),
INTERNAL_ANALYTICS("INTERNAL_ANALYTICS"),
APPEND_LIVE_BLOG_NOTIFICATIONS("APPEND_LIVE_BLOG_NOTIFICATIONS");
APPEND_LIVE_BLOG_NOTIFICATIONS("APPEND_LIVE_BLOG_NOTIFICATIONS"),
ADVANCED_NOTIFICATIONS("ADVANCED_NOTIFICATIONS");

private final String headerValue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import static com.ft.up.apipolicy.configuration.Policy.APPEND_LIVE_BLOG_NOTIFICATIONS;
import static com.ft.up.apipolicy.configuration.Policy.INTERNAL_UNSTABLE;

import static com.ft.up.apipolicy.configuration.Policy.ADVANCED_NOTIFICATIONS;
import com.ft.up.apipolicy.JsonConverter;
import com.ft.up.apipolicy.pipeline.ApiFilter;
import com.ft.up.apipolicy.pipeline.HttpPipelineChain;
Expand All @@ -20,6 +20,7 @@ public class NotificationsTypeFilter implements ApiFilter {
private static final String HREF_KEY = "href";
private static final String TYPE_KEY = "type";
private static final String MONITOR_KEY = "monitor";
private static final String HIDE_CREATE_EVENTS_KEY = "hideCreate";
private static final String ALL_CONTENT_TYPES = "All";
private static final String ARTICLE_CONTENT_TYPE = "Article";
private static final String LIVE_BLOG_POST_CONTENT_TYPE = "LiveBlogPost";
Expand Down Expand Up @@ -65,6 +66,7 @@ public MutableResponse processRequest(MutableRequest request, HttpPipelineChain
private void addQueryParams(MutableRequest request) {
List<String> typeParams = new ArrayList<>();
List<String> monitorParams = new ArrayList<>();
List<String> hideCreateEventsParams = new ArrayList<>();

if (request.policyIs(INTERNAL_UNSTABLE)) {
typeParams.add(ALL_CONTENT_TYPES);
Expand All @@ -79,6 +81,13 @@ private void addQueryParams(MutableRequest request) {
monitorParams.add(Boolean.FALSE.toString());
}

if (request.policyIs(ADVANCED_NOTIFICATIONS)) {
hideCreateEventsParams.add(Boolean.FALSE.toString());
} else {
hideCreateEventsParams.add(Boolean.TRUE.toString());
}

request.getQueryParameters().put(HIDE_CREATE_EVENTS_KEY, hideCreateEventsParams);
request.getQueryParameters().put(TYPE_KEY, typeParams);
request.getQueryParameters().put(MONITOR_KEY, monitorParams);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ public void testThatForNon200ResponseNoOtherInteractionHappens() {
filter.processRequest(request, chain);

verify(request).policyIs(Policy.INTERNAL_UNSTABLE);
verify(request, times(2)).getQueryParameters();
verify(request).policyIs(Policy.ADVANCED_NOTIFICATIONS);
verify(request, times(3)).getQueryParameters();
verifyNoMoreInteractions(request);
}

Expand Down

0 comments on commit 316a01e

Please sign in to comment.