Auto-commit dev changes before merge via Dashboard
This commit is contained in:
@@ -24,6 +24,9 @@ public class WebhookController {
|
|||||||
@Value("${whatsapp.phone-number-id:}")
|
@Value("${whatsapp.phone-number-id:}")
|
||||||
private String configuredPhoneId;
|
private String configuredPhoneId;
|
||||||
|
|
||||||
|
@Value("${whatsapp.dev-webhook-forward-url:}")
|
||||||
|
private String devWebhookUrl;
|
||||||
|
|
||||||
private final WhatsAppMessageService messageService;
|
private final WhatsAppMessageService messageService;
|
||||||
private final SessionService sessionService;
|
private final SessionService sessionService;
|
||||||
private final StudentMenuHandler studentMenuHandler;
|
private final StudentMenuHandler studentMenuHandler;
|
||||||
@@ -81,8 +84,22 @@ public class WebhookController {
|
|||||||
String incomingPhoneId = metadataNode.get("phone_number_id").asText();
|
String incomingPhoneId = metadataNode.get("phone_number_id").asText();
|
||||||
if (configuredPhoneId != null && !configuredPhoneId.trim().isEmpty()
|
if (configuredPhoneId != null && !configuredPhoneId.trim().isEmpty()
|
||||||
&& !incomingPhoneId.trim().equals(configuredPhoneId.trim())) {
|
&& !incomingPhoneId.trim().equals(configuredPhoneId.trim())) {
|
||||||
System.out.println("Incoming phone ID " + incomingPhoneId + " does not match configured ID " + configuredPhoneId + ". Ignoring webhook payload.");
|
if (devWebhookUrl != null && !devWebhookUrl.trim().isEmpty()) {
|
||||||
return ResponseEntity.ok("EVENT_IGNORED");
|
System.out.println("Incoming phone ID " + incomingPhoneId + " does not match configured ID " + configuredPhoneId + ". Forwarding to " + devWebhookUrl);
|
||||||
|
try {
|
||||||
|
org.springframework.web.client.RestTemplate tempTemplate = new org.springframework.web.client.RestTemplate();
|
||||||
|
org.springframework.http.HttpHeaders headers = new org.springframework.http.HttpHeaders();
|
||||||
|
headers.setContentType(org.springframework.http.MediaType.APPLICATION_JSON);
|
||||||
|
org.springframework.http.HttpEntity<String> entity = new org.springframework.http.HttpEntity<>(payload, headers);
|
||||||
|
tempTemplate.postForEntity(devWebhookUrl, entity, String.class);
|
||||||
|
} catch (Exception forwardEx) {
|
||||||
|
System.err.println("Failed to forward webhook to dev bot: " + forwardEx.getMessage());
|
||||||
|
}
|
||||||
|
return ResponseEntity.ok("EVENT_FORWARDED");
|
||||||
|
} else {
|
||||||
|
System.out.println("Incoming phone ID " + incomingPhoneId + " does not match configured ID " + configuredPhoneId + ". Ignoring webhook payload.");
|
||||||
|
return ResponseEntity.ok("EVENT_IGNORED");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user