Bonfire.Social.PostContents (Bonfire v1.0.1-social-alpha.28)
View SourceQuery, manipulate, and federate post contents. See also Bonfire.Social.Posts for directly handling posts.
Context for Bonfire.Data.Social.PostContent which has the following fields:
- name (eg. title)
- summary (eg. description)
- html_body (NOTE: can also contain markdown or plaintext)
Summary
Functions
Prepare an outgoing ActivityPub Note object for publishing.
Returns the base query for post contents.
Given a changeset, post content attributes, creator, boundary and options, returns a changeset prepared with relevant attributes and associations.
Creates a changeset for a PostContent struct.
Given a post content ID, returns the corresponding post content.
Given post content attributes, creator, boundary, and options, prepares the post contents for processing by detecting languages, mentions, hashtags, and urls.
Normalizes AP links in the content based on format.
Given a set of filters, returns a single post content matching those filters.
Given a set of filters, returns an Ecto.Query for matching post contents.
Performs a search query on post contents based on the given text.
Translates the translatable fields of a post content to the target language.
Functions
Prepare an outgoing ActivityPub Note object for publishing.
Returns the base query for post contents.
Examples
iex> Bonfire.Social.PostContents.base_query()
#Ecto.Query<from p0 in Bonfire.Data.Social.PostContent>
Given a changeset, post content attributes, creator, boundary and options, returns a changeset prepared with relevant attributes and associations.
Examples
iex> attrs = %{name: "Test Post", html_body: "Content"}
iex> creator = %Bonfire.Data.Identity.User{id: "01FXYZ123ABC"}
iex> boundary = "public"
iex> opts = []
iex> changeset = %Ecto.Changeset{}
iex> Bonfire.Social.PostContents.cast(changeset, attrs, creator, boundary, opts)
#Ecto.Changeset<...>
Creates a changeset for a PostContent struct.
Examples
iex> attrs = %{name: "Test Post", html_body: "Content"}
iex> Bonfire.Social.PostContents.changeset(%Bonfire.Data.Social.PostContent{}, attrs)
#Ecto.Changeset<...>
Given a post content ID, returns the corresponding post content.
Examples
iex> Bonfire.Social.PostContents.get("01FXYZ123ABC")
%Bonfire.Data.Social.PostContent{id: "01FXYZ123ABC", ...}
Given post content attributes, creator, boundary, and options, prepares the post contents for processing by detecting languages, mentions, hashtags, and urls.
Normalizes AP links in the content based on format.
Examples
> nomalise_local_links("<a href="/pub/actors/foo">Actor</a>", :markdown)
"<a href="/character/foo">Actor</a>"
Given a set of filters, returns a single post content matching those filters.
Examples
iex> Bonfire.Social.PostContents.one(%{name: "Test Post"})
%Bonfire.Data.Social.PostContent{name: "Test Post", ...}
Given a set of filters, returns an Ecto.Query for matching post contents.
Examples
iex> Bonfire.Social.PostContents.query(%{name: "Test Post"})
#Ecto.Query<from p0 in Bonfire.Data.Social.PostContent, where: p0.name == ^"Test Post">
Performs a search query on post contents based on the given text.
Examples
iex> Bonfire.Social.PostContents.search_query("test", %{})
#Ecto.Query<from p0 in Bonfire.Data.Social.PostContent, ...>
Translates the translatable fields of a post content to the target language.
Extracts non-empty :name, :summary, and :html_body fields and translates them
using batch translation for efficiency. Uses format: :html for html_body.
Options
:source_lang- Optional source language code (auto-detected if not provided)- Other options are passed through to the translation adapter
Examples
iex> translate(%{post_content: %{name: "Hello", html_body: "<p>World</p>"}}, "es")
{:ok, %{name: "Hola", html_body: "<p>Mundo</p>"}}