Ensure suspect messages actually involved the reporter
This commit is contained in:
parent
efe532e8a6
commit
9af606ae20
@ -126,7 +126,6 @@ public class ReportManager
|
|||||||
*/
|
*/
|
||||||
public CompletableFuture<Report> createReport(int reporterId, int suspectId, ReportCategory category, String message)
|
public CompletableFuture<Report> createReport(int reporterId, int suspectId, ReportCategory category, String message)
|
||||||
{
|
{
|
||||||
// TODO only allow report if suspect actually did something
|
|
||||||
return fetchOrCreateReport(suspectId, category).whenComplete((report, throwable) ->
|
return fetchOrCreateReport(suspectId, category).whenComplete((report, throwable) ->
|
||||||
{
|
{
|
||||||
if (report != null)
|
if (report != null)
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
package mineplex.core.report.ui;
|
package mineplex.core.report.ui;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import mineplex.core.account.CoreClient;
|
import mineplex.core.account.CoreClient;
|
||||||
|
import mineplex.core.chatsnap.SnapshotManager;
|
||||||
|
import mineplex.core.chatsnap.SnapshotMessage;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
@ -69,7 +73,12 @@ public class ReportCategoryPage extends SimpleGui
|
|||||||
|
|
||||||
private boolean hasSentMessage(int accountId)
|
private boolean hasSentMessage(int accountId)
|
||||||
{
|
{
|
||||||
return _plugin.getReportManager().getSnapshotManager().getMessagesFrom(accountId).size() > 0;
|
SnapshotManager snapshotManager = _plugin.getReportManager().getSnapshotManager();
|
||||||
|
List<SnapshotMessage> suspectMessages = snapshotManager.getMessagesFrom(accountId).stream()
|
||||||
|
.filter(message -> message.getRecipientIds().contains(_suspect.getAccountId()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
return suspectMessages.size() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createReport(ReportCategory category)
|
private void createReport(ReportCategory category)
|
||||||
|
Loading…
Reference in New Issue
Block a user