Introduce Sitemaps

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2020-08-12 16:05:34 +02:00
parent 9a0068dfea
commit c56fb710b6
21 changed files with 163 additions and 39 deletions

View File

@@ -21,6 +21,13 @@ defmodule Mobilizon.Posts do
:private
])
@spec list_posts_for_stream :: Enum.t()
def list_posts_for_stream do
Post
|> filter_public()
|> Repo.stream()
end
@doc """
Returns the list of recent posts for a group
"""
@@ -35,7 +42,7 @@ defmodule Mobilizon.Posts do
def get_public_posts_for_group(%Actor{id: group_id}, page \\ nil, limit \\ nil) do
group_id
|> do_get_posts_for_group()
|> where([p], p.visibility == ^:public and not p.draft)
|> filter_public()
|> Page.build_page(page, limit)
end
@@ -132,4 +139,9 @@ defmodule Mobilizon.Posts do
where: p.post_id == ^post_id
)
end
@spec filter_public(Ecto.Query.t()) :: Ecto.Query.t()
defp filter_public(query) do
where(query, [p], p.visibility == ^:public and not p.draft)
end
end