user.ex 629 Bytes
Newer Older
lain's avatar
lain committed
1
2
defmodule Pleroma.User do
  use Ecto.Schema
lain's avatar
lain committed
3
  alias Pleroma.User
lain's avatar
lain committed
4
5
6
7
8
9
10

  schema "users" do
    field :bio, :string
    field :email, :string
    field :name, :string
    field :nickname, :string
    field :password_hash, :string
lain's avatar
lain committed
11
12
    field :following, { :array, :string }, default: []
    field :ap_id, :string
lain's avatar
lain committed
13
14
15

    timestamps()
  end
lain's avatar
lain committed
16
17
18
19
20
21
22
23
24
25
26
27
28

  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
lain's avatar
lain committed
29
end