mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-09-16 11:28:15 +00:00
[SONAR] fixing major sonar issues
This commit is contained in:
@@ -685,8 +685,7 @@ public class AssignableRolePlaceServiceBean implements AssignableRolePlaceServic
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public CompletableFuture<Void> addEmotes(List<CompletableFuture<Message>> assignablePlacePostsMessageFutures, String placeKey) {
|
public CompletableFuture<Void> addEmotes(List<CompletableFuture<Message>> assignablePlacePostsMessageFutures, String placeKey) {
|
||||||
try {
|
Message firstMessage = assignablePlacePostsMessageFutures.get(0).join();
|
||||||
Message firstMessage = assignablePlacePostsMessageFutures.get(0).get();
|
|
||||||
Long serverId = firstMessage.getGuild().getIdLong();
|
Long serverId = firstMessage.getGuild().getIdLong();
|
||||||
|
|
||||||
AServer innerServer = serverManagementService.loadOrCreate(serverId);
|
AServer innerServer = serverManagementService.loadOrCreate(serverId);
|
||||||
@@ -696,7 +695,7 @@ public class AssignableRolePlaceServiceBean implements AssignableRolePlaceServic
|
|||||||
List<CompletableFuture<Void>> reactionFutures = new ArrayList<>();
|
List<CompletableFuture<Void>> reactionFutures = new ArrayList<>();
|
||||||
int usedEmotes = 0;
|
int usedEmotes = 0;
|
||||||
for (CompletableFuture<Message> messageCompletableFuture : assignablePlacePostsMessageFutures) {
|
for (CompletableFuture<Message> messageCompletableFuture : assignablePlacePostsMessageFutures) {
|
||||||
Message sentMessage = messageCompletableFuture.get();
|
Message sentMessage = messageCompletableFuture.join();
|
||||||
// this uses the actual embed count as a limit, so this relies on fields to be used for description, if this changes, this needs to be changed
|
// this uses the actual embed count as a limit, so this relies on fields to be used for description, if this changes, this needs to be changed
|
||||||
MessageEmbed embed = sentMessage.getEmbeds().get(0);
|
MessageEmbed embed = sentMessage.getEmbeds().get(0);
|
||||||
List<AssignableRole> firstRoles = roleStream.subList(usedEmotes, usedEmotes + embed.getFields().size());
|
List<AssignableRole> firstRoles = roleStream.subList(usedEmotes, usedEmotes + embed.getFields().size());
|
||||||
@@ -709,11 +708,6 @@ public class AssignableRolePlaceServiceBean implements AssignableRolePlaceServic
|
|||||||
self.storeCreatedAssignableRolePlacePosts(placeKey, serverId, assignablePlacePostsMessageFutures);
|
self.storeCreatedAssignableRolePlacePosts(placeKey, serverId, assignablePlacePostsMessageFutures);
|
||||||
return CompletableFuture.completedFuture(null);
|
return CompletableFuture.completedFuture(null);
|
||||||
});
|
});
|
||||||
} catch (InterruptedException | ExecutionException e) {
|
|
||||||
log.error("Failed to process future from sending assignable place posts messages.", e);
|
|
||||||
throw new AbstractoRunTimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
|||||||
@@ -30,11 +30,8 @@ public class ServerManagementServiceBean implements ServerManagementService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AServer loadOrCreate(Long id) {
|
public AServer loadOrCreate(Long id) {
|
||||||
if(repository.existsById(id)) {
|
Optional<AServer> optional = repository.findById(id);
|
||||||
return repository.findById(id).get();
|
return optional.orElseGet(() -> createServer(id));
|
||||||
} else {
|
|
||||||
return createServer(id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import net.dv8tion.jda.api.entities.Member;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class UserManagementServiceBean implements UserManagementService {
|
public class UserManagementServiceBean implements UserManagementService {
|
||||||
@@ -29,10 +31,7 @@ public class UserManagementServiceBean implements UserManagementService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AUser loadUser(Long userId) {
|
public AUser loadUser(Long userId) {
|
||||||
if(userRepository.existsById(userId)) {
|
Optional<AUser> optional = userRepository.findById(userId);
|
||||||
return userRepository.findById(userId).get();
|
return optional.orElseGet(() -> this.createUser(userId));
|
||||||
} else {
|
|
||||||
return this.createUser(userId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user