summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre de Lacroix <pierre@pdelacroix.com>2020-12-30 23:54:49 +0100
committerPierre de Lacroix <pierre@pdelacroix.com>2020-12-30 23:54:49 +0100
commit0729f9cd2094b19a9bb30915d7355b83acf01c37 (patch)
treeabc94bd8db088c895d0ad57549d0e1ac994f57a2
parentdefine client behaviour (diff)
fix types
-rw-r--r--lib/matrix_app_service/client.ex7
-rw-r--r--lib/matrix_app_service/client_behaviour.ex7
-rw-r--r--lib/matrix_app_service_web/auth_plug.ex4
-rw-r--r--lib/matrix_app_service_web/router.ex2
4 files changed, 16 insertions, 4 deletions
diff --git a/lib/matrix_app_service/client.ex b/lib/matrix_app_service/client.ex
index 8fbdc35..f7f9f63 100644
--- a/lib/matrix_app_service/client.ex
+++ b/lib/matrix_app_service/client.ex
@@ -21,6 +21,7 @@ defmodule MatrixAppService.Client do
* `:user_id`: user ID
* `:storage`: a `t:Polyjuice.Client.Storage.t/0`
"""
+ @impl true
def client(opts \\ []) do
base_url =
Keyword.get(opts, :base_url) ||
@@ -53,6 +54,7 @@ defmodule MatrixAppService.Client do
1. `options`: see `Polyjuice.Client.Room.create_room/2`
2. `client_options`: see `client/1`
"""
+ @impl true
def create_room(options \\ [], client_options \\ []) do
client(client_options)
|> Polyjuice.Client.Room.create_room(options)
@@ -66,6 +68,7 @@ defmodule MatrixAppService.Client do
2. `room_alias`: room alias
3. `client_options`: see `client/1`
"""
+ @impl true
def create_alias(room_id, room_alias, client_options \\ []) do
client(client_options)
|> Polyjuice.Client.Room.create_alias(room_id, room_alias)
@@ -79,6 +82,7 @@ defmodule MatrixAppService.Client do
2. `msg`: see `Polyjuice.Client.Room.send_message/3`
3. `client_options`: see `client/1`
"""
+ @impl true
def send_message(room_id, msg, client_options \\ []) do
client(client_options)
|> Polyjuice.Client.Room.send_message(room_id, msg)
@@ -97,6 +101,7 @@ defmodule MatrixAppService.Client do
`"guest"`
2. `client_options`: see `client/1`
"""
+ @impl true
def register(opts \\ [], client_options \\ []) do
default_opts = [
inhibit_login: true,
@@ -112,5 +117,5 @@ defmodule MatrixAppService.Client do
defdelegate get_data(client, id, key), to: Polyjuice.Client.Account
defdelegate get_profile(client, id), to: Polyjuice.Client.Profile
- defdelegate modify_display(client, id, name), to: Polyjuice.Client.Profile
+ defdelegate modify_displayname(client, id, name), to: Polyjuice.Client.Profile
end
diff --git a/lib/matrix_app_service/client_behaviour.ex b/lib/matrix_app_service/client_behaviour.ex
index cf56286..6c69846 100644
--- a/lib/matrix_app_service/client_behaviour.ex
+++ b/lib/matrix_app_service/client_behaviour.ex
@@ -12,9 +12,16 @@ defmodule MatrixAppService.ClientBehaviour do
@callback client([client_options()]) ::
Polyjuice.Client.LowLevel.t()
@callback create_room(Keyword.t()) :: {:ok, String.t()} | Any
+ @callback create_room(Keyword.t(), client_options()) :: {:ok, String.t()} | Any
@callback create_alias(String.t(), String.t(), client_options()) :: {:ok, String.t()} | Any
@callback send_message(String.t(), String.t(), client_options()) :: {:ok, String.t()} | Any
+ @callback register() ::
+ {:ok, String.t()} | Any
+ @callback register(Polyjuice.Client.LowLevel.register_opts()) ::
+ {:ok, String.t()} | Any
@callback register(Polyjuice.Client.LowLevel.register_opts(), client_options()) ::
{:ok, String.t()} | Any
@callback get_profile(Polyjuice.Client.LowLevel.t(), String.t()) :: {:ok, map()} | any
+ @callback get_data(Polyjuice.Client.LowLevel.t(), String.t(), String.t()) :: {:ok, map()} | any
+ @callback modify_displayname(Polyjuice.Client.LowLevel.t(), String.t(), String.t()) :: :ok | any
end
diff --git a/lib/matrix_app_service_web/auth_plug.ex b/lib/matrix_app_service_web/auth_plug.ex
index ee431aa..4a0b386 100644
--- a/lib/matrix_app_service_web/auth_plug.ex
+++ b/lib/matrix_app_service_web/auth_plug.ex
@@ -17,12 +17,12 @@ defmodule MatrixAppServiceWeb.AuthPlug do
@doc false
@impl Plug
- def call(%Plug.Conn{params: %{"access_token" => access_token}} = conn, homeserver_token)
+ def call(%Plug.Conn{params: %{"access_token" => _access_token}} = conn, homeserver_token)
when is_binary(homeserver_token) do
verify_access_token(conn, homeserver_token)
end
- def call(%Plug.Conn{params: %{"access_token" => access_token}} = conn, homeserver_token)
+ def call(%Plug.Conn{params: %{"access_token" => _access_token}} = conn, homeserver_token)
when is_function(homeserver_token, 0) do
verify_access_token(conn, homeserver_token.())
end
diff --git a/lib/matrix_app_service_web/router.ex b/lib/matrix_app_service_web/router.ex
index f254bdc..d8340c0 100644
--- a/lib/matrix_app_service_web/router.ex
+++ b/lib/matrix_app_service_web/router.ex
@@ -2,7 +2,7 @@ defmodule MatrixAppServiceWeb.Router do
use Phoenix.Router
use MatrixAppServiceWeb.Routes
- import Plug.Conn
+ # import Plug.Conn
import Phoenix.Controller
# if MatrixAppService.Application.start_endpoint?() do