mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 08:36:29 +00:00
Fix some edge cases [nervous laughter]
This commit is contained in:
parent
4656f433f9
commit
ce15e0659e
3 changed files with 23 additions and 4 deletions
|
@ -454,7 +454,20 @@ defmodule Pleroma.User do
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_cached_by_nickname_or_id(nickname_or_id) do
|
def get_cached_by_nickname_or_id(nickname_or_id) do
|
||||||
get_cached_by_id(nickname_or_id) || get_cached_by_nickname(nickname_or_id)
|
try do
|
||||||
|
# TODO: convert to UUIDs when !654 is merged
|
||||||
|
maybe_id = String.to_integer(nickname_or_id)
|
||||||
|
user = get_cached_by_id(maybe_id)
|
||||||
|
|
||||||
|
if user == nil do
|
||||||
|
raise ArgumentError, message: "invalid argument foo"
|
||||||
|
else
|
||||||
|
user
|
||||||
|
end
|
||||||
|
rescue
|
||||||
|
_ in ArgumentError ->
|
||||||
|
get_cached_by_nickname(nickname_or_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_by_nickname(nickname) do
|
def get_by_nickname(nickname) do
|
||||||
|
|
|
@ -21,7 +21,13 @@ defmodule Pleroma.Web.Metadata do
|
||||||
{:meta,
|
{:meta,
|
||||||
[
|
[
|
||||||
property: "og:title",
|
property: "og:title",
|
||||||
content: "#{user.name} (@#{user.nickname}@#{pleroma_domain()}) post ##{activity.id}"
|
content:
|
||||||
|
"#{user.name}" <>
|
||||||
|
if user.local do
|
||||||
|
"(@#{user.nickname}@{pleroma_domain})"
|
||||||
|
else
|
||||||
|
"(@#{user.nickname})"
|
||||||
|
end
|
||||||
], []},
|
], []},
|
||||||
{:meta, [property: "og:url", content: activity.data["id"]], []},
|
{:meta, [property: "og:url", content: activity.data["id"]], []},
|
||||||
{:meta, [property: "og:description", content: truncated_content], []},
|
{:meta, [property: "og:description", content: truncated_content], []},
|
||||||
|
@ -35,7 +41,7 @@ defmodule Pleroma.Web.Metadata do
|
||||||
|
|
||||||
# opengraph for user card
|
# opengraph for user card
|
||||||
defp opengraph_tags(%{user: user}) do
|
defp opengraph_tags(%{user: user}) do
|
||||||
with truncated_bio = scrub_html_and_truncate(user.bio) do
|
with truncated_bio = scrub_html_and_truncate(user.bio || "") do
|
||||||
[
|
[
|
||||||
{:meta,
|
{:meta,
|
||||||
[
|
[
|
||||||
|
|
|
@ -505,7 +505,7 @@ defmodule Pleroma.Web.Router do
|
||||||
|
|
||||||
scope "/", Fallback do
|
scope "/", Fallback do
|
||||||
get("/registration/:token", RedirectController, :registration_page)
|
get("/registration/:token", RedirectController, :registration_page)
|
||||||
get("/*path", RedirectController, :redirector)
|
get("/*path", RedirectController, :redirector_with_meta)
|
||||||
|
|
||||||
options("/*path", RedirectController, :empty)
|
options("/*path", RedirectController, :empty)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue