-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
363 additions
and
91 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* Photos.network · A privacy first photo storage and sharing service for fediverse. | ||
* Copyright (C) 2020 Photos network developers | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
use axum::routing::get; | ||
use axum::Router; | ||
use handler::{ | ||
authorize::authorization_handler, | ||
discovery::openid_discover_handler, | ||
jwks::openid_jwks_handler, | ||
login::{get_realm_login_form, post_realm_login}, | ||
}; | ||
use state::ServerState; | ||
use std::sync::{Arc, RwLock}; | ||
|
||
pub mod client; | ||
pub mod config; | ||
pub mod error; | ||
pub mod query; | ||
pub mod realm; | ||
pub mod request; | ||
pub mod state; | ||
pub mod handler { | ||
pub mod authorize; | ||
pub mod discovery; | ||
pub mod jwks; | ||
pub mod login; | ||
} | ||
|
||
pub struct AccountsApi {} | ||
|
||
impl AccountsApi { | ||
pub fn routes<S>() -> Router<S> | ||
where | ||
S: Send + Sync + 'static + Clone, | ||
{ | ||
Router::new() | ||
// Returns information about a single account by ID | ||
// 200 OK | ||
// 401 Unauthorized - Requesting user is unauthenticated | ||
// 404 Not Found - The requested resource does not exist. | ||
.route("/users/:user_id/profile", get(list_photos_handler)) | ||
// Update a single account when `admin.users:write` scope is present | ||
// 200 - OK | ||
// 400 Bad Request - The request body was malformed or a field violated its constraints. | ||
// 401 Unauthorized - You are unauthenticated | ||
// 403 Forbidden - You are authenticated but have no permission to manage the target user. | ||
// 404 Not Found - The requested resource does not exist. | ||
.route("/users/:user_id/profile", patch(list_photos_handler)) | ||
|
||
// Disable a single account by ID when `admin.users:write` scope is present | ||
// 204 No Content - Account was disabled successful | ||
// 401 Unauthorized - You are unauthenticated | ||
// 403 Forbidden - You are authenticated but have no permission to manage the target user. | ||
// 404 Not Found - The requested resource does not exist. | ||
.route("/users/:user_id/disable", patch(list_photos_handler)) | ||
|
||
// Enable a single account by ID when `admin.users:write` scope is present | ||
// 204 No Content - Account was enabled successful | ||
// 401 Unauthorized - You are unauthenticated | ||
// 403 Forbidden - You are authenticated but have no permission to manage the target user. | ||
// 404 Not Found - The requested resource does not exist. | ||
.route("/users/:user_id/enabled", patch(list_photos_handler)) | ||
|
||
.layer(tower_http::trace::TraceLayer::new_for_http()) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# media | ||
|
||
This crate handles all media items like photos or albums for [Photos.network](https://photos.network). | ||
|
||
Persisting the metadata in a database with [SQLx](https://crates.io/crates/sqlx) and accessing the files via [filesystem](https://crates.io/crates/filesystem). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//! Returns the binary of a given entity | ||
//! | ||
|
||
use axum::http::StatusCode; | ||
|
||
pub(crate) async fn file_handler() -> std::result::Result<String, StatusCode> { | ||
// TODO: parse params max-with / max-height =wmax-width-hmax-height (=w2048-h1024) | ||
// -wmax-width (preserving the aspect ratio) | ||
// -hmax-height (preserving the aspect ratio) | ||
// -c crop images to max-width / max-height | ||
// -d remove exif data | ||
|
||
Err(StatusCode::NOT_IMPLEMENTED) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
//! Returns a list of media items owned or shared with the user | ||
//! | ||
pub(crate) async fn list_photos_handler( | ||
|
||
) -> std::result::Result<String, StatusCode> { | ||
Err(StatusCode::NOT_IMPLEMENTED) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
//! Returns the details of a given media item | ||
//! | ||
pub(crate) async fn photo_details_handler( | ||
|
||
) -> std::result::Result<String, StatusCode> { | ||
Err(StatusCode::NOT_IMPLEMENTED) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* Photos.network · A privacy first photo storage and sharing service for fediverse. | ||
* Copyright (C) 2020 Photos network developers | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
use crate::api::handler::file_handler::file_handler; | ||
use axum::routing::{get, patch, post}; | ||
use axum::Router; | ||
|
||
pub struct MediaApi {} | ||
|
||
impl MediaApi { | ||
pub fn routes<S>() -> Router<S> | ||
where | ||
S: Send + Sync + 'static + Clone, | ||
{ | ||
Router::new() | ||
// list owned and shared items | ||
.route("/photos", get(file_handler)) | ||
// get metadata of a specific item | ||
.route("/photos/:entity_id", get(file_handler)) | ||
// update the given media item owned by the user | ||
.route("/photos/:entity_id", patch(file_handler)) | ||
// creates one or multiple media items | ||
.route("/photos", post(file_handler)) | ||
// list owned and shared albums | ||
.route("/albums", get(file_handler)) | ||
// create new album | ||
.route("/albums", post(file_handler)) | ||
// get metadata of a specific owned or shared album | ||
.route("/albums/:entity_id", get(file_handler)) | ||
// updates the given album owned by the user | ||
.route("/albums/:entity_id", patch(file_handler)) | ||
// shares the given album | ||
.route("/albums/:entity_id/share", patch(file_handler)) | ||
// unshares the given album | ||
.route("/albums/:entity_id/unshare", patch(file_handler)) | ||
.layer(tower_http::trace::TraceLayer::new_for_http()) | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,10 @@ | |
pub mod data { | ||
pub mod error; | ||
} | ||
|
||
pub mod api { | ||
pub mod handler { | ||
pub mod file_handler; | ||
} | ||
pub mod router; | ||
} |
File renamed without changes.
Oops, something went wrong.