Initial commit
This commit is contained in:
commit
4339999152
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
Cargo.lock
|
||||
target
|
18
Cargo.toml
Normal file
18
Cargo.toml
Normal file
@ -0,0 +1,18 @@
|
||||
[package]
|
||||
authors = ["Wim de With <wf@dewith.io>"]
|
||||
categories = ["api-bindings", "web-programming"]
|
||||
description = "Types of the endpoints in the Matrix application service API."
|
||||
keywords = ["matrix", "chat", "messaging", "ruma"]
|
||||
license = "MIT"
|
||||
name = "ruma-appservice-api"
|
||||
readme = "README.md"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
ruma-api = "0.11.0"
|
||||
ruma-events = "0.15.1"
|
||||
ruma-identifiers = "0.14.0"
|
||||
serde = { version = "1.0.102", features = ["derive"] }
|
||||
serde_json = "1.0.41"
|
||||
url = { version = "2.1.0", features = ["serde"] }
|
19
LICENSE
Normal file
19
LICENSE
Normal file
@ -0,0 +1,19 @@
|
||||
Copyright (c) 2019 Wim de With
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
16
README.md
Normal file
16
README.md
Normal file
@ -0,0 +1,16 @@
|
||||
# ruma-appservice-api
|
||||
|
||||
**ruma-appservice-api** contains serializable types for the requests and responses for each endpoint in the [Matrix](https://matrix.org/) application service API specification.
|
||||
These types can be shared by application service and server code.
|
||||
|
||||
## Minimum Rust version
|
||||
|
||||
ruma-appservice-api requires Rust 1.34.2 or later.
|
||||
|
||||
## Status
|
||||
|
||||
This project is currently experimental and is very likely to change drastically.
|
||||
|
||||
## License
|
||||
|
||||
[MIT](http://opensource.org/licenses/MIT)
|
13
src/lib.rs
Normal file
13
src/lib.rs
Normal file
@ -0,0 +1,13 @@
|
||||
//! Crate ruma_appservice_api contains serializable types for the requests and responses for each
|
||||
//! endpoint in the [Matrix](https://matrix.org/) application service API specification. These
|
||||
//! types can be shared by application service and server code.
|
||||
|
||||
#![deny(
|
||||
missing_copy_implementations,
|
||||
missing_debug_implementations,
|
||||
missing_docs
|
||||
)]
|
||||
// Since we support Rust 1.34.2, we can't apply this suggestion yet
|
||||
#![allow(clippy::use_self)]
|
||||
|
||||
pub mod v1;
|
4
src/v1.rs
Normal file
4
src/v1.rs
Normal file
@ -0,0 +1,4 @@
|
||||
//! Endpoints for the r0.x.x versions of the application service API specification
|
||||
|
||||
pub mod event;
|
||||
pub mod query;
|
3
src/v1/event.rs
Normal file
3
src/v1/event.rs
Normal file
@ -0,0 +1,3 @@
|
||||
//! Endpoint for sending events.
|
||||
|
||||
pub mod push_events;
|
28
src/v1/event/push_events.rs
Normal file
28
src/v1/event/push_events.rs
Normal file
@ -0,0 +1,28 @@
|
||||
//! [PUT /_matrix/app/v1/transactions/{txnId}](https://matrix.org/docs/spec/application_service/r0.1.2#put-matrix-app-v1-transactions-txnid)
|
||||
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_events::collections::all;
|
||||
|
||||
ruma_api! {
|
||||
metadata {
|
||||
description: "This API is called by the homeserver when it wants to push an event (or batch of events) to the application service.",
|
||||
method: PUT,
|
||||
name: "push_events",
|
||||
path: "/_matrix/app/v1/transactions/:txn_id",
|
||||
rate_limited: false,
|
||||
requires_authentication: true,
|
||||
}
|
||||
|
||||
request {
|
||||
/// The transaction ID for this set of events.
|
||||
///
|
||||
/// Homeservers generate these IDs and they are used to ensure idempotency of results.
|
||||
#[ruma_api(path)]
|
||||
pub txn_id: String,
|
||||
/// A list of events.
|
||||
#[ruma_api(body)]
|
||||
pub events: Vec<all::Event>,
|
||||
}
|
||||
|
||||
response {}
|
||||
}
|
4
src/v1/query.rs
Normal file
4
src/v1/query.rs
Normal file
@ -0,0 +1,4 @@
|
||||
//! Endpoints for querying user IDs and room aliases
|
||||
|
||||
pub mod query_room_alias;
|
||||
pub mod query_user_id;
|
23
src/v1/query/query_room_alias.rs
Normal file
23
src/v1/query/query_room_alias.rs
Normal file
@ -0,0 +1,23 @@
|
||||
//! [GET /_matrix/app/v1/rooms/{roomAlias}](https://matrix.org/docs/spec/application_service/r0.1.2#get-matrix-app-v1-rooms-roomalias)
|
||||
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_identifiers::RoomAliasId;
|
||||
|
||||
ruma_api! {
|
||||
metadata {
|
||||
description: "This endpoint is invoked by the homeserver on an application service to query the existence of a given room alias.",
|
||||
method: GET,
|
||||
name: "query_room_alias",
|
||||
path: "/_matrix/app/v1/rooms/:room_alias",
|
||||
rate_limited: false,
|
||||
requires_authentication: true,
|
||||
}
|
||||
|
||||
request {
|
||||
/// The room alias being queried.
|
||||
#[ruma_api(path)]
|
||||
pub room_alias: RoomAliasId,
|
||||
}
|
||||
|
||||
response {}
|
||||
}
|
23
src/v1/query/query_user_id.rs
Normal file
23
src/v1/query/query_user_id.rs
Normal file
@ -0,0 +1,23 @@
|
||||
//! [GET /_matrix/app/v1/users/{userId}](https://matrix.org/docs/spec/application_service/r0.1.2#get-matrix-app-v1-users-userid)
|
||||
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_identifiers::UserId;
|
||||
|
||||
ruma_api! {
|
||||
metadata {
|
||||
description: "This endpoint is invoked by the homeserver on an application service to query the existence of a given user ID.",
|
||||
method: GET,
|
||||
name: "query_user_id",
|
||||
path: "/_matrix/app/v1/users/:user_id",
|
||||
rate_limited: false,
|
||||
requires_authentication: true,
|
||||
}
|
||||
|
||||
request {
|
||||
/// The user ID being queried.
|
||||
#[ruma_api(path)]
|
||||
pub user_id: UserId,
|
||||
}
|
||||
|
||||
response {}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user