implement site-wide WS announcements on CLI command
parent
d281f5bd3c
commit
b9b0336242
|
@ -60,6 +60,7 @@ object dev {
|
|||
),
|
||||
h2("Command examples:"),
|
||||
pre("""uptime
|
||||
announce Lichess will undergo maintenance in 15 minutes!
|
||||
change asset version
|
||||
puzzle disable 70000
|
||||
team disable foobar
|
||||
|
|
|
@ -15,7 +15,7 @@ private[api] final class Cli(bus: lila.common.Bus) extends lila.common.Cli {
|
|||
}
|
||||
|
||||
def process = {
|
||||
case "uptime" :: Nil => fuccess(lila.common.PlayApp.uptimeSeconds.toString)
|
||||
case "uptime" :: Nil => fuccess(s"${lila.common.PlayApp.uptimeSeconds} seconds")
|
||||
case "deploy" :: "pre" :: Nil => remindDeploy(lila.hub.actorApi.DeployPre)
|
||||
case "deploy" :: "post" :: Nil => remindDeploy(lila.hub.actorApi.DeployPost)
|
||||
case "change" :: ("asset" | "assets") :: "version" :: Nil =>
|
||||
|
@ -30,6 +30,10 @@ private[api] final class Cli(bus: lila.common.Bus) extends lila.common.Cli {
|
|||
bus.publish(lila.user.User.GDPRErase(user), 'gdprErase)
|
||||
s"Erasing all data about ${user.username} now"
|
||||
}
|
||||
case "announce" :: msgWords =>
|
||||
val msg = msgWords mkString " "
|
||||
bus.publish(lila.hub.actorApi.Announce(msg), 'announce)
|
||||
fuccess(s"Announcing: $msg")
|
||||
}
|
||||
|
||||
private def remindDeploy(event: Deploy): Fu[String] = {
|
||||
|
|
|
@ -12,6 +12,9 @@ case object DeployPost extends Deploy("deployPost")
|
|||
|
||||
case object Shutdown // on actor system termination
|
||||
|
||||
// announce something to all clients
|
||||
case class Announce(msg: String)
|
||||
|
||||
package streamer {
|
||||
case class StreamsOnAir(html: String)
|
||||
case class StreamStart(userId: String)
|
||||
|
|
|
@ -8,7 +8,7 @@ import scala.concurrent.duration._
|
|||
import actorApi.{ GetSocketStatus, SocketStatus }
|
||||
|
||||
import lila.game.{ Game, GameRepo, Pov }
|
||||
import lila.hub.actorApi.DeployPost
|
||||
import lila.hub.actorApi.{ DeployPost, Announce }
|
||||
import lila.hub.actorApi.map.Tell
|
||||
import lila.hub.actorApi.round.{ Abort, Resign, FishnetPlay }
|
||||
import lila.hub.actorApi.socket.HasUserId
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package lila.socket
|
||||
|
||||
import scala.concurrent.duration._
|
||||
import ornicar.scalalib.Random.approximatly
|
||||
import scala.concurrent.duration._
|
||||
|
||||
import lila.hub.{ Trouper, TrouperMap }
|
||||
|
||||
|
@ -26,7 +26,14 @@ object SocketMap {
|
|||
system.scheduler.schedule(approximatly(0.1f)(12.seconds.toMillis).millis, broomFrequency) {
|
||||
trouperMap tellAll actorApi.Broom
|
||||
}
|
||||
system.lilaBus.subscribeFun('shutdown) { case _ => trouperMap.killAll }
|
||||
system.lilaBus.subscribeFuns(
|
||||
'shutdown -> {
|
||||
case _ => trouperMap.killAll
|
||||
},
|
||||
'announce -> {
|
||||
case m: lila.hub.actorApi.Announce => trouperMap tellAll m
|
||||
}
|
||||
)
|
||||
|
||||
trouperMap
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import scala.concurrent.Promise
|
|||
import actorApi._
|
||||
import chess.Centis
|
||||
import lila.common.LightUser
|
||||
import lila.hub.actorApi.Deploy
|
||||
import lila.hub.actorApi.{ Deploy, Announce }
|
||||
import lila.hub.actorApi.socket.HasUserId
|
||||
import lila.hub.Trouper
|
||||
import lila.memo.ExpireSetMemo
|
||||
|
@ -56,6 +56,8 @@ abstract class SocketTrouper[M <: SocketMember](
|
|||
case Resync(uid) => resync(uid)
|
||||
|
||||
case d: Deploy => onDeploy(d)
|
||||
|
||||
case Announce(msg) => notifyAll(makeMessage("announce", Json.obj("msg" -> msg)).pp)
|
||||
}
|
||||
|
||||
protected def hasUserId(userId: String) = members.values.exists(_.userId contains userId)
|
||||
|
@ -181,5 +183,5 @@ trait LoneSocket { self: SocketTrouper[_] =>
|
|||
this ! lila.socket.actorApi.Broom
|
||||
lila.mon.socket.queueSize(monitoringName)(queueSize)
|
||||
}
|
||||
system.lilaBus.subscribe(this, 'deploy, 'shutdown)
|
||||
system.lilaBus.subscribe(this, 'deploy, 'shutdown, 'announce)
|
||||
}
|
||||
|
|
|
@ -34,4 +34,4 @@
|
|||
@import 'component/btn-rack';
|
||||
@import 'component/loader';
|
||||
@import 'component/reconnecting';
|
||||
@import 'component/tour-reminder';
|
||||
@import 'component/announce';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#tour-reminder {
|
||||
#announce {
|
||||
@extend %flex-between, %popup-shadow;
|
||||
font-size: 1.4em;
|
||||
position: fixed;
|
||||
|
@ -26,4 +26,9 @@
|
|||
margin-left: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
&.announce {
|
||||
flex-flow: row nowrap;
|
||||
background: $c-accent;
|
||||
}
|
||||
}
|
|
@ -92,20 +92,30 @@
|
|||
});
|
||||
},
|
||||
tournamentReminder: function(data) {
|
||||
if ($('#tour-reminder').length || $('body').data("tournament-id") == data.id) return;
|
||||
if ($('#announce').length || $('body').data("tournament-id") == data.id) return;
|
||||
var url = '/tournament/' + data.id;
|
||||
$('body').append(
|
||||
'<div id="tour-reminder">' +
|
||||
'<a data-icon="g" class="text" href="' + url + '">' + data.name + '</a>' +
|
||||
'<div class="actions">' +
|
||||
'<a class="withdraw text" href="' + url + '/withdraw" data-icon="Z">Pause</a>' +
|
||||
'<a class="text" href="' + url + '" data-icon="G">Join</a>' +
|
||||
'</div></div>'
|
||||
).find("a.withdraw").click(function() {
|
||||
$.post($(this).attr("href"));
|
||||
$('#tour-reminder').remove();
|
||||
return false;
|
||||
});
|
||||
$(
|
||||
'<div id="announce">' +
|
||||
'<a data-icon="g" class="text" href="' + url + '">' + data.name + '</a>' +
|
||||
'<div class="actions">' +
|
||||
'<a class="withdraw text" href="' + url + '/withdraw" data-icon="Z">Pause</a>' +
|
||||
'<a class="text" href="' + url + '" data-icon="G">Join</a>' +
|
||||
'</div></div>'
|
||||
).find('.withdraw').click(function() {
|
||||
$.post($(this).attr("href"));
|
||||
$('#annouce').remove();
|
||||
return false;
|
||||
})
|
||||
);
|
||||
},
|
||||
announce: function(d) {
|
||||
if (!$('#announce').length) $('body').append(
|
||||
'<div id="announce" class="announce">' +
|
||||
d.msg +
|
||||
'<div class="actions"><a class="close">X</a></div>' +
|
||||
'</div>'
|
||||
).find('#announce .close').click(function() { $('#announce').remove(); });
|
||||
}
|
||||
},
|
||||
params: {},
|
||||
|
|
Loading…
Reference in New Issue