forked from potsda.mn/mobilizon
Fix posts not able to accept existing tags
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
3ecc2cbad7
commit
df22082f3e
|
@ -22,8 +22,8 @@ defmodule Mobilizon.Posts.Post do
|
||||||
import Ecto.Changeset
|
import Ecto.Changeset
|
||||||
alias Ecto.Changeset
|
alias Ecto.Changeset
|
||||||
alias Mobilizon.Actors.Actor
|
alias Mobilizon.Actors.Actor
|
||||||
|
alias Mobilizon.{Events, Medias}
|
||||||
alias Mobilizon.Events.Tag
|
alias Mobilizon.Events.Tag
|
||||||
alias Mobilizon.Medias
|
|
||||||
alias Mobilizon.Medias.Media
|
alias Mobilizon.Medias.Media
|
||||||
alias Mobilizon.Posts.Post.TitleSlug
|
alias Mobilizon.Posts.Post.TitleSlug
|
||||||
alias Mobilizon.Posts.PostVisibility
|
alias Mobilizon.Posts.PostVisibility
|
||||||
|
@ -141,6 +141,12 @@ defmodule Mobilizon.Posts.Post do
|
||||||
|
|
||||||
defp put_tags(changeset, _), do: changeset
|
defp put_tags(changeset, _), do: changeset
|
||||||
|
|
||||||
|
@spec process_tag(map() | Tag.t()) :: Tag.t() | Ecto.Changeset.t()
|
||||||
|
# We need a changeset instead of a raw struct because of slug which is generated in changeset
|
||||||
|
defp process_tag(%{id: id} = _tag) do
|
||||||
|
Events.get_tag(id)
|
||||||
|
end
|
||||||
|
|
||||||
defp process_tag(tag), do: Tag.changeset(%Tag{}, tag)
|
defp process_tag(tag), do: Tag.changeset(%Tag{}, tag)
|
||||||
|
|
||||||
defp maybe_put_publish_date(%Changeset{} = changeset) do
|
defp maybe_put_publish_date(%Changeset{} = changeset) do
|
||||||
|
|
Loading…
Reference in a new issue