Actor without preferredUsername gives error
When you have an actor without preferredUsername
, Pleroma will store it in the DB, but have a NULL
value for nickname
. When viewing it through Mastodon API (e.g. by searching it), we add a field fqn
which calls Pleroma.user.full_nickname(%User{} = user)
. This assumes user.nickname
to be a string and it throws an error[1].
I encountered this while playing around, so I'm not sure if there's currently examples in the wild, but should prob be fixed regardless.
[1]
[error] Elixir.Pleroma.Web.MastodonAPI.StatusView failed to render {Pleroma.Web.MastodonAPI.StatusView, "show.json"}
** (FunctionClauseError) no function clause matching in String.contains?/2
(elixir 1.13.4) lib/string.ex:2372: String.contains?(nil, "@")
(pleroma 2.4.52-589-gb53cf7d4-fine-grained-moderation-privileges+dev) lib/pleroma/user.ex:2225: Pleroma.User.full_nickname/1
(pleroma 2.4.52-589-gb53cf7d4-fine-grained-moderation-privileges+dev) lib/pleroma/web/mastodon_api/views/account_view.ex:284: Pleroma.Web.MastodonAPI.AccountView.do_render/2
(pleroma 2.4.52-589-gb53cf7d4-fine-grained-moderation-privileges+dev) lib/pleroma/web/mastodon_api/views/status_view.ex:338: Pleroma.Web.MastodonAPI.StatusView.render/2
(pleroma 2.4.52-589-gb53cf7d4-fine-grained-moderation-privileges+dev) lib/pleroma/web/mastodon_api/views/status_view.ex:6: Pleroma.Web.MastodonAPI.StatusView.safe_render/3
(elixir 1.13.4) lib/enum.ex:1593: Enum."-map/2-lists^map/1-0-"/2
(pleroma 2.4.52-589-gb53cf7d4-fine-grained-moderation-privileges+dev) lib/pleroma/web/mastodon_api/views/status_view.ex:6: Pleroma.Web.MastodonAPI.StatusView.safe_render_many/4
(pleroma 2.4.52-589-gb53cf7d4-fine-grained-moderation-privileges+dev) lib/pleroma/web/mastodon_api/controllers/search_controller.ex:182: Pleroma.Web.MastodonAPI.SearchController.with_fallback/2
(pleroma 2.4.52-589-gb53cf7d4-fine-grained-moderation-privileges+dev) lib/pleroma/web/mastodon_api/controllers/search_controller.ex:63: anonymous fn/1 in Pleroma.Web.MastodonAPI.SearchController.do_search/3
(elixir 1.13.4) lib/task/supervised.ex:89: Task.Supervised.invoke_mfa/2
(elixir 1.13.4) lib/task/supervised.ex:34: Task.Supervised.reply/4
(stdlib 4.0.1) proc_lib.erl:240: :proc_lib.init_p_do_apply/3