show streamer notes - closes #4257
This commit is contained in:
parent
2dfa23b2db
commit
06555ec6da
|
@ -55,11 +55,16 @@ object Streamer extends LilaController {
|
|||
}
|
||||
}
|
||||
|
||||
private def modData(user: lila.user.User)(implicit ctx: Context) = isGranted(_.ModLog) ?? {
|
||||
Env.mod.logApi.userHistory(user.id) zip
|
||||
Env.user.noteApi.forMod(user.id) map some
|
||||
}
|
||||
|
||||
def edit = Auth { implicit ctx => me =>
|
||||
AsStreamer { s =>
|
||||
Env.streamer.liveStreamApi of s flatMap { sws =>
|
||||
isGranted(_.ModLog).??(Env.mod.logApi.userHistory(s.user.id) map some) map { modLog =>
|
||||
NoCache(Ok(html.streamer.edit(sws, StreamerForm userForm sws.streamer, modLog)))
|
||||
modData(s.user) map { forMod =>
|
||||
NoCache(Ok(html.streamer.edit(sws, StreamerForm userForm sws.streamer, forMod)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -70,10 +75,9 @@ object Streamer extends LilaController {
|
|||
Env.streamer.liveStreamApi of s flatMap { sws =>
|
||||
implicit val req = ctx.body
|
||||
StreamerForm.userForm(sws.streamer).bindFromRequest.fold(
|
||||
error =>
|
||||
isGranted(_.ModLog).??(Env.mod.logApi.userHistory(s.user.id) map some) map { modLog =>
|
||||
BadRequest(html.streamer.edit(sws, error, modLog))
|
||||
},
|
||||
error => modData(s.user) map { forMod =>
|
||||
BadRequest(html.streamer.edit(sws, error, forMod))
|
||||
},
|
||||
data => api.update(sws.streamer, data, isGranted(_.Streamers)) map { change =>
|
||||
change.list foreach { Env.mod.logApi.streamerList(lila.report.Mod(me), s.user.id, _) }
|
||||
change.feature foreach { Env.mod.logApi.streamerFeature(lila.report.Mod(me), s.user.id, _) }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@(s: lila.streamer.Streamer.WithUserAndStream, form: Form[_], modLog: Option[List[lila.mod.Modlog]])(implicit ctx: Context)
|
||||
@(s: lila.streamer.Streamer.WithUserAndStream, form: Form[_], modData: Option[(List[lila.mod.Modlog], List[lila.user.Note])])(implicit ctx: Context)
|
||||
|
||||
@import play.api.data.Field
|
||||
|
||||
|
@ -71,7 +71,8 @@ menu = menu("edit", s.withoutStream.some).some) {
|
|||
<strong>If your stream is in another language than English</strong>, include the correct language tag (<a class="blue" href="https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes">2-letter ISO 639-1 code</a> enclosed in square brackets) at the start of your stream title. As examples, include "[RU]" for Russian, "[TR]" for Turkish, "[FR]" for French, etc. If your stream is in English, there is no need to include a language tag.
|
||||
</div>
|
||||
}
|
||||
@modLog.map { log =>
|
||||
@modData.map {
|
||||
case (log, notes) => {
|
||||
<div class="mod_log status">
|
||||
<strong class="text" data-icon="!">Moderation history@if(log.isEmpty){: nothing to show.}</strong>
|
||||
@if(log.nonEmpty) {
|
||||
|
@ -81,8 +82,20 @@ menu = menu("edit", s.withoutStream.some).some) {
|
|||
}
|
||||
</ul>
|
||||
}
|
||||
<strong class="text" data-icon="!">Moderator notes@if(notes.isEmpty){: nothing to show.}</strong>
|
||||
@if(notes.nonEmpty) {
|
||||
<ul>
|
||||
@notes.map { note =>
|
||||
<li>
|
||||
<p class="meta">@userIdLink(note.from.some)@momentFromNow(note.date)</p>
|
||||
<p class="text">@richText(note.text)</p>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
<form class="content_box_content material form" action="@routes.Streamer.edit@if(!ctx.is(s.user)){?u=@s.user.id}" method="POST">
|
||||
@errMsgMaterial(form.errors)
|
||||
@if(isGranted(_.Streamers)) {
|
||||
|
|
|
@ -50,7 +50,7 @@ final class NoteApi(
|
|||
.list[Note](20)
|
||||
|
||||
def forMod(ids: List[User.ID]): Fu[List[Note]] =
|
||||
coll.find($doc("to" -> $doc("$in" -> ids)))
|
||||
coll.find($doc("to" $in ids))
|
||||
.sort($doc("date" -> -1))
|
||||
.list[Note](50)
|
||||
|
||||
|
|
Loading…
Reference in a new issue