forked from lichess-org/lila
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTimeline.scala
38 lines (32 loc) · 984 Bytes
/
Timeline.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package controllers
import play.api.libs.json._
import play.api.mvc._
import lila.api.Context
import lila.app._
import lila.common.HTTPRequest
import views._
object Timeline extends LilaController {
def home = Auth { implicit ctx =>
import lila.timeline.Entry.entryWrites
val nb = getInt("nb").fold(100)(_ min 100)
me =>
negotiate(
html = {
if (HTTPRequest.isXhr(ctx.req))
Env.timeline.entryRepo.userEntries(me.id) map { html.timeline.entries(_) }
else {
val entries = Env.timeline.entryRepo.moreUserEntries(me.id, nb)
entries map { html.timeline.more(_) }
}
},
_ => {
val entries = Env.timeline.entryRepo.moreUserEntries(me.id, nb)
entries map { es => Ok(Json.obj("entries" -> es)) }
}
)
}
def unsub(channel: String) = Auth { implicit ctx =>
me =>
Env.timeline.unsubApi.set(channel, me.id, ~get("unsub") == "on")
}
}