Returm generation of URL by usage of MobilizonWeb.Endpoint

This commit is contained in:
miffigriffi 2019-09-17 22:10:22 +02:00
parent da97c29340
commit 8f580ce10c
2 changed files with 7 additions and 4 deletions

View file

@ -8,9 +8,11 @@ defmodule Mobilizon.Events.Comment do
import Ecto.Changeset
alias Mobilizon.Actors.Actor
alias Mobilizon.Config
alias Mobilizon.Events.{Comment, CommentVisibility, Event}
alias MobilizonWeb.Router.Helpers, as: Routes
alias MobilizonWeb.Endpoint
@type t :: %__MODULE__{
text: String.t(),
url: String.t(),
@ -66,5 +68,5 @@ defmodule Mobilizon.Events.Comment do
end
@spec generate_url(String.t()) :: String.t()
defp generate_url(uuid), do: "#{Config.instance_hostname()}/comments/#{uuid}"
defp generate_url(uuid), do: Routes.page_url(Endpoint, :comment, uuid)
end

View file

@ -8,10 +8,11 @@ defmodule Mobilizon.Events.Participant do
import Ecto.Changeset
alias Mobilizon.Actors.Actor
alias Mobilizon.Config
alias Mobilizon.Events
alias Mobilizon.Events.{Event, ParticipantRole}
alias MobilizonWeb.Endpoint
@type t :: %__MODULE__{
role: ParticipantRole.t(),
url: String.t(),
@ -82,5 +83,5 @@ defmodule Mobilizon.Events.Participant do
end
@spec generate_url(String.t()) :: String.t()
defp generate_url(uuid), do: "#{Config.instance_hostname()}/join/event/#{uuid}"
defp generate_url(uuid), do: "#{Endpoint.url()}/join/event/#{uuid}"
end