in app/controllers/UserController.scala [152:181]
def updateUserProfileField = IsAdminAsync(circe.json(2048)) { _=> request=>
request.body.as[UserProfileFieldUpdate] match {
case Left(err)=>
logger.error(err.toString)
Future(BadRequest(GenericErrorResponse("bad_request", err.toString).asJson))
case Right(updateRq)=>
userProfileDAO.userProfileForEmail(updateRq.user).flatMap({
case None=>
Future(BadRequest(GenericErrorResponse("not_found", s"user ${updateRq.user} not found").asJson))
case Some(Left(err))=>
logger.error(err.toString)
Future(InternalServerError(GenericErrorResponse("db_error", err.toString).asJson))
case Some(Right(originalProfile))=>
performUpdate(originalProfile, updateRq) match {
case Right(updatedProfile) =>
logger.info(s"updatedProfile is $updatedProfile")
userProfileDAO
.put(updatedProfile)
.map(_ => Ok(ObjectGetResponse("updated", "profile", updatedProfile).asJson))
.recover({
case err: Throwable =>
logger.error(s"Could not update user profile for ${updateRq.user}: ${err.getMessage}", err)
InternalServerError(GenericErrorResponse("db_error", err.getMessage).asJson)
})
case Left(err) =>
Future(BadRequest(GenericErrorResponse("bad_request", err).asJson))
}
})
}
}