parent
450c4bae8c
commit
4590c63c38
|
@ -38,8 +38,8 @@ object Mod extends LilaController {
|
||||||
|
|
||||||
def booster(username: String, v: Boolean) = Secure(_.MarkBooster) { implicit ctx => me =>
|
def booster(username: String, v: Boolean) = Secure(_.MarkBooster) { implicit ctx => me =>
|
||||||
withSuspect(username) { sus =>
|
withSuspect(username) { sus =>
|
||||||
modApi.setBooster(AsMod(me), sus, v)
|
modApi.setBooster(AsMod(me), sus, v) inject redirect(username)
|
||||||
} >> User.modZoneOrRedirect(username, me)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def troll(username: String, v: Boolean) = SecureBody(_.MarkTroll) { implicit ctx => me =>
|
def troll(username: String, v: Boolean) = SecureBody(_.MarkTroll) { implicit ctx => me =>
|
||||||
|
@ -69,38 +69,38 @@ object Mod extends LilaController {
|
||||||
def ban(username: String, v: Boolean) = Secure(_.IpBan) { implicit ctx => me =>
|
def ban(username: String, v: Boolean) = Secure(_.IpBan) { implicit ctx => me =>
|
||||||
withSuspect(username) { sus =>
|
withSuspect(username) { sus =>
|
||||||
modApi.setBan(AsMod(me), sus, v)
|
modApi.setBan(AsMod(me), sus, v)
|
||||||
} >> User.modZoneOrRedirect(username, me)
|
} inject redirect(username)
|
||||||
}
|
}
|
||||||
|
|
||||||
def deletePmsAndChats(username: String) = Secure(_.MarkTroll) { implicit ctx => me =>
|
def deletePmsAndChats(username: String) = Secure(_.MarkTroll) { implicit ctx => me =>
|
||||||
withSuspect(username) { sus =>
|
withSuspect(username) { sus =>
|
||||||
Env.mod.publicChat.delete(sus) >>
|
Env.mod.publicChat.delete(sus) >>
|
||||||
Env.message.api.deleteThreadsBy(sus.user)
|
Env.message.api.deleteThreadsBy(sus.user)
|
||||||
} >> User.modZoneOrRedirect(username, me)
|
} inject redirect(username)
|
||||||
}
|
}
|
||||||
|
|
||||||
def closeAccount(username: String) = Secure(_.CloseAccount) { implicit ctx => me =>
|
def closeAccount(username: String) = Secure(_.CloseAccount) { implicit ctx => me =>
|
||||||
modApi.closeAccount(me.id, username).flatMap {
|
modApi.closeAccount(me.id, username) flatMap {
|
||||||
_ ?? { user =>
|
_ ?? { user =>
|
||||||
Env.current.closeAccount(user.id, self = false)
|
Env.current.closeAccount(user.id, self = false)
|
||||||
}
|
}
|
||||||
} >> User.modZoneOrRedirect(username, me)
|
} inject redirect(username)
|
||||||
}
|
}
|
||||||
|
|
||||||
def reopenAccount(username: String) = Secure(_.ReopenAccount) { implicit ctx => me =>
|
def reopenAccount(username: String) = Secure(_.ReopenAccount) { implicit ctx => me =>
|
||||||
modApi.reopenAccount(me.id, username) >> User.modZoneOrRedirect(username, me)
|
modApi.reopenAccount(me.id, username) inject redirect(username)
|
||||||
}
|
}
|
||||||
|
|
||||||
def reportban(username: String, v: Boolean) = Secure(_.ReportBan) { implicit ctx => me =>
|
def reportban(username: String, v: Boolean) = Secure(_.ReportBan) { implicit ctx => me =>
|
||||||
withSuspect(username) { sus =>
|
withSuspect(username) { sus =>
|
||||||
modApi.setReportban(AsMod(me), sus, v)
|
modApi.setReportban(AsMod(me), sus, v) inject redirect(username)
|
||||||
} >> User.modZoneOrRedirect(username, me)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def rankban(username: String, v: Boolean) = Secure(_.RemoveRanking) { implicit ctx => me =>
|
def rankban(username: String, v: Boolean) = Secure(_.RemoveRanking) { implicit ctx => me =>
|
||||||
withSuspect(username) { sus =>
|
withSuspect(username) { sus =>
|
||||||
modApi.setRankban(AsMod(me), sus, v)
|
modApi.setRankban(AsMod(me), sus, v) inject redirect(username)
|
||||||
} >> User.modZoneOrRedirect(username, me)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def impersonate(username: String) = Auth { implicit ctx => me =>
|
def impersonate(username: String) = Auth { implicit ctx => me =>
|
||||||
|
@ -141,8 +141,8 @@ object Mod extends LilaController {
|
||||||
|
|
||||||
def notifySlack(username: String) = Auth { implicit ctx => me =>
|
def notifySlack(username: String) = Auth { implicit ctx => me =>
|
||||||
OptionFuResult(UserRepo named username) { user =>
|
OptionFuResult(UserRepo named username) { user =>
|
||||||
Env.slack.api.userMod(user = user, mod = me)
|
Env.slack.api.userMod(user = user, mod = me) inject redirect(user.username)
|
||||||
} >> User.modZoneOrRedirect(username, me)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def log = Secure(_.SeeReport) { implicit ctx => me =>
|
def log = Secure(_.SeeReport) { implicit ctx => me =>
|
||||||
|
@ -194,8 +194,8 @@ object Mod extends LilaController {
|
||||||
|
|
||||||
def refreshUserAssess(username: String) = Secure(_.MarkEngine) { implicit ctx => me =>
|
def refreshUserAssess(username: String) = Secure(_.MarkEngine) { implicit ctx => me =>
|
||||||
assessApi.refreshAssessByUsername(username) >>
|
assessApi.refreshAssessByUsername(username) >>
|
||||||
Env.irwin.api.requests.fromMod(SuspectId normalize username, me) >>
|
Env.irwin.api.requests.fromMod(SuspectId normalize username, me) inject
|
||||||
User.modZoneOrRedirect(username, me)
|
redirect(username)
|
||||||
}
|
}
|
||||||
|
|
||||||
def spontaneousInquiry(username: String) = Secure(_.SeeReport) { implicit ctx => me =>
|
def spontaneousInquiry(username: String) = Secure(_.SeeReport) { implicit ctx => me =>
|
||||||
|
|
|
@ -57,9 +57,10 @@ object Report extends LilaController {
|
||||||
case _ => false
|
case _ => false
|
||||||
}
|
}
|
||||||
inquiry match {
|
inquiry match {
|
||||||
case None =>
|
case None => {
|
||||||
goTo.fold(Redirect(routes.Report.list).fuccess) { s =>
|
goTo.fold(Redirect(routes.Report.list)) { s =>
|
||||||
User.modZoneOrRedirect(s.user.username, me)
|
Mod.redirect(s.user.username)
|
||||||
|
}.fuccess
|
||||||
}
|
}
|
||||||
case Some(prev) =>
|
case Some(prev) =>
|
||||||
def redirectToList = Redirect(routes.Report.listWithFilter(prev.room.key))
|
def redirectToList = Redirect(routes.Report.listWithFilter(prev.room.key))
|
||||||
|
@ -70,7 +71,7 @@ object Report extends LilaController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (force) User.modZoneOrRedirect(prev.user, me)
|
else if (force) Redirect(s"${routes.User.show(prev.user)}?mod").fuccess
|
||||||
else api.inquiries.toggle(AsMod(me), prev.id) map {
|
else api.inquiries.toggle(AsMod(me), prev.id) map {
|
||||||
_.fold(redirectToList)(onInquiryStart)
|
_.fold(redirectToList)(onInquiryStart)
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,12 +240,7 @@ object User extends LilaController {
|
||||||
}
|
}
|
||||||
|
|
||||||
def mod(username: String) = Secure(_.UserSpy) { implicit ctx => me =>
|
def mod(username: String) = Secure(_.UserSpy) { implicit ctx => me =>
|
||||||
modZoneOrRedirect(username, me)
|
if (Env.streamer.liveStreamApi.isStreaming(me.id)) fuccess(Ok("Disabled while streaming"))
|
||||||
}
|
|
||||||
|
|
||||||
protected[controllers] def modZoneOrRedirect(username: String, me: UserModel)(implicit ctx: Context): Fu[Result] =
|
|
||||||
if (HTTPRequest isSynchronousHttp ctx.req) fuccess(Mod.redirect(username))
|
|
||||||
else if (Env.streamer.liveStreamApi.isStreaming(me.id)) fuccess(Ok("Disabled while streaming"))
|
|
||||||
else OptionFuOk(UserRepo named username) { user =>
|
else OptionFuOk(UserRepo named username) { user =>
|
||||||
UserRepo.emails(user.id) zip
|
UserRepo.emails(user.id) zip
|
||||||
(Env.security userSpy user) zip
|
(Env.security userSpy user) zip
|
||||||
|
@ -267,6 +262,7 @@ object User extends LilaController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def writeNote(username: String) = AuthBody { implicit ctx => me =>
|
def writeNote(username: String) = AuthBody { implicit ctx => me =>
|
||||||
OptionFuResult(UserRepo named username) { user =>
|
OptionFuResult(UserRepo named username) { user =>
|
||||||
|
|
|
@ -8,63 +8,63 @@
|
||||||
<form method="post" action="@routes.Mod.spontaneousInquiry(u.username)" data-hint="Start an inquiry" class="hint--bottom">
|
<form method="post" action="@routes.Mod.spontaneousInquiry(u.username)" data-hint="Start an inquiry" class="hint--bottom">
|
||||||
<button class="button inquiry" type="submit"><i></i></button>
|
<button class="button inquiry" type="submit"><i></i></button>
|
||||||
</form>
|
</form>
|
||||||
<form method="post" action="@routes.Mod.refreshUserAssess(u.username)" data-hint="Collect data and analyze if the user is suspicious." class="hint--bottom xhr">
|
<form method="post" action="@routes.Mod.refreshUserAssess(u.username)" data-hint="Collect data and analyze if the user is suspicious." class="hint--bottom">
|
||||||
<input class="button" type="submit" value="Evaluate" />
|
<input class="button" type="submit" value="Evaluate" />
|
||||||
</form>
|
</form>
|
||||||
@if(isGranted(_.MarkTroll)) {
|
@if(isGranted(_.MarkTroll)) {
|
||||||
<a class="button hint--bottom" href="@routes.Mod.communicationPublic(u.id)" data-hint="View communications">Comms</a>
|
<a class="button hint--bottom" href="@routes.Mod.communicationPublic(u.id)" data-hint="View communications">Comms</a>
|
||||||
}
|
}
|
||||||
<form method="post" action="@routes.Mod.notifySlack(u.id)" data-hint="Notify slack #tavern" class="hint--bottom xhr">
|
<form method="post" action="@routes.Mod.notifySlack(u.id)" data-hint="Notify slack #tavern" class="hint--bottom">
|
||||||
<input class="button" type="submit" value="Slack" />
|
<input class="button" type="submit" value="Slack" />
|
||||||
</form>
|
</form>
|
||||||
•
|
•
|
||||||
}
|
}
|
||||||
@if(isGranted(_.MarkEngine)) {
|
@if(isGranted(_.MarkEngine)) {
|
||||||
<form method="post" action="@routes.Mod.engine(u.username, !u.engine)" data-hint="This user is clearly cheating." class="hint--bottom xhr">
|
<form method="post" action="@routes.Mod.engine(u.username, !u.engine)" data-hint="This user is clearly cheating." class="hint--bottom">
|
||||||
<input class="button@when(u.engine, " active")" type="submit" value="Engine" />
|
<input class="button@when(u.engine, " active")" type="submit" value="Engine" />
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
@if(isGranted(_.MarkBooster)) {
|
@if(isGranted(_.MarkBooster)) {
|
||||||
<form method="post" action="@routes.Mod.booster(u.username, !u.booster)" data-hint="Marks the user as a booster or sandbagger." class="hint--bottom xhr">
|
<form method="post" action="@routes.Mod.booster(u.username, !u.booster)" data-hint="Marks the user as a booster or sandbagger." class="hint--bottom">
|
||||||
<input class="button@when(u.booster, " active")" type="submit" value="Booster" />
|
<input class="button@when(u.booster, " active")" type="submit" value="Booster" />
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
@if(isGranted(_.MarkTroll)) {
|
@if(isGranted(_.MarkTroll)) {
|
||||||
<form method="post" action="@routes.Mod.troll(u.username, !u.troll)" data-hint="@if(u.troll){En}else{Dis}able communication features for this user." class="hint--bottom xhr">
|
<form method="post" action="@routes.Mod.troll(u.username, !u.troll)" data-hint="@if(u.troll){En}else{Dis}able communication features for this user." class="hint--bottom">
|
||||||
<input class="button@when(u.troll, " active")" type="submit" value="Shadowban" />
|
<input class="button@when(u.troll, " active")" type="submit" value="Shadowban" />
|
||||||
</form>
|
</form>
|
||||||
@if(u.troll) {
|
@if(u.troll) {
|
||||||
<form method="post" action="@routes.Mod.deletePmsAndChats(u.username)" data-hint="Delete all PMs and public chat messages" class="hint--bottom xhr">
|
<form method="post" action="@routes.Mod.deletePmsAndChats(u.username)" data-hint="Delete all PMs and public chat messages" class="hint--bottom">
|
||||||
<input class="button confirm" type="submit" value="Clear PMs & chats" />
|
<input class="button confirm" type="submit" value="Clear PMs & chats" />
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@if(isGranted(_.IpBan)) {
|
@if(isGranted(_.IpBan)) {
|
||||||
<form method="post" action="@routes.Mod.ban(u.username, !u.ipBan)" data-hint="Bans all @spy.ips.size IPs under this account from logging into this site." class="hint--bottom-left xhr">
|
<form method="post" action="@routes.Mod.ban(u.username, !u.ipBan)" data-hint="Bans all @spy.ips.size IPs under this account from logging into this site." class="hint--bottom-left">
|
||||||
<input class="button@when(u.ipBan, " active")" type="submit" value="IP ban @spy.ips.size" />
|
<input class="button@when(u.ipBan, " active")" type="submit" value="IP ban @spy.ips.size" />
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
@if(!u.disabled) {
|
@if(!u.disabled) {
|
||||||
@if(isGranted(_.CloseAccount)) {
|
@if(isGranted(_.CloseAccount)) {
|
||||||
<form method="post" action="@routes.Mod.closeAccount(u.username)" data-hint="Disables this account." class="hint--bottom-left xhr">
|
<form method="post" action="@routes.Mod.closeAccount(u.username)" data-hint="Disables this account." class="hint--bottom-left">
|
||||||
<input class="button" type="submit" value="Close" />
|
<input class="button" type="submit" value="Close" />
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@if(isGranted(_.ReopenAccount)) {
|
@if(isGranted(_.ReopenAccount)) {
|
||||||
<form method="post" action="@routes.Mod.reopenAccount(u.username)" data-hint="Re-activates this account." class="hint--bottom-left xhr">
|
<form method="post" action="@routes.Mod.reopenAccount(u.username)" data-hint="Re-activates this account." class="hint--bottom-left">
|
||||||
<input type="submit" class="button active" value="Closed" />
|
<input type="submit" class="button active" value="Closed" />
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
<div class="second_mod_button_row">
|
<div class="second_mod_button_row">
|
||||||
@if(isGranted(_.RemoveRanking)) {
|
@if(isGranted(_.RemoveRanking)) {
|
||||||
<form method="post" action="@routes.Mod.rankban(u.username, !u.rankban)" data-hint="@if(u.rankban){In}else{Ex}cludes this user @if(u.rankban){from}else{in} the rankings." class="hint--bottom-left xhr">
|
<form method="post" action="@routes.Mod.rankban(u.username, !u.rankban)" data-hint="@if(u.rankban){In}else{Ex}cludes this user @if(u.rankban){from}else{in} the rankings." class="hint--bottom-left">
|
||||||
<input class="button@when(u.rankban, " active")" type="submit" value="Ban from ranking" />
|
<input class="button@when(u.rankban, " active")" type="submit" value="Ban from ranking" />
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
@if(isGranted(_.ReportBan)) {
|
@if(isGranted(_.ReportBan)) {
|
||||||
<form method="post" action="@routes.Mod.reportban(u.username, !u.reportban)" data-hint="@if(u.reportban){En}else{Dis}able the report feature for this user." class="hint--bottom-left xhr">
|
<form method="post" action="@routes.Mod.reportban(u.username, !u.reportban)" data-hint="@if(u.reportban){En}else{Dis}able the report feature for this user." class="hint--bottom-left">
|
||||||
<input class="button@when(u.reportban, " active")" type="submit" value="Reportban" />
|
<input class="button@when(u.reportban, " active")" type="submit" value="Reportban" />
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
|
@ -77,12 +77,12 @@
|
||||||
@if(isGranted(_.SetTitle)) {
|
@if(isGranted(_.SetTitle)) {
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
<form class="fide_title xhr" method="post" action="@routes.Mod.setTitle(u.username)">
|
<form class="fide_title" method="post" action="@routes.Mod.setTitle(u.username)">
|
||||||
@base.form.select(lila.user.DataForm.title.fill(u.title)("title"), lila.user.User.titles, "No title".some)
|
@base.form.select(lila.user.DataForm.title.fill(u.title)("title"), lila.user.User.titles, "No title".some)
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
@if(isGranted(_.SetEmail)) {
|
@if(isGranted(_.SetEmail)) {
|
||||||
<form class="email xhr" method="post" action="@routes.Mod.setEmail(u.username)">
|
<form class="email" method="post" action="@routes.Mod.setEmail(u.username)">
|
||||||
<input type="email" value="@emails.current" name="email" placeholder="Email address" />
|
<input type="email" value="@emails.current" name="email" placeholder="Email address" />
|
||||||
<button type="submit" class="thin button" data-icon="E"></button>
|
<button type="submit" class="thin button" data-icon="E"></button>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -1,30 +1,13 @@
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
$('div.user_show .mod_zone_toggle').each(function() {
|
$('div.user_show .mod_zone_toggle').each(function() {
|
||||||
|
|
||||||
function start($mod) {
|
|
||||||
$mod.find('form.xhr').submit(function() {
|
|
||||||
$mod.html(lichess.spinnerHtml).show();
|
|
||||||
$.ajax({
|
|
||||||
url: $(this).attr('action'),
|
|
||||||
method: $(this).attr('method'),
|
|
||||||
success: function(html) {
|
|
||||||
start($mod.html(html));
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
$(this).click(function() {
|
$(this).click(function() {
|
||||||
var $zone = $('div.user_show .mod_zone');
|
var $zone = $('div.user_show .mod_zone');
|
||||||
if ($zone.is(':visible')) $zone.hide();
|
if ($zone.is(':visible')) $zone.hide();
|
||||||
else {
|
else {
|
||||||
$zone.html(lichess.spinnerHtml).show();
|
$zone.html(lichess.spinnerHtml).show();
|
||||||
lichess.loadCss('/assets/stylesheets/user-mod.css');
|
lichess.loadCss('/assets/stylesheets/user-mod.css');
|
||||||
$zone.load($(this).attr('href'), function() {
|
$zone.load($(this).attr('href'));
|
||||||
start($zone);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue