-
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
35 changed files
with
1,222 additions
and
144 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* 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 uuid::Uuid; | ||
|
||
pub struct Details { | ||
pub uuid: &'static Uuid, | ||
pub camera_manufacturer: &'static str, | ||
pub camera_model: &'static str, | ||
pub camera_serial: &'static str, | ||
pub lens_model: &'static str, | ||
pub lens_serial: &'static str, | ||
pub orientation: &'static str, | ||
pub compression: &'static str, | ||
pub resolution_x: &'static str, | ||
pub resolution_y: &'static str, | ||
pub resolution_unit: &'static str, | ||
pub exposure_time: &'static str, | ||
pub exposure_mode: &'static str, | ||
pub exposure_program: &'static str, | ||
pub exposure_bias: &'static str, | ||
pub aperture: &'static f32, | ||
pub iso: &'static i32, | ||
pub color_space: &'static str, | ||
pub pixel_x: &'static i64, | ||
pub pixel_y: &'static i64, | ||
pub user_comment: &'static str, | ||
pub white_balance: &'static str, | ||
pub flash: bool, | ||
pub exif_version: &'static f32, | ||
} |
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,25 @@ | ||
/* 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 uuid::Uuid; | ||
|
||
pub struct Location { | ||
pub uuid: &'static Uuid, | ||
pub latitude: &'static f64, | ||
pub longitude: &'static f64, | ||
pub altitude: &'static Option<f64>, | ||
} |
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,31 @@ | ||
/* 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 std::time::Instant; | ||
|
||
use super::{details::Details, location::Location, reference::Reference, tag::Tag}; | ||
|
||
pub struct MediaItem { | ||
pub uuid: &'static str, | ||
pub name: &'static str, | ||
pub added_at: Instant, | ||
pub taken_at: Option<Instant>, | ||
pub details: Option<Details>, | ||
pub tags: Option<Vec<Tag>>, | ||
pub location: Option<Location>, | ||
pub references: Option<Vec<Reference>>, | ||
} |
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 |
---|---|---|
@@ -1,12 +1,85 @@ | ||
/* 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 async_trait::async_trait; | ||
use std::error::Error; | ||
use time::OffsetDateTime; | ||
|
||
use crate::auth::user::User; | ||
|
||
use self::{media_item::MediaItem, reference::Reference}; | ||
|
||
pub mod details; | ||
pub mod location; | ||
pub mod media_item; | ||
pub mod reference; | ||
pub mod tag; | ||
|
||
#[async_trait] | ||
pub trait Database { | ||
/// Initialize the database and run required migrations | ||
async fn setup(&mut self) -> Result<(), Box<dyn Error>>; | ||
|
||
/// List registered user accounts | ||
async fn get_users(&self) -> Result<Vec<User>, Box<dyn Error>>; | ||
|
||
/// Create a new user account | ||
async fn create_user(&self, user: &User) -> Result<(), Box<dyn Error>>; | ||
|
||
/// Get user by user_id | ||
async fn get_user(&self, user_id: &str) -> Result<User, Box<dyn Error>>; | ||
|
||
/// Partial update a single user account | ||
async fn update_email(&self, email: &str, user_id: &str) -> Result<(), Box<dyn Error>>; | ||
async fn get_users(&self) -> Result<Vec<User>, Box<dyn Error>>; | ||
async fn update_nickname(&self, nickname: &str) -> Result<(), Box<dyn Error>>; | ||
async fn update_names( | ||
&self, | ||
firstname: &str, | ||
lastname: &str, | ||
user_id: &str, | ||
) -> Result<(), Box<dyn Error>>; | ||
|
||
async fn disable_user(&self, user_id: &str) -> Result<(), Box<dyn Error>>; | ||
async fn enable_user(&self, user_id: &str) -> Result<(), Box<dyn Error>>; | ||
|
||
async fn get_media_items(&self, user_id: &str) -> Result<Vec<MediaItem>, Box<dyn Error>>; | ||
async fn create_media_item( | ||
&self, | ||
user_id: &str, | ||
name: &str, | ||
date_taken: OffsetDateTime, | ||
) -> Result<String, Box<dyn Error>>; | ||
async fn get_media_item(&self, media_id: &str) -> Result<MediaItem, Box<dyn Error>>; | ||
async fn add_reference( | ||
&self, | ||
user_id: &str, | ||
media_id: &str, | ||
reference: &Reference, | ||
) -> Result<String, Box<dyn Error>>; | ||
|
||
async fn update_reference( | ||
&self, | ||
reference_id: &str, | ||
reference: &Reference, | ||
) -> Result<(), Box<dyn Error>>; | ||
|
||
async fn remove_reference( | ||
&self, | ||
media_id: &str, | ||
reference_id: &str, | ||
) -> Result<(), Box<dyn Error>>; | ||
} |
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,28 @@ | ||
/* 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 time::OffsetDateTime; | ||
|
||
pub struct Reference { | ||
pub uuid: &'static str, | ||
pub filepath: String, | ||
pub filename: String, | ||
pub size: u64, | ||
pub description: &'static str, | ||
pub last_modified: OffsetDateTime, | ||
pub is_missing: bool, | ||
} |
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,24 @@ | ||
/* 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 uuid::Uuid; | ||
|
||
pub struct Tag { | ||
pub uuid: &'static Uuid, | ||
pub tag: &'static str, | ||
pub origin: &'static str, | ||
} |
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,31 @@ | ||
/* 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 std::time::Instant; | ||
|
||
use super::{details::Details, location::Location, reference::Reference, tag::Tag}; | ||
|
||
pub struct MediaItem { | ||
pub uuid: &'static str, | ||
pub name: &'static str, | ||
pub added_at: Instant, | ||
pub taken_at: Option<Instant>, | ||
pub details: Option<Details>, | ||
pub tags: Option<Vec<Tag>>, | ||
pub location: Option<Location>, | ||
pub references: Option<Vec<Reference>>, | ||
} |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.