Verified Commit 0729f9cd authored by Pierre de Lacroix's avatar Pierre de Lacroix
Browse files

fix types

parent d76110a5
Pipeline #236019678 passed with stages
in 4 minutes and 52 seconds
......@@ -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
......@@ -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
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment