aboutsummaryrefslogtreecommitdiff
path: root/shardweb/lib/views/identity_view.ex
blob: 86423b2cd523e2c880b620dab1a3a5788258648a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
defmodule ShardWeb.IdentityView do
  use ShardWeb, :view

  def identity_list do
    Shard.Keys.list_identities
  end

  def get_nick(pk) do
    SApp.Identity.get_nick pk
  end

  def people_list do
    Shard.Manager.list_shards
    |> Enum.filter(fn {_, manifest, _} ->
        case manifest do
          %SApp.Identity.Manifest{} -> true
          _ -> false
        end
      end)
  end

  def is_friend(conn, pk) do
    fd = SApp.Directory.friends_dir(conn.assigns.pk)
    SApp.Directory.find(fd, %SApp.Identity.Manifest{pk: pk}) != nil
  end
end