mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-30 14:57:59 +01:00
ae5bfe14e4
* Adding routes for /forums Adding routes for new /forums endpoints * New API Routes `/forum` `/forum/:forum_id` * Add New API Routes `/forums/:forum_id/topics/:topic_id/` `/forums/:forum_id/topics/:topic_id/:post_id` * Adds New API Routes `/forums/:forum_id/topics` `/forums/:forum_id/topics/:topic_id` * Forum JSON formatter * Updated Correctly filters out things that should not be shown. * Added topic JSON filter * Added correct pagination * Spacing and neatened * Cleaned up Consolidated queries and neatened up spacing. Fixed name * Removed unneeded aliases * Cleaned up Consolidated queries Fixed spacing Removed unneeded aliases * Cleaned up Spacing * Cleaned up spacing * Depluralized * Cleaned up Removed space * Removed extra spaces * Removed extra spaces * Removed extra spaces * Removed preloads * Cleaned up Grouped clauses * Consolodated further * Cleaned up preloads * Cleaned up Preloads consolidated clauses grouped clauses * Cleaned up removed `id` `locked` * Removed topic_id Not useful since the API client should already know it. * More consolodation of terms * Add total post count * Removed unneeded variable * Last cleanup, I swear.
30 lines
807 B
Elixir
30 lines
807 B
Elixir
defmodule PhilomenaWeb.TopicJson do
|
|
alias PhilomenaWeb.UserAttributionView
|
|
|
|
def as_json(%{hidden_from_users: true}) do
|
|
%{
|
|
slug: nil,
|
|
title: nil,
|
|
post_count: nil,
|
|
view_count: nil,
|
|
sticky: nil,
|
|
last_replied_to_at: nil,
|
|
locked: nil,
|
|
user_id: nil,
|
|
author: nil
|
|
}
|
|
end
|
|
def as_json(topic) do
|
|
%{
|
|
slug: topic.slug,
|
|
title: topic.title,
|
|
post_count: topic.post_count,
|
|
view_count: topic.view_count,
|
|
sticky: topic.sticky,
|
|
last_replied_to_at: topic.last_replied_to_at,
|
|
locked: not is_nil(topic.locked_at),
|
|
user_id: if(not topic.anonymous, do: topic.user.id),
|
|
author: if(topic.anonymous or is_nil(topic.user), do: UserAttributionView.anonymous_name(topic), else: topic.user.name)
|
|
}
|
|
end
|
|
end
|