user: add helper for fetching profile url (which may be different than ap id)
authorWilliam Pitcock <nenolod@dereferenced.org>
Thu, 25 Oct 2018 04:01:59 +0000 (04:01 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Thu, 25 Oct 2018 04:01:59 +0000 (04:01 +0000)
lib/pleroma/user.ex

index e972247316c0ad7aed9acf6b6f06857be3133691..0c9fa559a21944c3bf29aa98d6aa7fce2296a8c5 100644 (file)
@@ -42,6 +42,10 @@ defmodule Pleroma.User do
     end
   end
 
+  def profile_url(%User{info: %{"source_data" => %{"url" => url}}}), do: url
+  def profile_url(%User{ap_id: ap_id}), do: ap_id
+  def profile_url(_), do: nil
+
   def ap_id(%User{nickname: nickname}) do
     "#{Web.base_url()}/users/#{nickname}"
   end