1 defmodule Pleroma.Web.OEmbed do
2 alias Pleroma.{Repo, Object, Activity, User}
3 alias Pleroma.Formatter
5 def recognize_path(url) do
6 details = Regex.named_captures(~r/.+\/(?<route>.+)\/(?<id>\w+).*$/, url)
9 %{ "route" => "notice", "id" => id } ->
10 %{type: :activity, entity: Repo.get(Activity, id) }
11 %{ "route" => "users", "id" => nickname } ->
12 %{type: :user, entity: User.get_by_nickname(nickname) }
14 { :error, "no matching route"}
18 def truncated_content(activity) do
19 content = activity.data['object']['content']
21 Formatter.truncate(content)