Add since_id for activitypub fetching.
[akkoma] / lib / pleroma / user.ex
index 3fb298d0550ae6ed2e2fa6973e0fe639068338dc..6d9fe623d5781505ce5a8d9746f30a2a71f4da7a 100644 (file)
@@ -1,5 +1,6 @@
 defmodule Pleroma.User do
   use Ecto.Schema
+  alias Pleroma.User
 
   schema "users" do
     field :bio, :string
@@ -7,7 +8,22 @@ defmodule Pleroma.User do
     field :name, :string
     field :nickname, :string
     field :password_hash, :string
+    field :following, { :array, :string }, default: []
+    field :ap_id, :string
 
     timestamps()
   end
+
+  def ap_id(%User{nickname: nickname}) do
+    host =
+      Application.get_env(:pleroma, Pleroma.Web.Endpoint)
+      |> Keyword.fetch!(:url)
+      |> Keyword.fetch!(:host)
+
+    "https://#{host}/users/#{nickname}"
+  end
+
+  def ap_followers(%User{} = user) do
+    "#{ap_id(user)}/followers"
+  end
 end