Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Commit

Permalink
WIP: Support media api, do some refactor and write API as unimplemented.
Browse files Browse the repository at this point in the history
  • Loading branch information
farodin91 committed Mar 9, 2017
1 parent 37edcf4 commit a6a4142
Show file tree
Hide file tree
Showing 23 changed files with 261 additions and 100 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
40 changes: 40 additions & 0 deletions src/api/r0/client/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//! API client endpoints for the 0.x.x version of the Matrix spec.
pub use self::account::{
AccountPassword,
DeactivateAccount,
PutAccountData,
PutRoomAccountData,
};
pub use self::directory::{GetRoomAlias, DeleteRoomAlias, PutRoomAlias};
pub use self::event_creation::{SendMessageEvent, StateMessageEvent};
pub use self::join::{InviteToRoom, JoinRoom, JoinRoomWithIdOrAlias, KickFromRoom, LeaveRoom};
pub use self::login::Login;
pub use self::logout::Logout;
pub use self::members::Members;
pub use self::presence::{GetPresenceList, GetPresenceStatus, PostPresenceList, PutPresenceStatus};
pub use self::profile::{Profile, GetAvatarUrl, PutAvatarUrl, GetDisplayName, PutDisplayName};
pub use self::registration::Register;
pub use self::room_creation::CreateRoom;
pub use self::room_info::RoomState;
pub use self::tags::{DeleteTag, GetTags, PutTag};
pub use self::sync::Sync;
pub use self::versions::Versions;
pub use self::filter::{GetFilter, PostFilter};

mod account;
mod directory;
mod event_creation;
mod filter;
mod join;
mod login;
mod logout;
mod members;
mod presence;
mod profile;
mod registration;
mod room_creation;
mod room_info;
mod tags;
mod sync;
mod versions;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
38 changes: 38 additions & 0 deletions src/api/r0/media/content.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//! Endpoints for content.
use iron::{Chain, Handler, IronError, IronResult, Request, Response};

use error::ApiError;
use middleware::{AccessTokenAuth, MiddlewareChain};

/// The `/upload` endpoint.
pub struct Upload;

middleware_chain!(Upload, [AccessTokenAuth]);

impl Handler for Upload {
fn handle(&self, _: &mut Request) -> IronResult<Response> {
Err(IronError::from(ApiError::unimplemented(None)))
}
}

/// The `/download/:server_name/:media_id` endpoint.
pub struct Download;

middleware_chain!(Download, [AccessTokenAuth]);

impl Handler for Download {
fn handle(&self, _: &mut Request) -> IronResult<Response> {
Err(IronError::from(ApiError::unimplemented(None)))
}
}

/// The `/download/:server_name/:media_id/:file_name` endpoint.
pub struct DownloadFile;

middleware_chain!(DownloadFile, [AccessTokenAuth]);

impl Handler for DownloadFile {
fn handle(&self, _: &mut Request) -> IronResult<Response> {
Err(IronError::from(ApiError::unimplemented(None)))
}
}
13 changes: 13 additions & 0 deletions src/api/r0/media/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//! API media endpoints for the 0.x.x version of the Matrix spec.
pub use self::content::{
Download,
DownloadFile,
Upload,
};
pub use self::thumbnail::Thumbnail;
pub use self::preview_url::PreviewUrl;

mod content;
mod preview_url;
mod thumbnail;
16 changes: 16 additions & 0 deletions src/api/r0/media/preview_url.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//! Endpoints for content.
use iron::{Chain, Handler, IronError, IronResult, Request, Response};

use error::ApiError;
use middleware::{AccessTokenAuth, MiddlewareChain};

/// The `/preview_url` endpoint.
pub struct PreviewUrl;

middleware_chain!(PreviewUrl, [AccessTokenAuth]);

impl Handler for PreviewUrl {
fn handle(&self, _: &mut Request) -> IronResult<Response> {
Err(IronError::from(ApiError::unimplemented(None)))
}
}
16 changes: 16 additions & 0 deletions src/api/r0/media/thumbnail.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//! Endpoints for content.
use iron::{Chain, Handler, IronError, IronResult, Request, Response};

use error::ApiError;
use middleware::{AccessTokenAuth, MiddlewareChain};

/// The `/thumbnail/:server_name/:media_id` endpoint.
pub struct Thumbnail;

middleware_chain!(Thumbnail, [AccessTokenAuth]);

impl Handler for Thumbnail {
fn handle(&self, _: &mut Request) -> IronResult<Response> {
Err(IronError::from(ApiError::unimplemented(None)))
}
}
74 changes: 42 additions & 32 deletions src/api/r0/mod.rs
Original file line number Diff line number Diff line change
@@ -1,40 +1,50 @@
//! API endpoints for the 0.x.x version of the Matrix spec.
pub use self::account::{
pub use self::client::{
AccountPassword,
CreateRoom,
DeactivateAccount,
DeleteRoomAlias,
DeleteTag,
GetAvatarUrl,
GetDisplayName,
GetFilter,
GetPresenceList,
GetPresenceStatus,
GetRoomAlias,
GetTags,
InviteToRoom,
JoinRoom,
JoinRoomWithIdOrAlias,
KickFromRoom,
LeaveRoom,
Login,
Logout,
Members,
PostFilter,
PostPresenceList,
Profile,
PutAccountData,
PutAvatarUrl,
PutDisplayName,
PutPresenceStatus,
PutRoomAccountData,
PutRoomAlias,
PutTag,
Register,
RoomState,
SendMessageEvent,
StateMessageEvent,
Sync,
Versions,
};
pub use self::media::{
Download,
DownloadFile,
PreviewUrl,
Thumbnail,
Upload,
};
pub use self::directory::{GetRoomAlias, DeleteRoomAlias, PutRoomAlias};
pub use self::event_creation::{SendMessageEvent, StateMessageEvent};
pub use self::join::{InviteToRoom, JoinRoom, JoinRoomWithIdOrAlias, KickFromRoom, LeaveRoom};
pub use self::login::Login;
pub use self::logout::Logout;
pub use self::members::Members;
pub use self::presence::{GetPresenceList, GetPresenceStatus, PostPresenceList, PutPresenceStatus};
pub use self::profile::{Profile, GetAvatarUrl, PutAvatarUrl, GetDisplayName, PutDisplayName};
pub use self::registration::Register;
pub use self::room_creation::CreateRoom;
pub use self::room_info::RoomState;
pub use self::tags::{DeleteTag, GetTags, PutTag};
pub use self::sync::Sync;
pub use self::versions::Versions;
pub use self::filter::{GetFilter, PostFilter};

mod account;
mod directory;
mod event_creation;
mod filter;
mod join;
mod login;
mod logout;
mod members;
mod presence;
mod profile;
mod registration;
mod room_creation;
mod room_info;
mod tags;
mod sync;
mod versions;
mod media;
mod client;
Loading

0 comments on commit a6a4142

Please sign in to comment.