<commit_before>package lila.message

import play.api.libs.json._
import play.api.mvc.Result
import play.api.mvc.Results._

import lila.common.PimpedJson._
import lila.user.User
import lila.common.paginator._

final class JsonView() {

  def inbox(me: User, threads: Paginator[Thread]): Result =
    Ok(Json.obj(
      "threads" -> PaginatorJson(threads.mapResults { t =>
        Json.obj(
          "id" -> t.id,
          "author" -> t.otherUserId(me),
          "name" -> t.name,
          "updatedAt" -> t.updatedAt,
          "isUnread" -> t.isUnReadBy(me)
        )
      })
    ))

  def thread(thread: Thread): Fu[JsValue] =
    fuccess (
      Json.obj(
        "id" -> thread.id,
        "name" -> thread.name,
        "posts" -> thread.posts.map { post => threadPost(thread, post)}
      )
    )

  def threadPost(thread: Thread, post: Post): JsValue =
    Json.obj(
      "sender" -> thread.senderOf(post),
      "receiver" -> thread.receiverOf(post),
      "text" -> post.text,<commit_msg>Having an object with a threads property that pointed to the Paginator was silly. Removed.<commit_after>package lila.message

import play.api.libs.json._
import play.api.mvc.Result
import play.api.mvc.Results._

import lila.common.PimpedJson._
import lila.user.User
import lila.common.paginator._

final class JsonView() {

  def inbox(me: User, threads: Paginator[Thread]): Result =
    Ok(PaginatorJson(threads.mapResults { t =>
        Json.obj(
          "id" -> t.id,
          "author" -> t.otherUserId(me),
          "name" -> t.name,
          "updatedAt" -> t.updatedAt,
          "isUnread" -> t.isUnReadBy(me)
        )
      })
    )

  def thread(thread: Thread): Fu[JsValue] =
    fuccess (
      Json.obj(
        "id" -> thread.id,
        "name" -> thread.name,
        "posts" -> thread.posts.map { post => threadPost(thread, post)}
      )
    )

  def threadPost(thread: Thread, post: Post): JsValue =
    Json.obj(
      "sender" -> thread.senderOf(post),
      "receiver" -> thread.receiverOf(post),
      "text" -> post.text,
{'fraction_non_alphanumeric': 0.1488530990727184, 'fraction_numerical': 0.0, 'mean_word_length': 2.3387622149837135, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1545741', 'n_tokens_mistral': 703, 'n_tokens_neox': 688, 'n_words': 143}