Merge remote-tracking branch 'origin/bugfix/report-hotfix' into bugfix/report-hotfix
This commit is contained in:
commit
643656de0d
|
@ -512,19 +512,9 @@ public class ReportManager
|
|||
*/
|
||||
public CompletableFuture<Boolean> isHandlingReport(int accountId)
|
||||
{
|
||||
CompletableFuture<List<Long>> future = _reportRepository.getReportsHandling(accountId);
|
||||
|
||||
return future.thenApply(reportIds -> {
|
||||
for (long reportId : reportIds)
|
||||
{
|
||||
if (isActiveReport(reportId).join())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}).exceptionally(throwable -> true);
|
||||
return _reportRepository.getReportsHandling(accountId)
|
||||
.thenApply(reportIds -> reportIds.size() > 0)
|
||||
.exceptionally(throwable -> true);
|
||||
// ^ if for some reason we cannot fetch the report a user is handling
|
||||
// assume the worst and return true
|
||||
// this means we do not end up allowing a user to handle multiple reports simultaneously
|
||||
|
@ -553,22 +543,22 @@ public class ReportManager
|
|||
reportIds.stream().map(_reportRepository::getReport).collect(Collectors.toList())
|
||||
).thenCompose(UtilFuture::sequence)
|
||||
.thenApply(UtilCollections::unboxPresent)
|
||||
.thenCompose(reports -> UtilFuture.filter(reports, this::isActiveReport)).thenApply(reports ->
|
||||
{
|
||||
Report report = null;
|
||||
int size = reports.size();
|
||||
.thenApply(reports ->
|
||||
{
|
||||
Report report = null;
|
||||
int size = reports.size();
|
||||
|
||||
if (size == 1)
|
||||
{
|
||||
report = reports.get(0);
|
||||
}
|
||||
else if (size > 1)
|
||||
{
|
||||
throw new IllegalStateException("Account is handling multiple reports.");
|
||||
}
|
||||
if (size == 1)
|
||||
{
|
||||
report = reports.get(0);
|
||||
}
|
||||
else if (size > 1)
|
||||
{
|
||||
throw new IllegalStateException("Account is handling multiple reports.");
|
||||
}
|
||||
|
||||
return Optional.ofNullable(report);
|
||||
});
|
||||
return Optional.ofNullable(report);
|
||||
});
|
||||
|
||||
future.exceptionally(throwable -> Optional.empty());
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ public class ReportAbortCommand extends CommandBase<ReportPlugin>
|
|||
|
||||
reportManager.getReportHandling(player).whenComplete(BukkitFuture.complete((reportOptional, throwable) ->
|
||||
{
|
||||
if (throwable != null)
|
||||
if (throwable == null)
|
||||
{
|
||||
if (reportOptional.isPresent())
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue