forked from lichess-org/lila
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
notify tournament players anywhere on the site WIP
- Loading branch information
Showing
21 changed files
with
151 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package lila | ||
package tournament | ||
|
||
import akka.actor._ | ||
import play.api.libs.concurrent._ | ||
import play.api.Play.current | ||
|
||
private[tournament] final class Register extends Actor { | ||
|
||
var userTournaments = Map[String, Tournament]() | ||
|
||
def receive = { | ||
|
||
case SetTournaments(tours) ⇒ { | ||
userTournaments = tours.foldLeft(Map[String, Tournament]()) { | ||
case (ts, tour) ⇒ ts ++ tour.userIds.map(x ⇒ x -> tour) | ||
} | ||
print(userTournaments) | ||
} | ||
|
||
case GetUserTournament(userId) ⇒ sender ! (userTournaments get userId) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package lila | ||
package tournament | ||
|
||
import akka.actor._ | ||
import akka.actor.ReceiveTimeout | ||
import akka.util.duration._ | ||
import akka.util.Timeout | ||
import akka.pattern.{ ask, pipe } | ||
import akka.dispatch.{ Future, Promise } | ||
import play.api.libs.concurrent._ | ||
import play.api.Play.current | ||
import play.api.libs.json._ | ||
|
||
import socket.SendTos | ||
|
||
private[tournament] final class Reminder(hubNames: List[String]) extends Actor { | ||
|
||
lazy val hubRefs = hubNames map { name ⇒ Akka.system.actorFor("/user/" + name) } | ||
|
||
implicit val timeout = Timeout(1 second) | ||
|
||
def receive = { | ||
case tour: Started ⇒ { | ||
val msg = SendTos(tour.userIds.toSet, JsObject(Seq( | ||
"t" -> JsString("tournamentReminder"), | ||
"d" -> JsString(views.html.tournament.reminder(tour).toString) | ||
))) | ||
hubRefs foreach { _ ! msg } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
@(notif: lila.notification.Notification) | ||
@(id: String, from: Option[String] = None)(html: Html) | ||
|
||
<div id="@notif.id" class="notification"> | ||
<a class="close" href="@routes.Notification.remove(notif.id)">X</a> | ||
@notif.from.map { user => | ||
@userLink(user, none) | ||
<div id="@id" class="notification"> | ||
<a class="close" href="@routes.Notification.remove(id)">X</a> | ||
@from.map { user => | ||
@userIdLink(user, none) | ||
} | ||
<div class="inner"> | ||
@Html(notif.html) | ||
</div> | ||
<div class="inner">@html</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@(tour: lila.tournament.Tournament) | ||
|
||
@notification.view("tournament_reminder") { | ||
@linkTo(tour) in progress! | ||
<form action="@routes.Tournament.join(tour.id)" method="POST"> | ||
<input type="submit" class="submit button" value="Join" /> | ||
</form> | ||
<form action="@routes.Tournament.withdraw(tour.id)" method="POST"> | ||
<input type="submit" class="submit button strong" value="Withdraw" /> | ||
</form> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.