Skip to content
Snippets Groups Projects

Fix feed endpoint issues

6 files
+ 54
14
Compare changes
  • Side-by-side
  • Inline
Files
6
@@ -60,14 +60,14 @@ class DailyController @Inject()(val controllerComponents: ControllerComponents,
*
* @param userId The ID of the user to get the feed for.
*/
def getUserFeed(userId: String) = authenticatedUserAction { implicit request: AuthenticationRequest[AnyContent] =>
def getUserFeed(userId: String, questionId: String) = authenticatedUserAction { implicit request: AuthenticationRequest[AnyContent] =>
println("DailyController:getUserFeed")
try {
if (!ObjectId.isValid(userId)) throw new InvalidRequestBodyException("Invalid query parameter ID format: userId")
val result: Seq[Daily] = Daily.getUserFeedAsync(new ObjectId(userId), request.jwt)
val jsonResult: JsValue = Daily.toJson(result)
val (feed, hasPosted): (Seq[Daily], Boolean) = Daily.getUserFeedAsync(new ObjectId(userId), new ObjectId(questionId), request.jwt)
val jsonResult: JsValue = Daily.feedToJson(feed, hasPosted)
Ok(jsonResult)
} catch {
case _: TimeoutException => BadRequest("Request timed out")
Loading