Skip to content

Commit

Permalink
minor change in message controller
Browse files Browse the repository at this point in the history
  • Loading branch information
surabhi-mahawar committed Jul 19, 2022
1 parent 16d532d commit 2399ff5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/java/com/uci/outbound/controller/MessageController.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ public Mono<ResponseEntity<HttpApiResponse>> sendMessage(@RequestBody MessageReq
|| request.getTo().getUserID().isEmpty() || request.getTo().getDeviceType() == null || request.getPayload() == null
) {
response.setStatus(HttpStatus.BAD_REQUEST.value());
response.setError(HttpStatus.BAD_REQUEST.name());
response.setError(HttpStatus.BAD_REQUEST.getReasonPhrase());
response.setMessage("Adapter id, to with userID, deviceType & payload are required.");
return Mono.just(ResponseEntity.badRequest().body(response));
} else if(request.getPayload().getText() == null && request.getPayload().getMedia() == null) {
response.setStatus(HttpStatus.BAD_REQUEST.value());
response.setError(HttpStatus.BAD_REQUEST.name());
response.setError(HttpStatus.BAD_REQUEST.getReasonPhrase());
response.setMessage("Payload should have either text or media.");
return Mono.just(ResponseEntity.badRequest().body(response));
} else if(request.getPayload().getMedia() != null
&& (request.getPayload().getMedia().getUrl() == null || request.getPayload().getMedia().getCategory() == null)
) {
response.setStatus(HttpStatus.BAD_REQUEST.value());
response.setError(HttpStatus.BAD_REQUEST.name());
response.setError(HttpStatus.BAD_REQUEST.getReasonPhrase());
response.setMessage("Payload media should have category and url.");
return Mono.just(ResponseEntity.badRequest().body(response));
} else {
Expand Down Expand Up @@ -91,7 +91,7 @@ public ResponseEntity<HttpApiResponse> apply(JsonNode adapter) {
&& !adapter.path("channel").asText().equalsIgnoreCase("whatsapp")
) {
response.setStatus(HttpStatus.BAD_REQUEST.value());
response.setError(HttpStatus.BAD_REQUEST.name());
response.setError(HttpStatus.BAD_REQUEST.getReasonPhrase());
response.setMessage("Media is allowed only for gupshup whatsapp & netcore whatsapp adapter.");
return ResponseEntity.badRequest().body(response);
}
Expand All @@ -101,7 +101,7 @@ public ResponseEntity<HttpApiResponse> apply(JsonNode adapter) {
&& adapter.path("provider").asText().equalsIgnoreCase("cdac")) {
if(request.getTo().getMeta() == null || request.getTo().getMeta().get("templateId") == null || request.getTo().getMeta().get("templateId").isEmpty()) {
response.setStatus(HttpStatus.BAD_REQUEST.value());
response.setError(HttpStatus.BAD_REQUEST.name());
response.setError(HttpStatus.BAD_REQUEST.getReasonPhrase());
response.setMessage("Template id in meta of to is required for firebase adapter messaging.");
return ResponseEntity.badRequest().body(response);
} else {
Expand All @@ -120,7 +120,7 @@ public ResponseEntity<HttpApiResponse> apply(JsonNode adapter) {
&& adapter.path("provider").asText().equalsIgnoreCase("firebase")
&& (request.getTo().getMeta() == null || request.getTo().getMeta().get("fcmToken") == null || request.getTo().getMeta().get("fcmToken").isEmpty())) {
response.setStatus(HttpStatus.BAD_REQUEST.value());
response.setError(HttpStatus.BAD_REQUEST.name());
response.setError(HttpStatus.BAD_REQUEST.getReasonPhrase());
response.setMessage("FCM token in meta of to is required for firebase adapter messaging.");
return ResponseEntity.badRequest().body(response);
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ spring.data.cassandra.pool.max-queue-size=2000
spring.data.cassandra.pool.idle-timeout=20s
spring.data.cassandra.pool.pool-timeout=20s

# For async timeout exception
spring.mvc.async.request-timeout=-1

# For removing trace from api response
server.error.include-stacktrace=never

fusionauth.url = ${FUSIONAUTH_URL}
fusionauth.key = ${FUSIONAUTH_KEY}

Expand Down

0 comments on commit 2399ff5

Please sign in to comment.