Do away with tokens

This commit is contained in:
Keir Nellyer 2016-06-24 17:59:26 +01:00
parent 45418b3a4d
commit 52873d5618
3 changed files with 5 additions and 29 deletions

View File

@ -21,9 +21,9 @@ public class SnapshotRepository extends MinecraftRepository
{
private static final ZoneId ZONE_ID = ZoneId.of("America/Chicago"); // This means "CST"
public static String getURL(String token)
public static String getURL(long reportId)
{
return URL_PREFIX + token;
return URL_PREFIX + reportId;
}
private static final String URL_PREFIX = "http://file.mineplex.com/chatsnap/view.php?identifier=";

View File

@ -5,8 +5,6 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
import org.apache.commons.lang3.RandomStringUtils;
/**
* Contains data about a report.
*/
@ -19,7 +17,6 @@ public class Report
private final Map<Integer, ReportMessage> _reportMessages = new HashMap<>();
private Integer _handlerId = null;
private ReportResult _reportResult = null;
private String _token = null;
public Report(int suspectId, ReportCategory category)
{
@ -83,28 +80,6 @@ public class Report
_reportResult = reportResult;
}
public boolean hasToken()
{
return _token != null;
}
/**
* Gets a token in the format of reportId-randomCharacters.
* Currently this is only used for publishing chat abuse reports.
*
* @return the full token
*/
public String getToken()
{
// since we don't always use this, only generate a token when we need it
if (_token == null)
{
_token = RandomStringUtils.randomAlphabetic(8);
}
return _reportId + "-" + _token;
}
public ReportMessage getLatestMessage()
{
ReportMessage latest = null;

View File

@ -9,6 +9,7 @@ import mineplex.core.common.jsonchat.ClickEvent;
import mineplex.core.common.jsonchat.JsonMessage;
import mineplex.core.common.util.C;
import mineplex.core.report.Report;
import mineplex.core.report.ReportCategory;
import mineplex.core.report.ReportManager;
import mineplex.core.report.ReportMessage;
import mineplex.core.report.command.ReportHandlerNotification;
@ -50,8 +51,8 @@ public class ReportHandlerMessageTask extends BukkitRunnable
.add("\n\n")
.add(C.cAqua + "Suspect: " + C.cGold + suspectName)
.add("\n")
.add((_report.hasToken() ? C.cAqua + "Chat Log: " + C.cGold + "Click Here" + "\n" : ""))
.click(ClickEvent.OPEN_URL, SnapshotRepository.getURL(_report.getToken()))
.add((_report.getCategory() == ReportCategory.CHAT_ABUSE ? C.cAqua + "Chat Log: " + C.cGold + "Click Here" + "\n" : ""))
.click(ClickEvent.OPEN_URL, SnapshotRepository.getURL(reportId))
.add("\n")
.add(C.cAqua + "Type " + C.cGold + "/reportclose " + reportId + " <reason>" + C.cAqua + " to close this report.")
.click(ClickEvent.SUGGEST_COMMAND, "/reportclose " + reportId)