forked from lichess-org/lila
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPush.scala
24 lines (19 loc) · 786 Bytes
/
Push.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
package controllers
import lila.app.{ given, * }
import lila.push.WebSubscription
final class Push(env: Env) extends LilaController(env):
def mobileRegister(platform: String, deviceId: String) = AuthOrScoped(_.Web.Mobile) { ctx ?=> me ?=>
env.push.registerDevice(me, platform, deviceId) inject NoContent
}
def mobileUnregister = AuthOrScoped(_.Web.Mobile) { ctx ?=> me ?=>
env.push.unregisterDevices(me) inject NoContent
}
def webSubscribe = AuthBody(parse.json) { ctx ?=> me ?=>
val currentSessionId = ~env.security.api.reqSessionId(ctx.req)
ctx.body.body
.validate[WebSubscription]
.fold(
err => BadRequest(err.toString),
data => env.push.webSubscriptionApi.subscribe(me, data, currentSessionId) inject NoContent
)
}