summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre de Lacroix <pierre@pdelacroix.com>2020-10-12 00:11:00 +0200
committerPierre de Lacroix <pierre@pdelacroix.com>2020-10-12 00:11:00 +0200
commit1d7d87a49c021bf6d210747d8473c6384acdd3bb (patch)
tree9a9ce3700bfdbf0235388796210ff8823cf293bb
parentchange docs main page (diff)
write docs
-rw-r--r--README.md29
-rw-r--r--lib/matrix_app_service.ex70
2 files changed, 95 insertions, 4 deletions
diff --git a/README.md b/README.md
index 8bda91b..f2a5e97 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,30 @@
# MatrixAppService
+
+Library that adds the Matrix Application Service API to Phoenix applications.
+
+## Installation
+
+Add this library to your dependencies in `mix.exs`
+
+```
+defp deps do
+ [...]
+ {:matrix_app_service, "~> 0.1.0"}
+end
+```
+
+## Usage
+
+See [documentation](https://kazarma.gitlab.io/matrix_app_service.ex).
+
+## Roadmap
+
+* [x] Authorization
+* [x] Router
+* [x] User query
+* [x] Room query
+* [x] Transaction push
+* [ ] Third party indications
+* [ ] Bridge functionalities: relations between local and remote rooms
+* [ ] Bridge functionalities: handling of remote sessions
+* [ ] Conveniences for building bots
diff --git a/lib/matrix_app_service.ex b/lib/matrix_app_service.ex
index 769a9f0..49acd1b 100644
--- a/lib/matrix_app_service.ex
+++ b/lib/matrix_app_service.ex
@@ -1,9 +1,71 @@
defmodule MatrixAppService do
@moduledoc """
- MatrixAppService keeps the contexts that define your domain
- and business logic.
+ Library that adds Matrix Application Service functionalities to Phoenix
+ applications.
- Contexts are also responsible for managing your data, regardless
- if it comes from the database, an external API or others.
+ ## Installation
+
+ Add this library to your dependencies in `mix.exs`
+
+ ```
+ defp deps do
+ [...]
+ {:matrix_app_service, "~> 0.1.0"}
+ end
+ ```
+
+ ## Usage
+
+ ### Inject routes
+
+ In your Phoenix Router:
+
+ ```
+ MatrixAppServiceWeb.Router.routes()
+ ```
+
+ ### Write adapters
+
+ Create one or multiple modules that implements the following modules:
+ `MatrixAppService.Adapter.Room`, `MatrixAppService.Adapter.User`,
+ `MatrixAppService.Adapter.Transaction`.
+
+ For instance:
+
+ ```
+ @impl MatrixAppService.Adapter.Room
+ def query_alias(room_alias) do
+ # Do something with the room alias
+ # If the room exists, return :ok
+ end
+
+ @impl MatrixAppService.Adapter.User
+ def query_user(user_id) do
+ # Do something with the user ID
+ # If the user exists, return :ok
+ end
+
+ @impl MatrixAppService.Adapter.Transaction
+ def new_event(%MatrixAppService.Event{type: type, content: content})
+ # Do something with the event
+ end
+ ```
+
+ ### Write configuration
+
+ ```
+ config :matrix_app_service,
+ transaction_adapter: App.Matrix.Transaction,
+ room_adapter: App.Matrix.Room,
+ user_adapter: App.Matrix.User,
+ path: "/matrix"
+ base_url: "http://synapse:8008",
+ access_token: "access token",
+ homeserver_token: "homeserver token"
+ ```
+
+ ### Use the Client-Server API
+
+ You can use the functions in `MatrixAppService.Client`
"""
end