mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-05 00:53:04 +00:00
[AB-302] refactoring assignable roles to use buttons instead of reactions
moved button related services to component service instead of message service adding component type to component payload renamed async role service methods ignoring bot reactions in starboard fixing rank not showing correct experience to next level for other members
This commit is contained in:
@@ -188,7 +188,7 @@ public class MuteServiceBean implements MuteService {
|
||||
@Override
|
||||
public CompletableFuture<Void> applyMuteRole(AUserInAServer aUserInAServer) {
|
||||
MuteRole muteRole = muteRoleManagementService.retrieveMuteRoleForServer(aUserInAServer.getServerReference());
|
||||
return roleService.addRoleToUserFuture(aUserInAServer, muteRole.getRole());
|
||||
return roleService.addRoleToUserAsync(aUserInAServer, muteRole.getRole());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -300,7 +300,7 @@ public class MuteServiceBean implements MuteService {
|
||||
MuteRole muteRole = muteRoleManagementService.retrieveMuteRoleForServer(mutingServer);
|
||||
log.debug("Using the mute role {} mapping to role {}", muteRole.getId(), muteRole.getRole().getId());
|
||||
Guild guild = guildService.getGuildById(mutingServer.getId());
|
||||
CompletableFuture<Void> roleRemovalFuture = roleService.removeRoleFromUserFuture(mute.getMutedUser(), muteRole.getRole());
|
||||
CompletableFuture<Void> roleRemovalFuture = roleService.removeRoleFromUserAsync(mute.getMutedUser(), muteRole.getRole());
|
||||
CompletableFuture<Member> mutingMemberFuture = memberService.getMemberInServerAsync(mute.getMutingUser());
|
||||
CompletableFuture<Member> mutedMemberFuture = memberService.getMemberInServerAsync(mute.getMutedUser());
|
||||
CompletableFuture<Void> finalFuture = new CompletableFuture<>();
|
||||
|
||||
@@ -8,8 +8,6 @@ import dev.sheldan.abstracto.core.service.*;
|
||||
import dev.sheldan.abstracto.core.service.management.ChannelManagementService;
|
||||
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
|
||||
import dev.sheldan.abstracto.core.service.management.UserInServerManagementService;
|
||||
import dev.sheldan.abstracto.moderation.config.feature.ModerationFeatureDefinition;
|
||||
import dev.sheldan.abstracto.moderation.config.feature.mode.MutingMode;
|
||||
import dev.sheldan.abstracto.moderation.config.posttarget.MutingPostTarget;
|
||||
import dev.sheldan.abstracto.moderation.exception.MuteRoleNotSetupException;
|
||||
import dev.sheldan.abstracto.moderation.exception.NoMuteFoundException;
|
||||
@@ -165,7 +163,7 @@ public class MuteServiceBeanTest {
|
||||
when(templateService.renderTemplate(eq(MUTE_NOTIFICATION_TEMPLATE), any(MuteNotification.class), eq(SERVER_ID))).thenReturn(NOTIFICATION_TEXT);
|
||||
|
||||
when(messageService.sendMessageToUser(jdaUserBeingMuted, NOTIFICATION_TEXT)).thenReturn(CompletableFuture.completedFuture(null));
|
||||
when(roleService.addRoleToUserFuture(userBeingMuted, aRole)).thenReturn(CompletableFuture.completedFuture(null));
|
||||
when(roleService.addRoleToUserAsync(userBeingMuted, aRole)).thenReturn(CompletableFuture.completedFuture(null));
|
||||
|
||||
CompletableFuture<Void> future = testUnit.muteUserInServer(mutedUser, mutingUser, REASON, unMuteDate, cause);
|
||||
future.join();
|
||||
@@ -199,7 +197,7 @@ public class MuteServiceBeanTest {
|
||||
String notificationText = "text";
|
||||
when(templateService.renderTemplate(eq(MUTE_NOTIFICATION_TEMPLATE), any(MuteNotification.class), eq(SERVER_ID))).thenReturn(notificationText);
|
||||
when(messageService.sendMessageToUser(memberBeingMuted.getUser(), notificationText)).thenReturn(CompletableFuture.completedFuture(null));
|
||||
when(roleService.addRoleToUserFuture(userBeingMuted, muteRole.getRole())).thenReturn(CompletableFuture.completedFuture(null));
|
||||
when(roleService.addRoleToUserAsync(userBeingMuted, muteRole.getRole())).thenReturn(CompletableFuture.completedFuture(null));
|
||||
CompletableFuture<Void> future = testUnit.muteUserInServer(mutedUser, mutingUser, REASON, unMuteDate, cause);
|
||||
future.join();
|
||||
Assert.assertFalse(future.isCompletedExceptionally() );
|
||||
@@ -245,7 +243,7 @@ public class MuteServiceBeanTest {
|
||||
String notificationText = "text";
|
||||
when(templateService.renderTemplate(eq(MUTE_NOTIFICATION_TEMPLATE), any(MuteNotification.class), eq(SERVER_ID))).thenReturn(notificationText);
|
||||
when(messageService.sendMessageToUser(memberBeingMuted.getUser(), notificationText)).thenReturn(CompletableFuture.completedFuture(null));
|
||||
when(roleService.addRoleToUserFuture(userBeingMuted, muteRole.getRole())).thenReturn(CompletableFuture.completedFuture(null));
|
||||
when(roleService.addRoleToUserAsync(userBeingMuted, muteRole.getRole())).thenReturn(CompletableFuture.completedFuture(null));
|
||||
testUnit.muteMember(memberBeingMuted, memberMuting, REASON, unMuteDate, cause);
|
||||
verifyDirectMute();
|
||||
}
|
||||
@@ -274,7 +272,7 @@ public class MuteServiceBeanTest {
|
||||
when(templateService.renderTemplate(eq(MUTE_NOTIFICATION_TEMPLATE), any(MuteNotification.class), eq(SERVER_ID))).thenReturn(notificationText);
|
||||
when(messageService.sendMessageToUser(memberBeingMuted.getUser(), notificationText)).thenReturn(CompletableFuture.completedFuture(null));
|
||||
when(templateService.renderEmbedTemplate(eq(MuteServiceBean.MUTE_LOG_TEMPLATE), any(MuteContext.class), eq(SERVER_ID))).thenReturn(messageToSend);
|
||||
when(roleService.addRoleToUserFuture(userBeingMuted, muteRole.getRole())).thenReturn(CompletableFuture.completedFuture(null));
|
||||
when(roleService.addRoleToUserAsync(userBeingMuted, muteRole.getRole())).thenReturn(CompletableFuture.completedFuture(null));
|
||||
testUnit.muteMemberWithLog(muteLog);
|
||||
verifyDirectMute();
|
||||
verify(templateService, times(1)).renderEmbedTemplate(eq(MuteServiceBean.MUTE_LOG_TEMPLATE), any(MuteContext.class), eq(SERVER_ID));
|
||||
@@ -303,7 +301,7 @@ public class MuteServiceBeanTest {
|
||||
String notificationText = "text";
|
||||
when(templateService.renderTemplate(eq(MUTE_NOTIFICATION_TEMPLATE), any(MuteNotification.class), eq(SERVER_ID))).thenReturn(notificationText);
|
||||
when(messageService.sendMessageToUser(memberBeingMuted.getUser(), notificationText)).thenReturn(CompletableFuture.completedFuture(null));
|
||||
when(roleService.addRoleToUserFuture(userBeingMuted, muteRole.getRole())).thenReturn(CompletableFuture.completedFuture(null));
|
||||
when(roleService.addRoleToUserAsync(userBeingMuted, muteRole.getRole())).thenReturn(CompletableFuture.completedFuture(null));
|
||||
testUnit.muteMemberWithLog(muteLog);
|
||||
verifyDirectMute();
|
||||
verify(postTargetService, times(0)).sendEmbedInPostTarget(messageToSend, MutingPostTarget.MUTE_LOG, SERVER_ID);
|
||||
@@ -331,7 +329,7 @@ public class MuteServiceBeanTest {
|
||||
when(muteRoleManagementService.retrieveMuteRoleForServer(server)).thenReturn(muteRole);
|
||||
when(muteRole.getRole()).thenReturn(aRole);
|
||||
when(muteManagementService.findMuteOptional(MUTE_ID, SERVER_ID)).thenReturn(Optional.of(mute));
|
||||
when(roleService.removeRoleFromUserFuture(userBeingMuted, aRole)).thenReturn(CompletableFuture.completedFuture(null));
|
||||
when(roleService.removeRoleFromUserAsync(userBeingMuted, aRole)).thenReturn(CompletableFuture.completedFuture(null));
|
||||
when(memberService.getMemberInServerAsync(userBeingMuted)).thenReturn(CompletableFuture.completedFuture(memberBeingMuted));
|
||||
when(memberService.getMemberInServerAsync(userMuting)).thenReturn(CompletableFuture.completedFuture(memberMuting));
|
||||
testUnit.endMute(MUTE_ID, SERVER_ID);
|
||||
@@ -430,7 +428,7 @@ public class MuteServiceBeanTest {
|
||||
when(muteRoleManagementService.retrieveMuteRoleForServer(server)).thenReturn(muteRole);
|
||||
when(muteRole.getRole()).thenReturn(aRole);
|
||||
setupUnMuteMocks();
|
||||
when(roleService.removeRoleFromUserFuture(userBeingMuted, aRole)).thenReturn(CompletableFuture.completedFuture(null));
|
||||
when(roleService.removeRoleFromUserAsync(userBeingMuted, aRole)).thenReturn(CompletableFuture.completedFuture(null));
|
||||
when(memberService.getMemberInServerAsync(userBeingMuted)).thenReturn(CompletableFuture.completedFuture(memberBeingMuted));
|
||||
when(memberService.getMemberInServerAsync(userMuting)).thenReturn(CompletableFuture.completedFuture(memberMuting));
|
||||
testUnit.unMuteUser(userBeingMuted);
|
||||
|
||||
Reference in New Issue
Block a user