aboutsummaryrefslogtreecommitdiff
path: root/shard/lib/app/identity.ex
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2018-10-12 18:16:46 +0200
committerAlex Auvolat <alex@adnab.me>2018-10-12 18:16:46 +0200
commit574b572fac144135c4381581351445bf5d0de81c (patch)
tree1ad2fa0157583a955069332e6a957250ff362967 /shard/lib/app/identity.ex
parent7bc609a85b43ed86eccb9cd40d9db31f15aaba1d (diff)
downloadshard-0.0.3.tar.gz
shard-0.0.3.zip
Clean up interface to shards0.0.3
Diffstat (limited to 'shard/lib/app/identity.ex')
-rw-r--r--shard/lib/app/identity.ex45
1 files changed, 38 insertions, 7 deletions
diff --git a/shard/lib/app/identity.ex b/shard/lib/app/identity.ex
index 95ffb92..42d1bf8 100644
--- a/shard/lib/app/identity.ex
+++ b/shard/lib/app/identity.ex
@@ -1,14 +1,29 @@
defmodule SApp.Identity do
+ @moduledoc"""
+ Shard application for keeping state associated with a user's identity.
+
+ Current functionality:
+
+ - nickname
+ - peer info: ip, port to connect to if we want a secure connection with this person
+ (used for private chat)
+
+ Future functionnality:
+
+ - friend list
+ - notifications & invites
+ """
+
use GenServer
require Logger
defmodule Manifest do
- defstruct [:pk]
- end
+ @moduledoc"""
+ Manifest for a user identity shard, defined by the public key of the user.
+ """
- defmodule State do
- defstruct [:info, :rev, :signed]
+ defstruct [:pk]
end
defimpl Shard.Manifest, for: Manifest do
@@ -17,6 +32,10 @@ defmodule SApp.Identity do
end
end
+ defmodule State do
+ defstruct [:info, :rev, :signed]
+ end
+
def start_link(pk) do
GenServer.start_link(__MODULE__, pk)
end
@@ -139,11 +158,23 @@ defmodule SApp.Identity do
end
@doc"""
+ Get the info dict of an identity shard. The pid of the shard must be given as an argument.
+ """
+ def get_info(pid) do
+ GenServer.call(pid, :get_info)
+ end
+
+ @doc"""
+ Set the info dict of an identity shard.
+ """
+ def set_info(pid, new_info) do
+ GenServer.call(pid, {:set_info, new_info})
+ end
+
+ @doc"""
Get a user's nickname from his pk
"""
def get_nick(pk) do
- pid = find_proc pk
- info = GenServer.call(pid, :get_info)
- info.nick
+ get_info(find_proc pk).nick
end
end