6d9fe623d5781505ce5a8d9746f30a2a71f4da7a
[akkoma] / lib / pleroma / user.ex
1 defmodule Pleroma.User do
2 use Ecto.Schema
3 alias Pleroma.User
4
5 schema "users" do
6 field :bio, :string
7 field :email, :string
8 field :name, :string
9 field :nickname, :string
10 field :password_hash, :string
11 field :following, { :array, :string }, default: []
12 field :ap_id, :string
13
14 timestamps()
15 end
16
17 def ap_id(%User{nickname: nickname}) do
18 host =
19 Application.get_env(:pleroma, Pleroma.Web.Endpoint)
20 |> Keyword.fetch!(:url)
21 |> Keyword.fetch!(:host)
22
23 "https://#{host}/users/#{nickname}"
24 end
25
26 def ap_followers(%User{} = user) do
27 "#{ap_id(user)}/followers"
28 end
29 end