expose created hook/seek id in mobile API
This commit is contained in:
parent
103d77c677
commit
e5858b5f2c
|
@ -93,7 +93,12 @@ object Setup extends LilaController with TheftPrevention with play.api.http.Cont
|
|||
api = _ => BadRequest(err.errorsAsJson).fuccess),
|
||||
config => (ctx.userId ?? Env.relation.api.blocking) flatMap { blocking =>
|
||||
JsonOk {
|
||||
env.processor.hook(config, uid, lila.common.HTTPRequest sid req, blocking) inject Json.obj("ok" -> true)
|
||||
env.processor.hook(config, uid, lila.common.HTTPRequest sid req, blocking) map { hookId =>
|
||||
Json.obj(
|
||||
"ok" -> true,
|
||||
"hook" -> Json.obj(
|
||||
"id" -> hookId))
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
|
@ -53,12 +53,18 @@ private[setup] final class Processor(
|
|||
config: HookConfig,
|
||||
uid: String,
|
||||
sid: Option[String],
|
||||
blocking: Set[String])(implicit ctx: UserContext): Funit =
|
||||
saveConfig(_ withHook config) >>- {
|
||||
blocking: Set[String])(implicit ctx: UserContext): Fu[String] =
|
||||
saveConfig(_ withHook config) >> {
|
||||
config.hook(uid, ctx.me, sid, blocking) match {
|
||||
case Left(hook) => lobby ! AddHook(hook)
|
||||
case Right(Some(seek)) => lobby ! AddSeek(seek)
|
||||
case _ =>
|
||||
case Left(hook) => fuccess {
|
||||
lobby ! AddHook(hook)
|
||||
hook.id
|
||||
}
|
||||
case Right(Some(seek)) => fuccess {
|
||||
lobby ! AddSeek(seek)
|
||||
seek.id
|
||||
}
|
||||
case _ => fufail("Can't create seek")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue