summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre de Lacroix <pierre@pdelacroix.com>2020-06-11 07:04:36 +0200
committerPierre de Lacroix <pierre@pdelacroix.com>2020-06-11 07:04:36 +0200
commit17d42f847605aa073bc0858ba1f05879c2a53c17 (patch)
tree718ba8a4d79e15cb358daa02e36a7fb9a2853b1c
parentimprove client bindings (diff)
bugfixes
-rw-r--r--lib/matrix_app_service_web/controllers/v1/room_controller.ex11
-rw-r--r--lib/matrix_app_service_web/controllers/v1/transaction_controller.ex31
2 files changed, 39 insertions, 3 deletions
diff --git a/lib/matrix_app_service_web/controllers/v1/room_controller.ex b/lib/matrix_app_service_web/controllers/v1/room_controller.ex
index 3729708..17cbac0 100644
--- a/lib/matrix_app_service_web/controllers/v1/room_controller.ex
+++ b/lib/matrix_app_service_web/controllers/v1/room_controller.ex
@@ -1,7 +1,14 @@
defmodule MatrixAppServiceWeb.V1.RoomController do
use MatrixAppServiceWeb, :controller
- def show(conn, _params) do
- send_resp(conn, 404, "")
+ def show(conn, %{"room_alias" => room_alias}) do
+ module = Application.fetch_env!(:matrix_app_service, :room_module)
+
+ with :ok <- module.query_alias(room_alias) do
+ send_resp(conn, 200, "{}")
+ else
+ _ ->
+ send_resp(conn, 404, "")
+ end
end
end
diff --git a/lib/matrix_app_service_web/controllers/v1/transaction_controller.ex b/lib/matrix_app_service_web/controllers/v1/transaction_controller.ex
index 252cfc6..bbb0293 100644
--- a/lib/matrix_app_service_web/controllers/v1/transaction_controller.ex
+++ b/lib/matrix_app_service_web/controllers/v1/transaction_controller.ex
@@ -28,7 +28,7 @@ defmodule MatrixAppServiceWeb.V1.TransactionController do
"unsigned" => unsigned,
"user_id" => user_id
}) do
- module = Application.get_env(:matrix_app_service, :transaction_module)
+ module = Application.fetch_env!(:matrix_app_service, :transaction_module)
event = %MatrixAppService.Event{
age: age,
@@ -46,6 +46,35 @@ defmodule MatrixAppServiceWeb.V1.TransactionController do
module.new_event(event)
end
+ defp create_event(%{
+ "age" => age,
+ "content" => content,
+ "event_id" => event_id,
+ "origin_server_ts" => origin_server_ts,
+ "room_id" => room_id,
+ "sender" => sender,
+ "type" => type,
+ "unsigned" => unsigned,
+ "user_id" => user_id
+ }) do
+ module = Application.fetch_env!(:matrix_app_service, :transaction_module)
+
+ event = %MatrixAppService.Event{
+ age: age,
+ content: content,
+ event_id: event_id,
+ origin_server_ts: origin_server_ts,
+ room_id: room_id,
+ sender: sender,
+ state_key: nil,
+ type: type,
+ unsigned: unsigned,
+ user_id: user_id
+ }
+
+ module.new_event(event)
+ end
+
def create(conn, %{"events" => events}) do
Enum.each(events, &create_event(&1))
send_resp(conn, 200, "{}")