mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-01-29 08:01:20 +00:00
[AB-xx] improving scheduling interface
moving renaming module to int removing duplicated starboard feature validator sonar fixes
This commit is contained in:
@@ -42,7 +42,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>metrics-interface</artifactId>
|
||||
<artifactId>metrics-int</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>core-interface</artifactId>
|
||||
<artifactId>core-int</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>core-interface</artifactId>
|
||||
<artifactId>core-int</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
@@ -50,7 +50,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>metrics-interface</artifactId>
|
||||
<artifactId>metrics-int</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>core-interface</artifactId>
|
||||
<artifactId>core-int</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>core-interface</artifactId>
|
||||
<artifactId>core-int</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
@@ -56,7 +56,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>metrics-interface</artifactId>
|
||||
<artifactId>metrics-int</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -23,6 +23,7 @@ import dev.sheldan.abstracto.moderation.models.template.commands.MuteNotificatio
|
||||
import dev.sheldan.abstracto.moderation.models.template.commands.UnMuteLog;
|
||||
import dev.sheldan.abstracto.moderation.service.management.MuteManagementService;
|
||||
import dev.sheldan.abstracto.moderation.service.management.MuteRoleManagementService;
|
||||
import dev.sheldan.abstracto.scheduling.model.JobParameters;
|
||||
import dev.sheldan.abstracto.scheduling.service.SchedulerService;
|
||||
import dev.sheldan.abstracto.core.templating.model.MessageToSend;
|
||||
import dev.sheldan.abstracto.core.templating.service.TemplateService;
|
||||
@@ -31,7 +32,6 @@ import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -39,10 +39,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -209,10 +206,11 @@ public class MuteServiceBean implements MuteService {
|
||||
return null;
|
||||
} else {
|
||||
log.trace("Starting scheduled job to execute unMute.");
|
||||
JobDataMap parameters = new JobDataMap();
|
||||
parameters.putAsString("muteId", muteId);
|
||||
parameters.putAsString("serverId", serverId);
|
||||
return schedulerService.executeJobWithParametersOnce("unMuteJob", "moderation", parameters, Date.from(unMuteDate));
|
||||
HashMap<Object, Object> parameters = new HashMap<>();
|
||||
parameters.put("muteId", muteId);
|
||||
parameters.put("serverId", serverId);
|
||||
JobParameters jobParameters = JobParameters.builder().parameters(parameters).build();
|
||||
return schedulerService.executeJobWithParametersOnce("unMuteJob", "moderation", jobParameters, Date.from(unMuteDate));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>core-interface</artifactId>
|
||||
<artifactId>core-int</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>metrics-interface</artifactId>
|
||||
<artifactId>metrics-int</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>core-interface</artifactId>
|
||||
<artifactId>core-int</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>core-interface</artifactId>
|
||||
<artifactId>core-int</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>core-interface</artifactId>
|
||||
<artifactId>core-int</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
<type>test-jar</type>
|
||||
@@ -51,7 +51,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>metrics-interface</artifactId>
|
||||
<artifactId>metrics-int</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>core-interface</artifactId>
|
||||
<artifactId>core-int</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>core-interface</artifactId>
|
||||
<artifactId>core-int</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
@@ -56,7 +56,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>metrics-interface</artifactId>
|
||||
<artifactId>metrics-int</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ public interface StarboardPostReactionRepository extends JpaRepository<Starboard
|
||||
"FROM starboard_post_reaction r \n" +
|
||||
"INNER JOIN starboard_post p ON p.id = r.post_id\n" +
|
||||
"WHERE p.server_id = :serverId\n" +
|
||||
" AND p.ignored = false\n" +
|
||||
"GROUP BY r.reactor_user_in_server_id \n" +
|
||||
"ORDER BY starCount DESC \n" +
|
||||
"LIMIT :count", nativeQuery = true)
|
||||
@@ -34,6 +35,7 @@ public interface StarboardPostReactionRepository extends JpaRepository<Starboard
|
||||
"FROM starboard_post_reaction r \n" +
|
||||
"INNER JOIN starboard_post p ON p.id = r.post_id\n" +
|
||||
"WHERE p.server_id = :serverId\n" +
|
||||
" AND p.ignored = false\n" +
|
||||
"GROUP BY p.author_user_in_server_id \n" +
|
||||
"ORDER BY starCount DESC \n" +
|
||||
"LIMIT :count", nativeQuery = true)
|
||||
|
||||
@@ -23,6 +23,7 @@ public interface StarboardPostRepository extends JpaRepository<StarboardPost, Lo
|
||||
" INNER JOIN starboard_post_reaction r ON p.id = r.post_id\n" +
|
||||
" INNER JOIN user_in_server usi ON usi.user_in_server_id = p.author_user_in_server_id\n" +
|
||||
" WHERE p.server_id = :serverId\n" +
|
||||
" AND p.ignored = false\n" +
|
||||
" AND usi.user_id = :userId\n" +
|
||||
" GROUP BY p.id \n" +
|
||||
" ORDER BY starCount DESC \n" +
|
||||
@@ -31,8 +32,10 @@ public interface StarboardPostRepository extends JpaRepository<StarboardPost, Lo
|
||||
|
||||
@Query(value = "SELECT COUNT(*) AS starCount\n" +
|
||||
"FROM starboard_post_reaction r \n" +
|
||||
" INNER JOIN starboard_post p ON p.id = r.post_id \n" +
|
||||
" INNER JOIN user_in_server usi ON usi.user_in_server_id = r.reactor_user_in_server_id \n" +
|
||||
" WHERE usi.user_id = :userId \n" +
|
||||
" AND p.ignored = false\n" +
|
||||
" AND r.server_id = :serverId", nativeQuery = true)
|
||||
Long getGivenStarsOfUserInServer(Long serverId, Long userId);
|
||||
|
||||
@@ -42,6 +45,7 @@ public interface StarboardPostRepository extends JpaRepository<StarboardPost, Lo
|
||||
" INNER JOIN user_in_server usi ON usi.user_in_server_id = p.author_user_in_server_id \n" +
|
||||
" WHERE p.author_user_in_server_id = usi.user_in_server_id \n" +
|
||||
" AND usi.user_id = :userId \n" +
|
||||
" AND p.ignored = false\n" +
|
||||
" AND r.server_id = :serverId", nativeQuery = true)
|
||||
Long getReceivedStarsOfUserInServer(Long serverId, Long userId);
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import dev.sheldan.abstracto.core.service.GuildService;
|
||||
import dev.sheldan.abstracto.core.service.MemberService;
|
||||
import dev.sheldan.abstracto.core.service.management.ChannelManagementService;
|
||||
import dev.sheldan.abstracto.core.utils.FutureUtils;
|
||||
import dev.sheldan.abstracto.scheduling.model.JobParameters;
|
||||
import dev.sheldan.abstracto.scheduling.service.SchedulerService;
|
||||
import dev.sheldan.abstracto.core.templating.model.MessageToSend;
|
||||
import dev.sheldan.abstracto.core.templating.service.TemplateService;
|
||||
@@ -21,7 +22,6 @@ import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -30,6 +30,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
@@ -94,9 +95,10 @@ public class RemindServiceBean implements ReminderService {
|
||||
}
|
||||
}, remindIn.toNanos(), TimeUnit.NANOSECONDS);
|
||||
} else {
|
||||
JobDataMap parameters = new JobDataMap();
|
||||
parameters.putAsString("reminderId", reminder.getId());
|
||||
String triggerKey = schedulerService.executeJobWithParametersOnce("reminderJob", "utility", parameters, Date.from(reminder.getTargetDate()));
|
||||
HashMap<Object, Object> parameters = new HashMap<>();
|
||||
parameters.put("reminderId", reminder.getId());
|
||||
JobParameters jobParameters = JobParameters.builder().parameters(parameters).build();
|
||||
String triggerKey = schedulerService.executeJobWithParametersOnce("reminderJob", "utility", jobParameters, Date.from(reminder.getTargetDate()));
|
||||
log.info("Starting scheduled job with trigger {} to execute reminder. {}", triggerKey, reminder.getId());
|
||||
reminder.setJobTriggerKey(triggerKey);
|
||||
reminderManagementService.saveReminder(reminder);
|
||||
|
||||
@@ -49,6 +49,11 @@ public class StarboardPostManagementServiceBean implements StarboardPostManageme
|
||||
return post;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StarboardPost createStarboardPost(StarboardPost post) {
|
||||
return repository.save(post);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStarboardPostMessageId(StarboardPost post, Long messageId) {
|
||||
post.setStarboardMessageId(messageId);
|
||||
|
||||
@@ -25,7 +25,7 @@ public class StarboardPostReactorManagementServiceBean implements StarboardPostR
|
||||
private StarStatsUserConverter converter;
|
||||
|
||||
@Override
|
||||
public void addReactor(StarboardPost post, AUserInAServer user) {
|
||||
public StarboardPostReaction addReactor(StarboardPost post, AUserInAServer user) {
|
||||
StarboardPostReaction reactor = StarboardPostReaction
|
||||
.builder()
|
||||
.starboardPost(post)
|
||||
@@ -34,6 +34,7 @@ public class StarboardPostReactorManagementServiceBean implements StarboardPostR
|
||||
.build();
|
||||
log.info("Persisting the reactor {} for starboard post {} in server {}.", user.getUserReference().getId(), post.getId(), user.getServerReference().getId());
|
||||
repository.save(reactor);
|
||||
return reactor;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
package dev.sheldan.abstracto.utility.validator;
|
||||
|
||||
import dev.sheldan.abstracto.core.config.FeatureConfig;
|
||||
import dev.sheldan.abstracto.core.models.FeatureValidationResult;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import dev.sheldan.abstracto.core.service.FeatureValidatorService;
|
||||
import dev.sheldan.abstracto.core.service.management.DefaultConfigManagementService;
|
||||
import dev.sheldan.abstracto.utility.StarboardFeatureValidator;
|
||||
import dev.sheldan.abstracto.utility.config.features.StarboardFeature;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class StarboardFeatureValidatorService implements StarboardFeatureValidator {
|
||||
|
||||
@Autowired
|
||||
private FeatureValidatorService featureValidatorService;
|
||||
|
||||
@Autowired
|
||||
private DefaultConfigManagementService defaultConfigManagementService;
|
||||
|
||||
@Override
|
||||
public void featureIsSetup(FeatureConfig featureConfig, AServer server, FeatureValidationResult validationResult) {
|
||||
int levelAmount = defaultConfigManagementService.getDefaultConfig(StarboardFeature.STAR_LEVELS_CONFIG_KEY).getLongValue().intValue();
|
||||
log.info("Validating starboard feature for server {}.", server.getId());
|
||||
for(int i = 1; i <= levelAmount; i++) {
|
||||
featureValidatorService.checkSystemConfig(StarboardFeature.STAR_LVL_CONFIG_PREFIX + i, server, validationResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import dev.sheldan.abstracto.core.service.ChannelService;
|
||||
import dev.sheldan.abstracto.core.service.GuildService;
|
||||
import dev.sheldan.abstracto.core.service.MemberService;
|
||||
import dev.sheldan.abstracto.core.service.management.ChannelManagementService;
|
||||
import dev.sheldan.abstracto.scheduling.model.JobParameters;
|
||||
import dev.sheldan.abstracto.scheduling.service.SchedulerService;
|
||||
import dev.sheldan.abstracto.core.templating.model.MessageToSend;
|
||||
import dev.sheldan.abstracto.core.templating.service.TemplateService;
|
||||
@@ -118,7 +119,7 @@ public class RemindServiceBeanTest {
|
||||
when(createdReminder.getTargetDate()).thenReturn(targetDate);
|
||||
Long messageId = 5L;
|
||||
when(reminderManagementService.createReminder(any(AServerAChannelAUser.class), eq(remindText), any(Instant.class), eq(messageId))).thenReturn(createdReminder);
|
||||
when(schedulerService.executeJobWithParametersOnce(eq("reminderJob"), eq("utility"), any(JobDataMap.class), eq(Date.from(targetDate)))).thenReturn(triggerKey);
|
||||
when(schedulerService.executeJobWithParametersOnce(eq("reminderJob"), eq("utility"), any(JobParameters.class), eq(Date.from(targetDate)))).thenReturn(triggerKey);
|
||||
Reminder returnedReminder = testUnit.createReminderInForUser(aUserInAServer, remindText, duration, message);
|
||||
verify(reminderManagementService, times(1)).saveReminder(createdReminder);
|
||||
Assert.assertEquals(createdReminder, returnedReminder);
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
package dev.sheldan.abstracto.utility.validator;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.property.SystemConfigProperty;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import dev.sheldan.abstracto.core.service.FeatureValidatorService;
|
||||
import dev.sheldan.abstracto.core.service.management.DefaultConfigManagementService;
|
||||
import dev.sheldan.abstracto.utility.config.features.StarboardFeature;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.*;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class StarboardFeatureValidatorServiceTest {
|
||||
|
||||
@InjectMocks
|
||||
private StarboardFeatureValidatorService testUnit;
|
||||
|
||||
@Mock
|
||||
private FeatureValidatorService featureValidatorService;
|
||||
|
||||
@Mock
|
||||
private DefaultConfigManagementService defaultConfigManagementService;
|
||||
|
||||
@Captor
|
||||
private ArgumentCaptor<String> configKeyCaptor;
|
||||
|
||||
@Test
|
||||
public void testStarboardFeatureConfig() {
|
||||
AServer server = Mockito.mock(AServer.class);
|
||||
int levelCount = 4;
|
||||
SystemConfigProperty config = Mockito.mock(SystemConfigProperty.class);
|
||||
when(config.getLongValue()).thenReturn((long) levelCount);
|
||||
when(defaultConfigManagementService.getDefaultConfig(StarboardFeature.STAR_LEVELS_CONFIG_KEY)).thenReturn(config);
|
||||
|
||||
testUnit.featureIsSetup(null, server, null);
|
||||
verify(featureValidatorService, times(levelCount)).checkSystemConfig(configKeyCaptor.capture(), eq(server), any());
|
||||
List<String> allValues = configKeyCaptor.getAllValues();
|
||||
for (int i = 0; i < allValues.size(); i++) {
|
||||
String key = allValues.get(i);
|
||||
Assert.assertEquals(StarboardFeature.STAR_LVL_CONFIG_PREFIX + ( i + 1 ), key);
|
||||
}
|
||||
Assert.assertEquals(levelCount, allValues.size());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package dev.sheldan.abstracto.utility;
|
||||
|
||||
import dev.sheldan.abstracto.core.service.FeatureValidator;
|
||||
|
||||
public interface StarboardFeatureValidator extends FeatureValidator {
|
||||
}
|
||||
@@ -3,9 +3,7 @@ package dev.sheldan.abstracto.utility.config.features;
|
||||
import dev.sheldan.abstracto.core.config.FeatureConfig;
|
||||
import dev.sheldan.abstracto.core.config.FeatureEnum;
|
||||
import dev.sheldan.abstracto.core.config.PostTargetEnum;
|
||||
import dev.sheldan.abstracto.core.service.FeatureValidator;
|
||||
import dev.sheldan.abstracto.core.service.management.DefaultConfigManagementService;
|
||||
import dev.sheldan.abstracto.utility.StarboardFeatureValidator;
|
||||
import dev.sheldan.abstracto.utility.config.posttargets.StarboardPostTarget;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -22,9 +20,6 @@ public class StarboardFeature implements FeatureConfig {
|
||||
public static final String STAR_BADGE_EMOTE_PREFIX = "starboardBadge";
|
||||
public static final String STAR_LEVELS_CONFIG_KEY = "starLvls";
|
||||
|
||||
@Autowired
|
||||
private StarboardFeatureValidator starboardFeatureValidator;
|
||||
|
||||
@Autowired
|
||||
private DefaultConfigManagementService defaultConfigManagementService;
|
||||
|
||||
@@ -38,11 +33,6 @@ public class StarboardFeature implements FeatureConfig {
|
||||
return Arrays.asList(StarboardPostTarget.STARBOARD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FeatureValidator> getAdditionalFeatureValidators() {
|
||||
return Arrays.asList(starboardFeatureValidator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRequiredSystemConfigKeys() {
|
||||
List<String> configKeys = new ArrayList<>();
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.Optional;
|
||||
|
||||
public interface StarboardPostManagementService {
|
||||
StarboardPost createStarboardPost(CachedMessage starredMessage, AUserInAServer starredUser, AServerAChannelMessage starboardPost);
|
||||
StarboardPost createStarboardPost(StarboardPost post);
|
||||
void setStarboardPostMessageId(StarboardPost post, Long messageId);
|
||||
List<StarboardPost> retrieveTopPosts(Long serverId, Integer count);
|
||||
List<StarboardPost> retrieveTopPostsForUserInServer(Long serverId, Long userId, Integer count);
|
||||
|
||||
@@ -2,13 +2,14 @@ package dev.sheldan.abstracto.utility.service.management;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||
import dev.sheldan.abstracto.utility.models.database.StarboardPost;
|
||||
import dev.sheldan.abstracto.utility.models.database.StarboardPostReaction;
|
||||
import dev.sheldan.abstracto.utility.models.template.commands.starboard.StarStatsUser;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface StarboardPostReactorManagementService {
|
||||
void addReactor(StarboardPost post, AUserInAServer user);
|
||||
StarboardPostReaction addReactor(StarboardPost post, AUserInAServer user);
|
||||
void removeReactor(StarboardPost post, AUserInAServer user);
|
||||
void removeReactors(StarboardPost post);
|
||||
Integer getStarCount(Long serverId);
|
||||
|
||||
@@ -98,14 +98,14 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>core-interface</artifactId>
|
||||
<artifactId>core-int</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>core-interface</artifactId>
|
||||
<artifactId>core-int</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
<type>test-jar</type>
|
||||
@@ -140,7 +140,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>metrics-interface</artifactId>
|
||||
<artifactId>metrics-int</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ public class MessageCacheBean implements MessageCache {
|
||||
@Override
|
||||
@Cacheable(key = "#messageId.toString()")
|
||||
public CompletableFuture<CachedMessage> getMessageFromCache(Long guildId, Long textChannelId, Long messageId) {
|
||||
log.trace("Retrieving message with parameters");
|
||||
log.trace("Retrieving message {} with parameters.", messageId);
|
||||
return concreteSelf.loadMessage(guildId, textChannelId, messageId);
|
||||
}
|
||||
|
||||
@@ -85,7 +85,10 @@ public class MessageCacheBean implements MessageCache {
|
||||
future.completeExceptionally(throwable);
|
||||
return null;
|
||||
})
|
||||
);
|
||||
).exceptionally(throwable -> {
|
||||
log.error("Failed to load message for caching.", throwable);
|
||||
return null;
|
||||
});
|
||||
} else {
|
||||
log.error("Not able to load message {} in channel {} in guild {}. Text channel not found.", messageId, textChannelId, guildId);
|
||||
future.completeExceptionally(new ChannelNotInGuildException(textChannelId));
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<artifactId>core-interface</artifactId>
|
||||
<artifactId>core-int</artifactId>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user