Complix Integration added

This commit is contained in:
RIT Services
2026-08-24 18:48:48 +00:00
parent 00b71831ee
commit 7d6d019b85
12 changed files with 593 additions and 49 deletions

View File

@@ -101,7 +101,6 @@ public class WebhookController {
String body = messageNode.get("text").get("body").asText();
handleUnauthenticatedUser(fromPhoneNumber, body, currentState);
} else {
// If they send a sticker/image/etc before logging in, force login
handleUnauthenticatedUser(fromPhoneNumber, "", currentState);
}
return ResponseEntity.ok("EVENT_RECEIVED");
@@ -111,6 +110,15 @@ public class WebhookController {
if ("text".equals(messageType)) {
String messageBody = messageNode.get("text").get("body").asText();
handleAuthenticatedTextMessage(fromPhoneNumber, messageBody, currentState);
} else if ("image".equals(messageType)) {
if (currentState == UserState.AWAITING_GRIEVANCE_IMAGE) {
JsonNode imageNode = messageNode.get("image");
String mediaId = imageNode.get("id").asText();
String mimeType = imageNode.has("mime_type") ? imageNode.get("mime_type").asText() : "image/jpeg";
grievanceHandler.handleImageInput(fromPhoneNumber, mediaId, mimeType);
} else {
studentMenuHandler.sendMainMenu(fromPhoneNumber);
}
} else if ("interactive".equals(messageType)) {
JsonNode interactiveNode = messageNode.get("interactive");
String interactiveType = interactiveNode.get("type").asText();
@@ -142,7 +150,6 @@ public class WebhookController {
loginHandler.handlePasscodeInput(phoneNumber, messageBody);
break;
default:
// Trigger the start of the login flow
loginHandler.startLoginFlow(phoneNumber);
break;
}
@@ -150,26 +157,40 @@ public class WebhookController {
private void handleAuthenticatedTextMessage(String phoneNumber, String messageBody, UserState currentState) {
switch (currentState) {
case AWAITING_GRIEVANCE_TITLE:
grievanceHandler.handleTitleInput(phoneNumber, messageBody);
break;
case AWAITING_GRIEVANCE_DESC:
grievanceHandler.handleGrievanceDescription(phoneNumber, messageBody);
grievanceHandler.handleDescriptionInput(phoneNumber, messageBody);
break;
case AWAITING_GRIEVANCE_IMAGE:
if (messageBody.trim().equalsIgnoreCase("skip")) {
grievanceHandler.handleSkipImage(phoneNumber);
} else {
messageService.sendMessage(phoneNumber, "Please send a photo or type 'skip' / click 'Skip Image' button.");
}
break;
case MAIN_MENU:
default:
// Fallback to main menu
studentMenuHandler.sendMainMenu(phoneNumber);
break;
}
}
private void handleInteractiveListSelection(String phoneNumber, String selectedListId, UserState currentState) {
if (selectedListId.startsWith("student_")) {
// They clicked an option from the main menu
if (selectedListId.startsWith("grv_action_")) {
grievanceHandler.handleActionSelection(phoneNumber, selectedListId);
} else if (selectedListId.startsWith("grv_dept_")) {
grievanceHandler.handleDepartmentSelection(phoneNumber, selectedListId);
} else if (selectedListId.startsWith("grv_status_")) {
grievanceHandler.handleStatusSelection(phoneNumber, selectedListId);
} else if (selectedListId.startsWith("grv_delete_")) {
grievanceHandler.handleDeleteSelection(phoneNumber, selectedListId);
} else if (selectedListId.startsWith("student_")) {
studentMenuHandler.handleMenuSelection(phoneNumber, selectedListId);
} else if (selectedListId.startsWith("sem_")) {
// They clicked an option from the semester selection list
studentMenuHandler.handleSemesterSelection(phoneNumber, selectedListId);
} else if (selectedListId.startsWith("receipt_") || selectedListId.startsWith("exam_") || selectedListId.startsWith("acad_") || selectedListId.startsWith("cons_")) {
// They clicked a receipt download option
studentMenuHandler.handleReceiptSelection(phoneNumber, selectedListId);
} else {
studentMenuHandler.sendMainMenu(phoneNumber);
@@ -223,8 +244,8 @@ public class WebhookController {
return;
}
if (currentState == UserState.AWAITING_GRIEVANCE_CATEGORY) {
grievanceHandler.handleCategorySelection(phoneNumber, selectedButtonId);
if ("grv_skip_image".equals(selectedButtonId)) {
grievanceHandler.handleSkipImage(phoneNumber);
} else {
studentMenuHandler.sendMainMenu(phoneNumber);
}