diff options
Diffstat (limited to 'lib/matrix_app_service_web/controllers/v1/transaction_controller.ex')
-rw-r--r-- | lib/matrix_app_service_web/controllers/v1/transaction_controller.ex | 31 |
1 files changed, 30 insertions, 1 deletions
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, "{}") |