feat: WhatsApp chat ownership, manual assignment and nightly repair

Conversations follow the lead's latest salesperson who is active with
BO_WHATSAPP, keep the current owner otherwise, and go unassigned when
nobody qualifies. Automatic writes are compare-and-set so they never
overwrite a WhatsApp Admin's manual assignment. leadChanged, userChanged
and assign endpoints, a 03:00 nightly job, and a system-service read of
the users of a company holding a module.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
This commit is contained in:
ngqileandClaude Opus 5.5 committed 2026-12-02 11:03:56 +08:00
1 parent 73d06795aa
commit 846c22697e
13 files changed
+1031 -3

No files matched your search

@@ -0,0 +1,35 @@
package com.solvway.services.system.controller;
import com.solvway.services.system.service.UserService;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
class UserControllerActiveWithModuleTest {
@Mock private UserService userService;
@InjectMocks private UserController controller;
@Test
void returnsTheIdsTheServiceFindsForTheCompanyAndModule() {
when(userService.findActiveAdminIdsWithModule(2L, "BO_WHATSAPP")).thenReturn(List.of(10L, 11L));
assertThat(controller.activeWithModule(2L, "BO_WHATSAPP")).containsExactly(10L, 11L);
}
@Test
void noMatchingUsersIsAnEmptyList() {
assertThat(controller.activeWithModule(3L, "BO_WHATSAPP")).isEmpty();
}
}