From 17e07b622f44bd0b2f962fbad0580ed92e26266f Mon Sep 17 00:00:00 2001 From: Jonatan Ziegler Date: Fri, 28 Jul 2023 09:25:47 +0200 Subject: [PATCH 01/45] changed folder? --- .github/workflows/deploy_backend.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy_backend.yaml b/.github/workflows/deploy_backend.yaml index ecc1cdef..e9e5534d 100644 --- a/.github/workflows/deploy_backend.yaml +++ b/.github/workflows/deploy_backend.yaml @@ -46,7 +46,7 @@ jobs: - name: Build and push Docker image uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 with: - context: . + context: "{{defaultContext}}:backend" push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From 4deb21daf9905fa24091b20ea5c04b0d00cfe4c4 Mon Sep 17 00:00:00 2001 From: Jonatan Ziegler Date: Fri, 28 Jul 2023 09:26:59 +0200 Subject: [PATCH 02/45] update version --- .github/workflows/deploy_backend.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy_backend.yaml b/.github/workflows/deploy_backend.yaml index e9e5534d..e68641f9 100644 --- a/.github/workflows/deploy_backend.yaml +++ b/.github/workflows/deploy_backend.yaml @@ -44,7 +44,7 @@ jobs: # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. - name: Build and push Docker image - uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + uses: docker/build-push-action@v4 with: context: "{{defaultContext}}:backend" push: true From 49e03e895a7db17133ef626c470708e615eadf9b Mon Sep 17 00:00:00 2001 From: Jonatan Ziegler Date: Fri, 28 Jul 2023 09:29:41 +0200 Subject: [PATCH 03/45] debug --- .github/workflows/deploy_backend.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy_backend.yaml b/.github/workflows/deploy_backend.yaml index e68641f9..51f5fa02 100644 --- a/.github/workflows/deploy_backend.yaml +++ b/.github/workflows/deploy_backend.yaml @@ -43,10 +43,11 @@ jobs: # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. + - run: pwd && ls - name: Build and push Docker image uses: docker/build-push-action@v4 with: - context: "{{defaultContext}}:backend" + context: . push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From 327989db34fd09c2c0047aa8f5c4c4ab1326e008 Mon Sep 17 00:00:00 2001 From: Jonatan Ziegler Date: Fri, 28 Jul 2023 09:32:39 +0200 Subject: [PATCH 04/45] dockerfile path --- .github/workflows/deploy_backend.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy_backend.yaml b/.github/workflows/deploy_backend.yaml index 51f5fa02..d2252bee 100644 --- a/.github/workflows/deploy_backend.yaml +++ b/.github/workflows/deploy_backend.yaml @@ -43,11 +43,11 @@ jobs: # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. - - run: pwd && ls - name: Build and push Docker image uses: docker/build-push-action@v4 with: context: . + file: ./Dockerfile push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From 3406ead2a904d3f24d5ca7493859255a931a1ef9 Mon Sep 17 00:00:00 2001 From: Whatsuup Date: Wed, 9 Aug 2023 10:55:28 +0200 Subject: [PATCH 05/45] added info logs to flickr api entry --- .../src/layer/data/flickr_api/flickr_api_handler.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/backend/src/layer/data/flickr_api/flickr_api_handler.rs b/backend/src/layer/data/flickr_api/flickr_api_handler.rs index 7bf2ff35..765c054f 100644 --- a/backend/src/layer/data/flickr_api/flickr_api_handler.rs +++ b/backend/src/layer/data/flickr_api/flickr_api_handler.rs @@ -6,6 +6,7 @@ use crate::layer::data::flickr_api::api_request::ApiRequest; use async_trait::async_trait; use lazy_static::lazy_static; use regex::Regex; +use tracing::info; #[derive(Debug)] pub struct FlickrInfo { @@ -33,9 +34,9 @@ impl FlickrApiHandler { } } - // URL TYPE Long 1.1: https://www.flickr.com/photos/gerdavs/52310534489/, id group = 4 - // URL TYPE Long 1.2: https://www.flickr.com/photos/198319418@N06/53077317043, id group = 4 - // URL TYPE Short 2: https://flic.kr/p/2oRguN3, id group = 2 + // URL TYPE Long 1.1: https://www.flickr.com/photos/gerdavs/52310534489/ + // URL TYPE Long 1.2: https://www.flickr.com/photos/198319418@N06/53077317043 + // URL TYPE Short 2: https://flic.kr/p/2oRguN3 // Both cases: Split with '/' and get last member (= photo_id). fn determine_photo_id(url: &str) -> Result { if let Some(groups) = SHORT_URL_REGEX.captures(url) { @@ -85,6 +86,7 @@ impl ImageHoster for FlickrApiHandler { /// # Return /// If the image exists, the [`ImageMetaData`] struct will be returned. async fn validate_url(&self, url: &str) -> Result { + info!("FlickrApi: Started url validation with '{url}'"); let photo_id = Self::determine_photo_id(url)?; self.request.flickr_photos_get_sizes(&photo_id).await } @@ -95,6 +97,7 @@ impl ImageHoster for FlickrApiHandler { /// # Errors /// If errors occur, that not decide weather the image exists or not, they will be returned. async fn check_existence(&self, photo_id: &str) -> Result { + info!("FlickrApi: Checking image existence for '{photo_id}'"); let res = self.request.flickr_photos_get_sizes(photo_id).await; match res { Ok(_) => Ok(true), @@ -118,6 +121,7 @@ impl ImageHoster for FlickrApiHandler { /// # Errors /// If any error occurs, it will be returned. async fn check_licence(&self, photo_id: &str) -> Result { + info!("FlickrApi: Checking image license for '{photo_id}'"); self.request.flickr_photos_license_check(photo_id).await } } From b9a1f1fb021f2f27c8adfb7fcc04b77f9c3fd984 Mon Sep 17 00:00:00 2001 From: Whatsuup Date: Wed, 9 Aug 2023 11:17:35 +0200 Subject: [PATCH 06/45] added error logs before return --- .../logic/api_command/command_handler.rs | 40 +++++++++++++------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/backend/src/layer/logic/api_command/command_handler.rs b/backend/src/layer/logic/api_command/command_handler.rs index 87c166fa..71a748ef 100644 --- a/backend/src/layer/logic/api_command/command_handler.rs +++ b/backend/src/layer/logic/api_command/command_handler.rs @@ -1,5 +1,6 @@ use async_trait::async_trait; use chrono::Local; +use tracing::warn; use crate::{ interface::{ @@ -169,19 +170,34 @@ where url: image_url.clone(), }; self.auth.authn_command(&auth_info, &command_type)?; - let image_meta_data = self.image_hoster.validate_url(&image_url).await?; - let licence_ok = self.image_hoster.check_licence(&image_meta_data.id).await?; - if licence_ok { - self.command_data - .link_image( - auth_info.client_id, - meal_id, - image_meta_data.id, - image_meta_data.image_url, - ) - .await?; + + match self.image_hoster.validate_url(&image_url).await { + Ok(image_meta_data) => { + match self.image_hoster.check_licence(&image_meta_data.id).await { + Ok(licence_ok) => { + if licence_ok { + self.command_data + .link_image( + auth_info.client_id, + meal_id, + image_meta_data.id, + image_meta_data.image_url, + ) + .await?; + } + Ok(()) + }, + Err(e) => { + warn!("{e}"); + return Err(CommandError::ImageHosterError(e)); + } + } + }, + Err(e) => { + warn!("{e}"); + return Err(CommandError::ImageHosterError(e)); + } } - Ok(()) } async fn set_meal_rating(&self, meal_id: Uuid, rating: u32, auth_info: AuthInfo) -> Result<()> { From 9646f7cecf8bfa77615ab76bee2192b4c168ec27 Mon Sep 17 00:00:00 2001 From: Whatsuup Date: Wed, 9 Aug 2023 11:18:05 +0200 Subject: [PATCH 07/45] jonatan: added traces to api_request.rs --- backend/src/layer/data/flickr_api/api_request.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/src/layer/data/flickr_api/api_request.rs b/backend/src/layer/data/flickr_api/api_request.rs index b4008304..cbda4585 100644 --- a/backend/src/layer/data/flickr_api/api_request.rs +++ b/backend/src/layer/data/flickr_api/api_request.rs @@ -5,6 +5,7 @@ use crate::layer::data::flickr_api::json_structs::{JsonRootError, JsonRootLicens use axum::body::Bytes; use reqwest::Response; use serde::de::DeserializeOwned; +use tracing::trace; pub struct ApiRequest { api_key: String, @@ -53,6 +54,7 @@ impl ApiRequest { .bytes() .await .map_err(|e| ImageHosterError::DecodeFailed(e.to_string()))?; + trace!("successfully send request `{GET_SIZES}` to flickr for image {photo_id}"); Self::json_to_struct::(&bytes).map_or_else( |_| Err(Self::determine_error(&bytes)), |root| JsonParser::parse_get_sizes(&root, photo_id), @@ -82,6 +84,7 @@ impl ApiRequest { .bytes() .await .map_err(|e| ImageHosterError::DecodeFailed(e.to_string()))?; + trace!("successfully send request `{GET_LICENCE_HISTORY}` to flickr for image {photo_id}"); Self::json_to_struct::(&bytes).map_or_else( |_| Err(Self::determine_error(&bytes)), |root| Ok(JsonParser::check_license(&root)), From 1b9cbf8bbfd0d18c9cfc0c55c74c0c8cf5e14b8e Mon Sep 17 00:00:00 2001 From: Whatsuup Date: Wed, 9 Aug 2023 11:18:58 +0200 Subject: [PATCH 08/45] changed logs to traces --- backend/src/layer/data/flickr_api/flickr_api_handler.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/src/layer/data/flickr_api/flickr_api_handler.rs b/backend/src/layer/data/flickr_api/flickr_api_handler.rs index 765c054f..92d3417d 100644 --- a/backend/src/layer/data/flickr_api/flickr_api_handler.rs +++ b/backend/src/layer/data/flickr_api/flickr_api_handler.rs @@ -6,7 +6,7 @@ use crate::layer::data::flickr_api::api_request::ApiRequest; use async_trait::async_trait; use lazy_static::lazy_static; use regex::Regex; -use tracing::info; +use tracing::trace; #[derive(Debug)] pub struct FlickrInfo { @@ -86,7 +86,7 @@ impl ImageHoster for FlickrApiHandler { /// # Return /// If the image exists, the [`ImageMetaData`] struct will be returned. async fn validate_url(&self, url: &str) -> Result { - info!("FlickrApi: Started url validation with '{url}'"); + trace!("FlickrApi: Started url validation with '{url}'"); let photo_id = Self::determine_photo_id(url)?; self.request.flickr_photos_get_sizes(&photo_id).await } @@ -97,7 +97,7 @@ impl ImageHoster for FlickrApiHandler { /// # Errors /// If errors occur, that not decide weather the image exists or not, they will be returned. async fn check_existence(&self, photo_id: &str) -> Result { - info!("FlickrApi: Checking image existence for '{photo_id}'"); + trace!("FlickrApi: Checking image existence for '{photo_id}'"); let res = self.request.flickr_photos_get_sizes(photo_id).await; match res { Ok(_) => Ok(true), @@ -121,7 +121,7 @@ impl ImageHoster for FlickrApiHandler { /// # Errors /// If any error occurs, it will be returned. async fn check_licence(&self, photo_id: &str) -> Result { - info!("FlickrApi: Checking image license for '{photo_id}'"); + trace!("FlickrApi: Checking image license for '{photo_id}'"); self.request.flickr_photos_license_check(photo_id).await } } From 52f3be9c10439cc0546da317acc212d4e4c1c08b Mon Sep 17 00:00:00 2001 From: Whatsuup Date: Wed, 9 Aug 2023 11:19:04 +0200 Subject: [PATCH 09/45] formatting --- backend/src/layer/logic/api_command/command_handler.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/layer/logic/api_command/command_handler.rs b/backend/src/layer/logic/api_command/command_handler.rs index 71a748ef..4f2e255c 100644 --- a/backend/src/layer/logic/api_command/command_handler.rs +++ b/backend/src/layer/logic/api_command/command_handler.rs @@ -186,13 +186,13 @@ where .await?; } Ok(()) - }, + } Err(e) => { warn!("{e}"); return Err(CommandError::ImageHosterError(e)); } } - }, + } Err(e) => { warn!("{e}"); return Err(CommandError::ImageHosterError(e)); From 9b774c8fc687118912d33a046c9535f59b07f529 Mon Sep 17 00:00:00 2001 From: Whatsuup Date: Wed, 9 Aug 2023 11:22:27 +0200 Subject: [PATCH 10/45] fixed error ArtificiallyBlackenedOlives --- backend/migrations/20230703130648_food_additive.up.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/migrations/20230703130648_food_additive.up.sql b/backend/migrations/20230703130648_food_additive.up.sql index d2ca73db..a7dc2e29 100644 --- a/backend/migrations/20230703130648_food_additive.up.sql +++ b/backend/migrations/20230703130648_food_additive.up.sql @@ -1,5 +1,5 @@ -- Add up migration script here -CREATE TYPE additive AS ENUM ('COLORANT','PRESERVING_AGENTS','ANTIOXIDANT_AGENTS','FLAVOUR_ENHANCER','PHOSPHATE','SURFACE_WAXED','SULPHUR','ARTIFICALLY_BLACKENED_OLIVES','SWEETENER','LAXATIVE_IF_OVERUSED','PHENYLALANINE','ALCOHOL','PRESSED_MEAT','GLAZING_WITH_CACAO','PRESSED_FISH'); +CREATE TYPE additive AS ENUM ('COLORANT','PRESERVING_AGENTS','ANTIOXIDANT_AGENTS','FLAVOUR_ENHANCER','PHOSPHATE','SURFACE_WAXED','SULPHUR','ARTIFICIALLY_BLACKENED_OLIVES','SWEETENER','LAXATIVE_IF_OVERUSED','PHENYLALANINE','ALCOHOL','PRESSED_MEAT','GLAZING_WITH_CACAO','PRESSED_FISH'); CREATE TABLE food_additive ( food_id uuid REFERENCES food(food_id), From 3727d94149cf16b40679036d97182defa3124a19 Mon Sep 17 00:00:00 2001 From: Whatsuup Date: Wed, 9 Aug 2023 13:00:20 +0200 Subject: [PATCH 11/45] changed error handling for check_license --- backend/src/interface/image_hoster.rs | 5 ++++- .../src/layer/data/flickr_api/api_request.rs | 6 +++--- .../data/flickr_api/flickr_api_handler.rs | 19 +++++++++++-------- .../src/layer/data/flickr_api/json_parser.rs | 9 +++++---- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/backend/src/interface/image_hoster.rs b/backend/src/interface/image_hoster.rs index 04bb5b05..65376899 100644 --- a/backend/src/interface/image_hoster.rs +++ b/backend/src/interface/image_hoster.rs @@ -15,7 +15,7 @@ pub trait ImageHoster: Send + Sync { /// Checks if an image still exists at the hoster website. async fn check_existence(&self, image_id: &str) -> Result; /// Checks whether the licence is acceptable for our purposes. - async fn check_licence(&self, image_id: &str) -> Result; + async fn check_licence(&self, image_id: &str) -> Result<()>; } /// Enum describing the possible ways, a image hoster request can fail. @@ -24,6 +24,9 @@ pub enum ImageHosterError { /// Photo not found error #[error("the photo id passed was not a valid photo id")] PhotoNotFound, + /// License invalid + #[error("the detected license cannot be used: {0}")] + InvalidLicense(String), /// Permission denied error #[error("the calling user does not have permission to view the photo")] PermissionDenied, diff --git a/backend/src/layer/data/flickr_api/api_request.rs b/backend/src/layer/data/flickr_api/api_request.rs index cbda4585..03d5e30b 100644 --- a/backend/src/layer/data/flickr_api/api_request.rs +++ b/backend/src/layer/data/flickr_api/api_request.rs @@ -73,7 +73,7 @@ impl ApiRequest { pub async fn flickr_photos_license_check( &self, photo_id: &str, - ) -> Result { + ) -> Result<(bool, String), ImageHosterError> { let url = &format!( "{BASE_URL}{GET_LICENCE_HISTORY}{TAG_API_KEY}{api_key}{TAG_PHOTO_ID}{photo_id}{FORMAT}", api_key = self.api_key @@ -157,11 +157,11 @@ mod test { #[tokio::test] async fn test_valid_check_license_request() { - let res = get_api_request() + let (valid, license) = get_api_request() .flickr_photos_license_check("52310534489") .await .unwrap(); - assert!(!res); + assert!(!valid); } #[tokio::test] diff --git a/backend/src/layer/data/flickr_api/flickr_api_handler.rs b/backend/src/layer/data/flickr_api/flickr_api_handler.rs index 92d3417d..98000cba 100644 --- a/backend/src/layer/data/flickr_api/flickr_api_handler.rs +++ b/backend/src/layer/data/flickr_api/flickr_api_handler.rs @@ -86,7 +86,6 @@ impl ImageHoster for FlickrApiHandler { /// # Return /// If the image exists, the [`ImageMetaData`] struct will be returned. async fn validate_url(&self, url: &str) -> Result { - trace!("FlickrApi: Started url validation with '{url}'"); let photo_id = Self::determine_photo_id(url)?; self.request.flickr_photos_get_sizes(&photo_id).await } @@ -97,7 +96,6 @@ impl ImageHoster for FlickrApiHandler { /// # Errors /// If errors occur, that not decide weather the image exists or not, they will be returned. async fn check_existence(&self, photo_id: &str) -> Result { - trace!("FlickrApi: Checking image existence for '{photo_id}'"); let res = self.request.flickr_photos_get_sizes(photo_id).await; match res { Ok(_) => Ok(true), @@ -120,9 +118,14 @@ impl ImageHoster for FlickrApiHandler { /// True if the image is published under a valid license. False if not. /// # Errors /// If any error occurs, it will be returned. - async fn check_licence(&self, photo_id: &str) -> Result { - trace!("FlickrApi: Checking image license for '{photo_id}'"); - self.request.flickr_photos_license_check(photo_id).await + async fn check_licence(&self, photo_id: &str) -> Result<()> { + let (valid, license) = self.request.flickr_photos_license_check(photo_id).await?; + return if valid { + Ok(()) + } else { + Err(ImageHosterError::InvalidLicense(license)) + } + } } @@ -141,7 +144,7 @@ where hoster.check_existence(image_id).await } - async fn check_licence(&self, image_id: &str) -> Result { + async fn check_licence(&self, image_id: &str) -> Result<()> { let hoster: &T = self; hoster.check_licence(image_id).await } @@ -238,8 +241,8 @@ mod test { Ok(true) } - async fn check_licence(&self, _image_id: &str) -> Result { - Ok(true) + async fn check_licence(&self, _image_id: &str) -> Result<()> { + Ok(()) } } diff --git a/backend/src/layer/data/flickr_api/json_parser.rs b/backend/src/layer/data/flickr_api/json_parser.rs index 2d1b2257..8aca8275 100644 --- a/backend/src/layer/data/flickr_api/json_parser.rs +++ b/backend/src/layer/data/flickr_api/json_parser.rs @@ -55,7 +55,7 @@ impl JsonParser { /// A boolean if the image has an valid license or not. /// If the image has no license or no license history, the image isn't restricted by any license and true will be returned. #[must_use] - pub fn check_license(root: &JsonRootLicense) -> bool { + pub fn check_license(root: &JsonRootLicense) -> (bool, String) { let license = root .license_history .iter() @@ -63,9 +63,9 @@ impl JsonParser { .map(|entry| &entry.new_license); if let Some(license) = license { - return VALID_LICENSES.contains(&license.as_str()); + return (VALID_LICENSES.contains(&license.as_str()), license.clone()); } - false + (false, String::from("No license could be detected")) } /// Obtains and determines an error by its error code and message provided by the [`JsonRootError`] struct. @@ -181,7 +181,8 @@ mod test { }, ], }; - assert!(JsonParser::check_license(&valid_licenses)); + let (valid, license) = JsonParser::check_license(&valid_licenses); + assert!(valid); } #[test] From a92fbf018870e10c7c4c1317f3742c7f79704aaf Mon Sep 17 00:00:00 2001 From: Whatsuup Date: Wed, 9 Aug 2023 13:03:13 +0200 Subject: [PATCH 12/45] changed error handling for add image in command --- .../logic/api_command/command_handler.rs | 31 +++---------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/backend/src/layer/logic/api_command/command_handler.rs b/backend/src/layer/logic/api_command/command_handler.rs index 4f2e255c..913127e0 100644 --- a/backend/src/layer/logic/api_command/command_handler.rs +++ b/backend/src/layer/logic/api_command/command_handler.rs @@ -171,33 +171,10 @@ where }; self.auth.authn_command(&auth_info, &command_type)?; - match self.image_hoster.validate_url(&image_url).await { - Ok(image_meta_data) => { - match self.image_hoster.check_licence(&image_meta_data.id).await { - Ok(licence_ok) => { - if licence_ok { - self.command_data - .link_image( - auth_info.client_id, - meal_id, - image_meta_data.id, - image_meta_data.image_url, - ) - .await?; - } - Ok(()) - } - Err(e) => { - warn!("{e}"); - return Err(CommandError::ImageHosterError(e)); - } - } - } - Err(e) => { - warn!("{e}"); - return Err(CommandError::ImageHosterError(e)); - } - } + let image_meta_data = self.image_hoster.validate_url(&image_url).await?; + self.image_hoster.check_licence(&image_meta_data.id).await?; + self.command_data.link_image(auth_info.client_id, meal_id, image_meta_data.id, image_meta_data.image_url, ).await?; + Ok(()) } async fn set_meal_rating(&self, meal_id: Uuid, rating: u32, auth_info: AuthInfo) -> Result<()> { From d5057c9bc470c6dfe575be5ed13c00e6695538d5 Mon Sep 17 00:00:00 2001 From: Whatsuup Date: Wed, 9 Aug 2023 13:04:48 +0200 Subject: [PATCH 13/45] clippy --- backend/src/layer/data/flickr_api/flickr_api_handler.rs | 1 - backend/src/layer/logic/api_command/command_handler.rs | 1 - backend/src/layer/logic/api_command/test/mocks.rs | 4 ++-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/backend/src/layer/data/flickr_api/flickr_api_handler.rs b/backend/src/layer/data/flickr_api/flickr_api_handler.rs index 98000cba..1c62a7e7 100644 --- a/backend/src/layer/data/flickr_api/flickr_api_handler.rs +++ b/backend/src/layer/data/flickr_api/flickr_api_handler.rs @@ -6,7 +6,6 @@ use crate::layer::data::flickr_api::api_request::ApiRequest; use async_trait::async_trait; use lazy_static::lazy_static; use regex::Regex; -use tracing::trace; #[derive(Debug)] pub struct FlickrInfo { diff --git a/backend/src/layer/logic/api_command/command_handler.rs b/backend/src/layer/logic/api_command/command_handler.rs index 913127e0..c17ffb0b 100644 --- a/backend/src/layer/logic/api_command/command_handler.rs +++ b/backend/src/layer/logic/api_command/command_handler.rs @@ -1,6 +1,5 @@ use async_trait::async_trait; use chrono::Local; -use tracing::warn; use crate::{ interface::{ diff --git a/backend/src/layer/logic/api_command/test/mocks.rs b/backend/src/layer/logic/api_command/test/mocks.rs index f52ec6ca..c9a5a1f0 100644 --- a/backend/src/layer/logic/api_command/test/mocks.rs +++ b/backend/src/layer/logic/api_command/test/mocks.rs @@ -160,8 +160,8 @@ impl ImageHoster for CommandImageHosterMock { Ok(true) } /// Checks whether the licence is acceptable for our purposes. - async fn check_licence(&self, _image_id: &str) -> ImageResult { - Ok(true) + async fn check_licence(&self, _image_id: &str) -> ImageResult<()> { + Ok(()) } } From 6fc505c685392a5c61393b55589b1e6f8b77a784 Mon Sep 17 00:00:00 2001 From: Whatsuup Date: Wed, 9 Aug 2023 13:05:00 +0200 Subject: [PATCH 14/45] formatting --- backend/src/layer/data/flickr_api/flickr_api_handler.rs | 3 +-- backend/src/layer/logic/api_command/command_handler.rs | 9 ++++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/backend/src/layer/data/flickr_api/flickr_api_handler.rs b/backend/src/layer/data/flickr_api/flickr_api_handler.rs index 1c62a7e7..34cc07de 100644 --- a/backend/src/layer/data/flickr_api/flickr_api_handler.rs +++ b/backend/src/layer/data/flickr_api/flickr_api_handler.rs @@ -123,8 +123,7 @@ impl ImageHoster for FlickrApiHandler { Ok(()) } else { Err(ImageHosterError::InvalidLicense(license)) - } - + }; } } diff --git a/backend/src/layer/logic/api_command/command_handler.rs b/backend/src/layer/logic/api_command/command_handler.rs index c17ffb0b..657325dd 100644 --- a/backend/src/layer/logic/api_command/command_handler.rs +++ b/backend/src/layer/logic/api_command/command_handler.rs @@ -172,7 +172,14 @@ where let image_meta_data = self.image_hoster.validate_url(&image_url).await?; self.image_hoster.check_licence(&image_meta_data.id).await?; - self.command_data.link_image(auth_info.client_id, meal_id, image_meta_data.id, image_meta_data.image_url, ).await?; + self.command_data + .link_image( + auth_info.client_id, + meal_id, + image_meta_data.id, + image_meta_data.image_url, + ) + .await?; Ok(()) } From d4e82b1196c251b42303d27897c8a71873e1d685 Mon Sep 17 00:00:00 2001 From: Whatsuup Date: Wed, 9 Aug 2023 13:06:09 +0200 Subject: [PATCH 15/45] fixed mock --- .../src/layer/logic/image_review/test/image_hoster_mock.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/layer/logic/image_review/test/image_hoster_mock.rs b/backend/src/layer/logic/image_review/test/image_hoster_mock.rs index 23e2910a..290154c2 100644 --- a/backend/src/layer/logic/image_review/test/image_hoster_mock.rs +++ b/backend/src/layer/logic/image_review/test/image_hoster_mock.rs @@ -47,7 +47,7 @@ impl ImageHoster for ImageHosterMock { } } /// Checks whether the licence is acceptable for our purposes. - async fn check_licence(&self, _image_id: &str) -> Result { - Ok(true) + async fn check_licence(&self, _image_id: &str) -> Result<()> { + Ok(()) } } From dabe7a31404be552caf98f549ad932fd254ae5ec Mon Sep 17 00:00:00 2001 From: Whatsuup Date: Wed, 9 Aug 2023 13:24:45 +0200 Subject: [PATCH 16/45] marked unused vars --- backend/src/layer/data/flickr_api/api_request.rs | 2 +- backend/src/layer/data/flickr_api/json_parser.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/layer/data/flickr_api/api_request.rs b/backend/src/layer/data/flickr_api/api_request.rs index 03d5e30b..71ca7746 100644 --- a/backend/src/layer/data/flickr_api/api_request.rs +++ b/backend/src/layer/data/flickr_api/api_request.rs @@ -157,7 +157,7 @@ mod test { #[tokio::test] async fn test_valid_check_license_request() { - let (valid, license) = get_api_request() + let (valid, _license) = get_api_request() .flickr_photos_license_check("52310534489") .await .unwrap(); diff --git a/backend/src/layer/data/flickr_api/json_parser.rs b/backend/src/layer/data/flickr_api/json_parser.rs index 8aca8275..74645627 100644 --- a/backend/src/layer/data/flickr_api/json_parser.rs +++ b/backend/src/layer/data/flickr_api/json_parser.rs @@ -181,7 +181,7 @@ mod test { }, ], }; - let (valid, license) = JsonParser::check_license(&valid_licenses); + let (valid, _license) = JsonParser::check_license(&valid_licenses); assert!(valid); } From 59cb6478b4c1b8d78d0b49652d70c1cbdbd03d5f Mon Sep 17 00:00:00 2001 From: Whatsuup Date: Wed, 9 Aug 2023 13:28:54 +0200 Subject: [PATCH 17/45] cargo sqlx prepare --- ...0d096494183081ae2f474096b7c3f85e733978b532798168c91d811.json | 2 +- ...2a41a9ff120b64e11a200860a6369d3d472262583e991d201995a03.json | 2 +- ...6f09eb6bf55a46425929363c0f8574ea181807ff488f12ba3285fe0.json | 2 +- ...6db71587fd7bef4608c80e8baaf5fb4658de6b7ebc2bb2ae7fd83cb.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/.sqlx/query-4ccb2bf5b0d096494183081ae2f474096b7c3f85e733978b532798168c91d811.json b/backend/.sqlx/query-4ccb2bf5b0d096494183081ae2f474096b7c3f85e733978b532798168c91d811.json index 34e89ddf..ec7cd455 100644 --- a/backend/.sqlx/query-4ccb2bf5b0d096494183081ae2f474096b7c3f85e733978b532798168c91d811.json +++ b/backend/.sqlx/query-4ccb2bf5b0d096494183081ae2f474096b7c3f85e733978b532798168c91d811.json @@ -22,7 +22,7 @@ "PHOSPHATE", "SURFACE_WAXED", "SULPHUR", - "ARTIFICALLY_BLACKENED_OLIVES", + "ARTIFICIALLY_BLACKENED_OLIVES", "SWEETENER", "LAXATIVE_IF_OVERUSED", "PHENYLALANINE", diff --git a/backend/.sqlx/query-6248da40d2a41a9ff120b64e11a200860a6369d3d472262583e991d201995a03.json b/backend/.sqlx/query-6248da40d2a41a9ff120b64e11a200860a6369d3d472262583e991d201995a03.json index 7d4d225f..29ad6986 100644 --- a/backend/.sqlx/query-6248da40d2a41a9ff120b64e11a200860a6369d3d472262583e991d201995a03.json +++ b/backend/.sqlx/query-6248da40d2a41a9ff120b64e11a200860a6369d3d472262583e991d201995a03.json @@ -72,7 +72,7 @@ "PHOSPHATE", "SURFACE_WAXED", "SULPHUR", - "ARTIFICALLY_BLACKENED_OLIVES", + "ARTIFICIALLY_BLACKENED_OLIVES", "SWEETENER", "LAXATIVE_IF_OVERUSED", "PHENYLALANINE", diff --git a/backend/.sqlx/query-a0feec1f96f09eb6bf55a46425929363c0f8574ea181807ff488f12ba3285fe0.json b/backend/.sqlx/query-a0feec1f96f09eb6bf55a46425929363c0f8574ea181807ff488f12ba3285fe0.json index 5c1216b9..42cc1726 100644 --- a/backend/.sqlx/query-a0feec1f96f09eb6bf55a46425929363c0f8574ea181807ff488f12ba3285fe0.json +++ b/backend/.sqlx/query-a0feec1f96f09eb6bf55a46425929363c0f8574ea181807ff488f12ba3285fe0.json @@ -72,7 +72,7 @@ "PHOSPHATE", "SURFACE_WAXED", "SULPHUR", - "ARTIFICALLY_BLACKENED_OLIVES", + "ARTIFICIALLY_BLACKENED_OLIVES", "SWEETENER", "LAXATIVE_IF_OVERUSED", "PHENYLALANINE", diff --git a/backend/.sqlx/query-edc31a0336db71587fd7bef4608c80e8baaf5fb4658de6b7ebc2bb2ae7fd83cb.json b/backend/.sqlx/query-edc31a0336db71587fd7bef4608c80e8baaf5fb4658de6b7ebc2bb2ae7fd83cb.json index 7d5f55a8..3d0b5d35 100644 --- a/backend/.sqlx/query-edc31a0336db71587fd7bef4608c80e8baaf5fb4658de6b7ebc2bb2ae7fd83cb.json +++ b/backend/.sqlx/query-edc31a0336db71587fd7bef4608c80e8baaf5fb4658de6b7ebc2bb2ae7fd83cb.json @@ -18,7 +18,7 @@ "PHOSPHATE", "SURFACE_WAXED", "SULPHUR", - "ARTIFICALLY_BLACKENED_OLIVES", + "ARTIFICIALLY_BLACKENED_OLIVES", "SWEETENER", "LAXATIVE_IF_OVERUSED", "PHENYLALANINE", From 4548adb07491bf581d8d33dba1cf69a177f946f2 Mon Sep 17 00:00:00 2001 From: Jonatan Ziegler Date: Wed, 9 Aug 2023 13:41:45 +0200 Subject: [PATCH 18/45] corrected order of parameters for "link image" --- backend/src/layer/logic/api_command/command_handler.rs | 6 +++--- backend/src/layer/logic/api_command/test/mocks.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/src/layer/logic/api_command/command_handler.rs b/backend/src/layer/logic/api_command/command_handler.rs index 657325dd..67419d38 100644 --- a/backend/src/layer/logic/api_command/command_handler.rs +++ b/backend/src/layer/logic/api_command/command_handler.rs @@ -174,8 +174,8 @@ where self.image_hoster.check_licence(&image_meta_data.id).await?; self.command_data .link_image( - auth_info.client_id, meal_id, + auth_info.client_id, image_meta_data.id, image_meta_data.image_url, ) @@ -374,10 +374,10 @@ mod test { hash: "TLvbxrv6azE4FpA2sROa8CD8ACdRGjj1M6OtLl1h4Q/NYypCKagZz0C2c4SEsoGjRpIbMAaKprFMcavssf2z2w==".into(), ..auth_info.unwrap() }); - assert!(handler + handler .add_image(MEAL_ID_TO_FAIL, image_url.to_string(), auth_info.clone()) .await - .is_err()); + .unwrap_err(); } #[tokio::test] diff --git a/backend/src/layer/logic/api_command/test/mocks.rs b/backend/src/layer/logic/api_command/test/mocks.rs index c9a5a1f0..4ae32cd8 100644 --- a/backend/src/layer/logic/api_command/test/mocks.rs +++ b/backend/src/layer/logic/api_command/test/mocks.rs @@ -103,8 +103,8 @@ impl CommandDataAccess for CommandDatabaseMock { /// Adds an image link to the database. The image will be related to the given meal. async fn link_image( &self, - _user_id: Uuid, meal_id: Uuid, + _user_id: Uuid, _image_hoster_id: String, _url: String, ) -> DataResult<()> { From 6b78e3b0b6916da15ff0059140e6abfc14fb55a9 Mon Sep 17 00:00:00 2001 From: Jonatan Ziegler Date: Wed, 9 Aug 2023 11:41:05 +0200 Subject: [PATCH 19/45] local time in logs --- backend/Cargo.lock | 48 +++++++++++++++++++++++++++++++++- backend/Cargo.toml | 2 +- backend/src/startup/logging.rs | 3 ++- 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 8979ac7a..f88694b8 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -392,7 +392,7 @@ dependencies = [ "iana-time-zone", "js-sys", "num-traits", - "time", + "time 0.1.45", "wasm-bindgen", "winapi", ] @@ -582,6 +582,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "deranged" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7684a49fb1af197853ef7b2ee694bc1f5b4179556f1e5710e1760c5db6f5e929" + [[package]] name = "derive_more" version = "0.99.17" @@ -1611,6 +1617,15 @@ dependencies = [ "libc", ] +[[package]] +name = "num_threads" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" +dependencies = [ + "libc", +] + [[package]] name = "object" version = "0.31.1" @@ -2784,6 +2799,36 @@ dependencies = [ "winapi", ] +[[package]] +name = "time" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fdd63d58b18d663fbdf70e049f00a22c8e42be082203be7f26589213cd75ea" +dependencies = [ + "deranged", + "itoa", + "libc", + "num_threads", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" + +[[package]] +name = "time-macros" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb71511c991639bb078fd5bf97757e03914361c48100d52878b8e52b46fb92cd" +dependencies = [ + "time-core", +] + [[package]] name = "tinyvec" version = "1.6.0" @@ -3008,6 +3053,7 @@ dependencies = [ "sharded-slab", "smallvec", "thread_local", + "time 0.3.25", "tracing", "tracing-core", "tracing-log", diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 19987b90..3a629376 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -19,7 +19,7 @@ async-graphql = {version = "5.0.10", features = ["chrono", "uuid", "tracing"]} async-graphql-axum = "5.0.10" tokio = {version = "1.29.0", features = ["full"]} tracing = "0.1" -tracing-subscriber = {version = "0.3.17", features = ["env-filter"]} +tracing-subscriber = {version = "0.3.17", features = ["env-filter", "local-time"]} base64 = "0.21.2" sha2 = "0.10.7" heck = "0.4.1" diff --git a/backend/src/startup/logging.rs b/backend/src/startup/logging.rs index 3a0a3817..7874e5ce 100644 --- a/backend/src/startup/logging.rs +++ b/backend/src/startup/logging.rs @@ -1,4 +1,4 @@ -use tracing_subscriber::{EnvFilter, FmtSubscriber}; +use tracing_subscriber::{fmt::time::LocalTime, EnvFilter, FmtSubscriber}; /// Struct containing all configurations available for the logging system. pub struct LogInfo { @@ -18,6 +18,7 @@ impl Logger { let subscriber = FmtSubscriber::builder() .with_env_filter(env_filter) + .with_timer(LocalTime::rfc_3339()) .pretty() .finish(); tracing::subscriber::set_global_default(subscriber) From 917e05b910bcecd12750f80ce0189c54f12b9ab9 Mon Sep 17 00:00:00 2001 From: Whatsuup Date: Wed, 9 Aug 2023 14:11:46 +0200 Subject: [PATCH 20/45] error determination moved to parser --- .../src/layer/data/flickr_api/api_request.rs | 18 ++++++++++------ .../data/flickr_api/flickr_api_handler.rs | 7 +------ .../src/layer/data/flickr_api/json_parser.rs | 21 ++++++++++++------- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/backend/src/layer/data/flickr_api/api_request.rs b/backend/src/layer/data/flickr_api/api_request.rs index 71ca7746..a5f0dd2c 100644 --- a/backend/src/layer/data/flickr_api/api_request.rs +++ b/backend/src/layer/data/flickr_api/api_request.rs @@ -73,7 +73,7 @@ impl ApiRequest { pub async fn flickr_photos_license_check( &self, photo_id: &str, - ) -> Result<(bool, String), ImageHosterError> { + ) -> Result<(), ImageHosterError> { let url = &format!( "{BASE_URL}{GET_LICENCE_HISTORY}{TAG_API_KEY}{api_key}{TAG_PHOTO_ID}{photo_id}{FORMAT}", api_key = self.api_key @@ -87,7 +87,14 @@ impl ApiRequest { trace!("successfully send request `{GET_LICENCE_HISTORY}` to flickr for image {photo_id}"); Self::json_to_struct::(&bytes).map_or_else( |_| Err(Self::determine_error(&bytes)), - |root| Ok(JsonParser::check_license(&root)), + |root| { + let (valid, license) = JsonParser::check_license(&root); + if valid { + Ok(()) + } else { + Err(ImageHosterError::InvalidLicense(license)) + } + }, ) } @@ -157,11 +164,10 @@ mod test { #[tokio::test] async fn test_valid_check_license_request() { - let (valid, _license) = get_api_request() + let res = get_api_request() .flickr_photos_license_check("52310534489") - .await - .unwrap(); - assert!(!valid); + .await; + assert!(res.is_err()); } #[tokio::test] diff --git a/backend/src/layer/data/flickr_api/flickr_api_handler.rs b/backend/src/layer/data/flickr_api/flickr_api_handler.rs index 34cc07de..da970415 100644 --- a/backend/src/layer/data/flickr_api/flickr_api_handler.rs +++ b/backend/src/layer/data/flickr_api/flickr_api_handler.rs @@ -118,12 +118,7 @@ impl ImageHoster for FlickrApiHandler { /// # Errors /// If any error occurs, it will be returned. async fn check_licence(&self, photo_id: &str) -> Result<()> { - let (valid, license) = self.request.flickr_photos_license_check(photo_id).await?; - return if valid { - Ok(()) - } else { - Err(ImageHosterError::InvalidLicense(license)) - }; + self.request.flickr_photos_license_check(photo_id).await } } diff --git a/backend/src/layer/data/flickr_api/json_parser.rs b/backend/src/layer/data/flickr_api/json_parser.rs index 74645627..bb996906 100644 --- a/backend/src/layer/data/flickr_api/json_parser.rs +++ b/backend/src/layer/data/flickr_api/json_parser.rs @@ -54,18 +54,24 @@ impl JsonParser { /// # Return /// A boolean if the image has an valid license or not. /// If the image has no license or no license history, the image isn't restricted by any license and true will be returned. - #[must_use] - pub fn check_license(root: &JsonRootLicense) -> (bool, String) { + pub fn check_license(root: &JsonRootLicense) -> Result<(), ImageHosterError> { let license = root .license_history - .iter() + .into_iter() .max_by_key(|l| l.date_change) - .map(|entry| &entry.new_license); + .map(|entry| entry.new_license); if let Some(license) = license { - return (VALID_LICENSES.contains(&license.as_str()), license.clone()); + let str_license = license.as_str(); + return if !VALID_LICENSES.contains(&str_license) { + Err(ImageHosterError::InvalidLicense(license)) + } else { + Ok(()) + }; } - (false, String::from("No license could be detected")) + Err(ImageHosterError::InvalidLicense(String::from( + "No license could be detected", + ))) } /// Obtains and determines an error by its error code and message provided by the [`JsonRootError`] struct. @@ -181,8 +187,7 @@ mod test { }, ], }; - let (valid, _license) = JsonParser::check_license(&valid_licenses); - assert!(valid); + assert!(JsonParser::check_license(&valid_licenses).is_ok()); } #[test] From 1e4dccf0a47d0f8da840e6c418a6076fdd272118 Mon Sep 17 00:00:00 2001 From: Whatsuup Date: Wed, 9 Aug 2023 14:14:25 +0200 Subject: [PATCH 21/45] fixed resulting errors --- backend/src/layer/data/flickr_api/api_request.rs | 9 +-------- backend/src/layer/data/flickr_api/json_parser.rs | 4 ++-- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/backend/src/layer/data/flickr_api/api_request.rs b/backend/src/layer/data/flickr_api/api_request.rs index a5f0dd2c..07a4a3fa 100644 --- a/backend/src/layer/data/flickr_api/api_request.rs +++ b/backend/src/layer/data/flickr_api/api_request.rs @@ -87,14 +87,7 @@ impl ApiRequest { trace!("successfully send request `{GET_LICENCE_HISTORY}` to flickr for image {photo_id}"); Self::json_to_struct::(&bytes).map_or_else( |_| Err(Self::determine_error(&bytes)), - |root| { - let (valid, license) = JsonParser::check_license(&root); - if valid { - Ok(()) - } else { - Err(ImageHosterError::InvalidLicense(license)) - } - }, + JsonParser::check_license, ) } diff --git a/backend/src/layer/data/flickr_api/json_parser.rs b/backend/src/layer/data/flickr_api/json_parser.rs index bb996906..90a8c314 100644 --- a/backend/src/layer/data/flickr_api/json_parser.rs +++ b/backend/src/layer/data/flickr_api/json_parser.rs @@ -54,7 +54,7 @@ impl JsonParser { /// # Return /// A boolean if the image has an valid license or not. /// If the image has no license or no license history, the image isn't restricted by any license and true will be returned. - pub fn check_license(root: &JsonRootLicense) -> Result<(), ImageHosterError> { + pub fn check_license(root: JsonRootLicense) -> Result<(), ImageHosterError> { let license = root .license_history .into_iter() @@ -187,7 +187,7 @@ mod test { }, ], }; - assert!(JsonParser::check_license(&valid_licenses).is_ok()); + assert!(JsonParser::check_license(valid_licenses).is_ok()); } #[test] From a0f49367dacca86744d95f8c5e7da3c5c314fc30 Mon Sep 17 00:00:00 2001 From: Whatsuup Date: Wed, 9 Aug 2023 14:16:38 +0200 Subject: [PATCH 22/45] added valid licenses to error type --- backend/src/interface/image_hoster.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/src/interface/image_hoster.rs b/backend/src/interface/image_hoster.rs index 65376899..2ab89c55 100644 --- a/backend/src/interface/image_hoster.rs +++ b/backend/src/interface/image_hoster.rs @@ -24,7 +24,10 @@ pub enum ImageHosterError { /// Photo not found error #[error("the photo id passed was not a valid photo id")] PhotoNotFound, - /// License invalid + /// License invalid. List of valid licenses: + /// - `No known copyright restrictions` + /// - `Public Domain Dedication (CC0)` + /// - `Public Domain Mark` #[error("the detected license cannot be used: {0}")] InvalidLicense(String), /// Permission denied error From dcb16c2ae9673858a3013eebb4b91c56cc49cc6d Mon Sep 17 00:00:00 2001 From: Whatsuup Date: Wed, 9 Aug 2023 14:18:55 +0200 Subject: [PATCH 23/45] clippy --- backend/src/layer/data/flickr_api/json_parser.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/backend/src/layer/data/flickr_api/json_parser.rs b/backend/src/layer/data/flickr_api/json_parser.rs index 90a8c314..e8fef4b1 100644 --- a/backend/src/layer/data/flickr_api/json_parser.rs +++ b/backend/src/layer/data/flickr_api/json_parser.rs @@ -54,6 +54,8 @@ impl JsonParser { /// # Return /// A boolean if the image has an valid license or not. /// If the image has no license or no license history, the image isn't restricted by any license and true will be returned. + /// # Errors + /// If an image is invalid [`ImageHosterError::InvalidLicense`] with the invalid license will be returned. pub fn check_license(root: JsonRootLicense) -> Result<(), ImageHosterError> { let license = root .license_history @@ -63,10 +65,10 @@ impl JsonParser { if let Some(license) = license { let str_license = license.as_str(); - return if !VALID_LICENSES.contains(&str_license) { - Err(ImageHosterError::InvalidLicense(license)) - } else { + return if VALID_LICENSES.contains(&str_license) { Ok(()) + } else { + Err(ImageHosterError::InvalidLicense(license)) }; } Err(ImageHosterError::InvalidLicense(String::from( From 7e459b9effc55d7cdcdf5baf53e1856682ea889c Mon Sep 17 00:00:00 2001 From: Jonatan Ziegler Date: Wed, 9 Aug 2023 14:31:15 +0200 Subject: [PATCH 24/45] logging time works on linux --- backend/src/startup/logging.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/startup/logging.rs b/backend/src/startup/logging.rs index 7874e5ce..8dca786f 100644 --- a/backend/src/startup/logging.rs +++ b/backend/src/startup/logging.rs @@ -1,4 +1,4 @@ -use tracing_subscriber::{fmt::time::LocalTime, EnvFilter, FmtSubscriber}; +use tracing_subscriber::{fmt::time::OffsetTime, EnvFilter, FmtSubscriber}; /// Struct containing all configurations available for the logging system. pub struct LogInfo { @@ -18,7 +18,7 @@ impl Logger { let subscriber = FmtSubscriber::builder() .with_env_filter(env_filter) - .with_timer(LocalTime::rfc_3339()) + .with_timer(OffsetTime::local_rfc_3339().expect("could not get local time")) .pretty() .finish(); tracing::subscriber::set_global_default(subscriber) From ee6056dbc85fc2d2831b200c38013515438d5f25 Mon Sep 17 00:00:00 2001 From: Jonatan Ziegler Date: Wed, 9 Aug 2023 14:37:35 +0200 Subject: [PATCH 25/45] removing timezones for logging again --- backend/Cargo.lock | 48 +--------------------------------- backend/Cargo.toml | 2 +- backend/src/startup/logging.rs | 3 +-- 3 files changed, 3 insertions(+), 50 deletions(-) diff --git a/backend/Cargo.lock b/backend/Cargo.lock index f88694b8..8979ac7a 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -392,7 +392,7 @@ dependencies = [ "iana-time-zone", "js-sys", "num-traits", - "time 0.1.45", + "time", "wasm-bindgen", "winapi", ] @@ -582,12 +582,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "deranged" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7684a49fb1af197853ef7b2ee694bc1f5b4179556f1e5710e1760c5db6f5e929" - [[package]] name = "derive_more" version = "0.99.17" @@ -1617,15 +1611,6 @@ dependencies = [ "libc", ] -[[package]] -name = "num_threads" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" -dependencies = [ - "libc", -] - [[package]] name = "object" version = "0.31.1" @@ -2799,36 +2784,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "time" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fdd63d58b18d663fbdf70e049f00a22c8e42be082203be7f26589213cd75ea" -dependencies = [ - "deranged", - "itoa", - "libc", - "num_threads", - "serde", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" - -[[package]] -name = "time-macros" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb71511c991639bb078fd5bf97757e03914361c48100d52878b8e52b46fb92cd" -dependencies = [ - "time-core", -] - [[package]] name = "tinyvec" version = "1.6.0" @@ -3053,7 +3008,6 @@ dependencies = [ "sharded-slab", "smallvec", "thread_local", - "time 0.3.25", "tracing", "tracing-core", "tracing-log", diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 3a629376..19987b90 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -19,7 +19,7 @@ async-graphql = {version = "5.0.10", features = ["chrono", "uuid", "tracing"]} async-graphql-axum = "5.0.10" tokio = {version = "1.29.0", features = ["full"]} tracing = "0.1" -tracing-subscriber = {version = "0.3.17", features = ["env-filter", "local-time"]} +tracing-subscriber = {version = "0.3.17", features = ["env-filter"]} base64 = "0.21.2" sha2 = "0.10.7" heck = "0.4.1" diff --git a/backend/src/startup/logging.rs b/backend/src/startup/logging.rs index 8dca786f..3a0a3817 100644 --- a/backend/src/startup/logging.rs +++ b/backend/src/startup/logging.rs @@ -1,4 +1,4 @@ -use tracing_subscriber::{fmt::time::OffsetTime, EnvFilter, FmtSubscriber}; +use tracing_subscriber::{EnvFilter, FmtSubscriber}; /// Struct containing all configurations available for the logging system. pub struct LogInfo { @@ -18,7 +18,6 @@ impl Logger { let subscriber = FmtSubscriber::builder() .with_env_filter(env_filter) - .with_timer(OffsetTime::local_rfc_3339().expect("could not get local time")) .pretty() .finish(); tracing::subscriber::set_global_default(subscriber) From 7aa34261542eef8d4bbe2f26e901e6cb4c272f39 Mon Sep 17 00:00:00 2001 From: Alexander <32518454+Whatsuup@users.noreply.github.com> Date: Wed, 9 Aug 2023 15:12:29 +0200 Subject: [PATCH 26/45] change requested option handling --- .../src/layer/data/flickr_api/json_parser.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/backend/src/layer/data/flickr_api/json_parser.rs b/backend/src/layer/data/flickr_api/json_parser.rs index e8fef4b1..b951c944 100644 --- a/backend/src/layer/data/flickr_api/json_parser.rs +++ b/backend/src/layer/data/flickr_api/json_parser.rs @@ -63,17 +63,15 @@ impl JsonParser { .max_by_key(|l| l.date_change) .map(|entry| entry.new_license); - if let Some(license) = license { - let str_license = license.as_str(); - return if VALID_LICENSES.contains(&str_license) { - Ok(()) - } else { - Err(ImageHosterError::InvalidLicense(license)) - }; + let license = license.ok_or_else(|| { + ImageHosterError::InvalidLicense(String::from("No license could be detected")) + })?; + let str_license = license.as_str(); + if VALID_LICENSES.contains(&str_license) { + Ok(()) + } else { + Err(ImageHosterError::InvalidLicense(license)) } - Err(ImageHosterError::InvalidLicense(String::from( - "No license could be detected", - ))) } /// Obtains and determines an error by its error code and message provided by the [`JsonRootError`] struct. From 7e4f281c13d3eb351dcb0e4e80c0033bf5556687 Mon Sep 17 00:00:00 2001 From: Whatsuup Date: Wed, 9 Aug 2023 15:24:49 +0200 Subject: [PATCH 27/45] added license to error message --- backend/src/interface/image_hoster.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/interface/image_hoster.rs b/backend/src/interface/image_hoster.rs index 2ab89c55..23d946a7 100644 --- a/backend/src/interface/image_hoster.rs +++ b/backend/src/interface/image_hoster.rs @@ -28,7 +28,7 @@ pub enum ImageHosterError { /// - `No known copyright restrictions` /// - `Public Domain Dedication (CC0)` /// - `Public Domain Mark` - #[error("the detected license cannot be used: {0}")] + #[error("the detected license cannot be used: '{0}'\nList of valid licenses:\n- No known copyright restrictions\n- Public Domain Dedication (CC0)\n- Public Domain Mark\n")] InvalidLicense(String), /// Permission denied error #[error("the calling user does not have permission to view the photo")] From ff01719c87e392aa2d61959cb0a784d649337919 Mon Sep 17 00:00:00 2001 From: Whatsuup Date: Wed, 9 Aug 2023 17:14:02 +0200 Subject: [PATCH 28/45] added valid licenses to error type --- backend/src/interface/image_hoster.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/interface/image_hoster.rs b/backend/src/interface/image_hoster.rs index 23d946a7..4967148d 100644 --- a/backend/src/interface/image_hoster.rs +++ b/backend/src/interface/image_hoster.rs @@ -28,8 +28,8 @@ pub enum ImageHosterError { /// - `No known copyright restrictions` /// - `Public Domain Dedication (CC0)` /// - `Public Domain Mark` - #[error("the detected license cannot be used: '{0}'\nList of valid licenses:\n- No known copyright restrictions\n- Public Domain Dedication (CC0)\n- Public Domain Mark\n")] - InvalidLicense(String), + #[error("the detected license cannot be used: '{0}'\nList of valid licenses:\n{1}")] + InvalidLicense(String, String), /// Permission denied error #[error("the calling user does not have permission to view the photo")] PermissionDenied, From 83b9a5581a82130370578f29a1c1bcaafbf15e10 Mon Sep 17 00:00:00 2001 From: Whatsuup Date: Wed, 9 Aug 2023 17:16:08 +0200 Subject: [PATCH 29/45] passed valid licenses to error --- .../src/layer/data/flickr_api/json_parser.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/backend/src/layer/data/flickr_api/json_parser.rs b/backend/src/layer/data/flickr_api/json_parser.rs index b951c944..ff4dc7a1 100644 --- a/backend/src/layer/data/flickr_api/json_parser.rs +++ b/backend/src/layer/data/flickr_api/json_parser.rs @@ -61,16 +61,21 @@ impl JsonParser { .license_history .into_iter() .max_by_key(|l| l.date_change) - .map(|entry| entry.new_license); - - let license = license.ok_or_else(|| { - ImageHosterError::InvalidLicense(String::from("No license could be detected")) - })?; + .map(|entry| entry.new_license) + .ok_or_else(|| { + ImageHosterError::InvalidLicense( + String::from("No license could be detected"), + format!("{VALID_LICENSES:?}"), + ) + })?; let str_license = license.as_str(); if VALID_LICENSES.contains(&str_license) { Ok(()) } else { - Err(ImageHosterError::InvalidLicense(license)) + Err(ImageHosterError::InvalidLicense( + license, + format!("{VALID_LICENSES:?}"), + )) } } From 1555e632a6c3a0735df0641a745338990cad1455 Mon Sep 17 00:00:00 2001 From: uglrl <134957879+uglrl@users.noreply.github.com> Date: Thu, 10 Aug 2023 11:57:34 +0200 Subject: [PATCH 30/45] Fixed GESCHLOSSEN is a Meal --- backend/src/layer/data/swka_parser/html_parser.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/backend/src/layer/data/swka_parser/html_parser.rs b/backend/src/layer/data/swka_parser/html_parser.rs index 43b710b3..c64b9f01 100644 --- a/backend/src/layer/data/swka_parser/html_parser.rs +++ b/backend/src/layer/data/swka_parser/html_parser.rs @@ -131,6 +131,8 @@ const DATE_FORMAT: &str = "%Y-%m-%d"; const NUMBER_OF_MEAL_TYPES: usize = 8; const PRICE_TYPE_COUNT: usize = 4; +const LINE_CLOSED_MEAL_NAME: &str = "GESCHLOSSEN"; + const SELECTOR_PARSE_E_MSG: &str = "Error while parsing Selector string"; const REGEX_PARSE_E_MSG: &str = "Error while parsing regex string"; const INVALID_ROOT_NODE_MESSAGE: &str = @@ -301,9 +303,13 @@ impl HTMLParser { fn get_dish_name(dish_node: &ElementRef) -> Option { let dish_name_node = dish_node.select(&DISH_NAME_NODE_CLASS_SELECTOR).next()?; - Some(Self::remove_multiple_whitespaces( - &dish_name_node.text().collect::(), - )) + let dish_name = + Self::remove_multiple_whitespaces(&dish_name_node.text().collect::()); + if dish_name == LINE_CLOSED_MEAL_NAME { + None + } else { + Some(dish_name) + } } fn remove_multiple_whitespaces(string: &str) -> String { From 4302a386e37e77acede0e455b751f3dd07776280 Mon Sep 17 00:00:00 2001 From: Jonatan Ziegler Date: Fri, 11 Aug 2023 08:02:04 +0200 Subject: [PATCH 31/45] invalid license message --- backend/src/interface/image_hoster.rs | 2 +- backend/src/layer/data/flickr_api/json_parser.rs | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/backend/src/interface/image_hoster.rs b/backend/src/interface/image_hoster.rs index 4967148d..7ab34fd7 100644 --- a/backend/src/interface/image_hoster.rs +++ b/backend/src/interface/image_hoster.rs @@ -28,7 +28,7 @@ pub enum ImageHosterError { /// - `No known copyright restrictions` /// - `Public Domain Dedication (CC0)` /// - `Public Domain Mark` - #[error("the detected license cannot be used: '{0}'\nList of valid licenses:\n{1}")] + #[error("invalid license '{0}' detected, expected one of: {1}")] InvalidLicense(String, String), /// Permission denied error #[error("the calling user does not have permission to view the photo")] diff --git a/backend/src/layer/data/flickr_api/json_parser.rs b/backend/src/layer/data/flickr_api/json_parser.rs index ff4dc7a1..5d1a4524 100644 --- a/backend/src/layer/data/flickr_api/json_parser.rs +++ b/backend/src/layer/data/flickr_api/json_parser.rs @@ -63,10 +63,7 @@ impl JsonParser { .max_by_key(|l| l.date_change) .map(|entry| entry.new_license) .ok_or_else(|| { - ImageHosterError::InvalidLicense( - String::from("No license could be detected"), - format!("{VALID_LICENSES:?}"), - ) + ImageHosterError::InvalidLicense(String::from("none"), VALID_LICENSES.join(", ")) })?; let str_license = license.as_str(); if VALID_LICENSES.contains(&str_license) { @@ -74,7 +71,7 @@ impl JsonParser { } else { Err(ImageHosterError::InvalidLicense( license, - format!("{VALID_LICENSES:?}"), + VALID_LICENSES.join(", "), )) } } From e835cee2df8b69c73502923cf8f70acb027150c7 Mon Sep 17 00:00:00 2001 From: Jonatan Ziegler Date: Fri, 11 Aug 2023 09:14:46 +0200 Subject: [PATCH 32/45] fixed overwriting image votes --- ...474096b7c3f85e733978b532798168c91d811.json | 2 +- ...200860a6369d3d472262583e991d201995a03.json | 2 +- ...517758a97fe3556b18b6cc7009a796e5ed4f6.json | 15 ++++++ ...29363c0f8574ea181807ff488f12ba3285fe0.json | 2 +- ...c4ee61bc76604e7047559dae46769dd61f6ff.json | 15 ------ ...33daed48ece0eb44712939bcc76d1a28b2ca6.json | 15 ++++++ ...c80e8baaf5fb4658de6b7ebc2bb2ae7fd83cb.json | 2 +- ...0db0f91c31357f6db23c625aa90153886f4c2.json | 15 ------ backend/src/layer/data/database/command.rs | 49 +++++++++++++++++-- 9 files changed, 79 insertions(+), 38 deletions(-) create mode 100644 backend/.sqlx/query-6d2e83bf144d05cc0c35560e595517758a97fe3556b18b6cc7009a796e5ed4f6.json delete mode 100644 backend/.sqlx/query-c60fd3cf348314ea8fb246589d9c4ee61bc76604e7047559dae46769dd61f6ff.json create mode 100644 backend/.sqlx/query-e4d8e91bfa5b83ca72687bbe3d733daed48ece0eb44712939bcc76d1a28b2ca6.json delete mode 100644 backend/.sqlx/query-ffbbe6b50eae0544be68e79f3840db0f91c31357f6db23c625aa90153886f4c2.json diff --git a/backend/.sqlx/query-4ccb2bf5b0d096494183081ae2f474096b7c3f85e733978b532798168c91d811.json b/backend/.sqlx/query-4ccb2bf5b0d096494183081ae2f474096b7c3f85e733978b532798168c91d811.json index ec7cd455..34e89ddf 100644 --- a/backend/.sqlx/query-4ccb2bf5b0d096494183081ae2f474096b7c3f85e733978b532798168c91d811.json +++ b/backend/.sqlx/query-4ccb2bf5b0d096494183081ae2f474096b7c3f85e733978b532798168c91d811.json @@ -22,7 +22,7 @@ "PHOSPHATE", "SURFACE_WAXED", "SULPHUR", - "ARTIFICIALLY_BLACKENED_OLIVES", + "ARTIFICALLY_BLACKENED_OLIVES", "SWEETENER", "LAXATIVE_IF_OVERUSED", "PHENYLALANINE", diff --git a/backend/.sqlx/query-6248da40d2a41a9ff120b64e11a200860a6369d3d472262583e991d201995a03.json b/backend/.sqlx/query-6248da40d2a41a9ff120b64e11a200860a6369d3d472262583e991d201995a03.json index 29ad6986..7d4d225f 100644 --- a/backend/.sqlx/query-6248da40d2a41a9ff120b64e11a200860a6369d3d472262583e991d201995a03.json +++ b/backend/.sqlx/query-6248da40d2a41a9ff120b64e11a200860a6369d3d472262583e991d201995a03.json @@ -72,7 +72,7 @@ "PHOSPHATE", "SURFACE_WAXED", "SULPHUR", - "ARTIFICIALLY_BLACKENED_OLIVES", + "ARTIFICALLY_BLACKENED_OLIVES", "SWEETENER", "LAXATIVE_IF_OVERUSED", "PHENYLALANINE", diff --git a/backend/.sqlx/query-6d2e83bf144d05cc0c35560e595517758a97fe3556b18b6cc7009a796e5ed4f6.json b/backend/.sqlx/query-6d2e83bf144d05cc0c35560e595517758a97fe3556b18b6cc7009a796e5ed4f6.json new file mode 100644 index 00000000..6fbb05f5 --- /dev/null +++ b/backend/.sqlx/query-6d2e83bf144d05cc0c35560e595517758a97fe3556b18b6cc7009a796e5ed4f6.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO image_rating (user_id, image_id, rating) \n VALUES ($1, $2, 1) \n ON CONFLICT (user_id, image_id) \n DO UPDATE SET rating = 1\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "6d2e83bf144d05cc0c35560e595517758a97fe3556b18b6cc7009a796e5ed4f6" +} diff --git a/backend/.sqlx/query-a0feec1f96f09eb6bf55a46425929363c0f8574ea181807ff488f12ba3285fe0.json b/backend/.sqlx/query-a0feec1f96f09eb6bf55a46425929363c0f8574ea181807ff488f12ba3285fe0.json index 42cc1726..5c1216b9 100644 --- a/backend/.sqlx/query-a0feec1f96f09eb6bf55a46425929363c0f8574ea181807ff488f12ba3285fe0.json +++ b/backend/.sqlx/query-a0feec1f96f09eb6bf55a46425929363c0f8574ea181807ff488f12ba3285fe0.json @@ -72,7 +72,7 @@ "PHOSPHATE", "SURFACE_WAXED", "SULPHUR", - "ARTIFICIALLY_BLACKENED_OLIVES", + "ARTIFICALLY_BLACKENED_OLIVES", "SWEETENER", "LAXATIVE_IF_OVERUSED", "PHENYLALANINE", diff --git a/backend/.sqlx/query-c60fd3cf348314ea8fb246589d9c4ee61bc76604e7047559dae46769dd61f6ff.json b/backend/.sqlx/query-c60fd3cf348314ea8fb246589d9c4ee61bc76604e7047559dae46769dd61f6ff.json deleted file mode 100644 index fa726ad2..00000000 --- a/backend/.sqlx/query-c60fd3cf348314ea8fb246589d9c4ee61bc76604e7047559dae46769dd61f6ff.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "INSERT INTO image_rating (user_id, image_id, rating) VALUES ($1, $2, -1)", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Uuid", - "Uuid" - ] - }, - "nullable": [] - }, - "hash": "c60fd3cf348314ea8fb246589d9c4ee61bc76604e7047559dae46769dd61f6ff" -} diff --git a/backend/.sqlx/query-e4d8e91bfa5b83ca72687bbe3d733daed48ece0eb44712939bcc76d1a28b2ca6.json b/backend/.sqlx/query-e4d8e91bfa5b83ca72687bbe3d733daed48ece0eb44712939bcc76d1a28b2ca6.json new file mode 100644 index 00000000..770baf33 --- /dev/null +++ b/backend/.sqlx/query-e4d8e91bfa5b83ca72687bbe3d733daed48ece0eb44712939bcc76d1a28b2ca6.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO image_rating (user_id, image_id, rating) \n VALUES ($1, $2, -1)\n ON CONFLICT (user_id, image_id) \n DO UPDATE SET rating = -1\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "e4d8e91bfa5b83ca72687bbe3d733daed48ece0eb44712939bcc76d1a28b2ca6" +} diff --git a/backend/.sqlx/query-edc31a0336db71587fd7bef4608c80e8baaf5fb4658de6b7ebc2bb2ae7fd83cb.json b/backend/.sqlx/query-edc31a0336db71587fd7bef4608c80e8baaf5fb4658de6b7ebc2bb2ae7fd83cb.json index 3d0b5d35..7d5f55a8 100644 --- a/backend/.sqlx/query-edc31a0336db71587fd7bef4608c80e8baaf5fb4658de6b7ebc2bb2ae7fd83cb.json +++ b/backend/.sqlx/query-edc31a0336db71587fd7bef4608c80e8baaf5fb4658de6b7ebc2bb2ae7fd83cb.json @@ -18,7 +18,7 @@ "PHOSPHATE", "SURFACE_WAXED", "SULPHUR", - "ARTIFICIALLY_BLACKENED_OLIVES", + "ARTIFICALLY_BLACKENED_OLIVES", "SWEETENER", "LAXATIVE_IF_OVERUSED", "PHENYLALANINE", diff --git a/backend/.sqlx/query-ffbbe6b50eae0544be68e79f3840db0f91c31357f6db23c625aa90153886f4c2.json b/backend/.sqlx/query-ffbbe6b50eae0544be68e79f3840db0f91c31357f6db23c625aa90153886f4c2.json deleted file mode 100644 index fbabb402..00000000 --- a/backend/.sqlx/query-ffbbe6b50eae0544be68e79f3840db0f91c31357f6db23c625aa90153886f4c2.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "INSERT INTO image_rating (user_id, image_id, rating) VALUES ($1, $2, 1)", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Uuid", - "Uuid" - ] - }, - "nullable": [] - }, - "hash": "ffbbe6b50eae0544be68e79f3840db0f91c31357f6db23c625aa90153886f4c2" -} diff --git a/backend/src/layer/data/database/command.rs b/backend/src/layer/data/database/command.rs index c7bf5ed8..177327ce 100644 --- a/backend/src/layer/data/database/command.rs +++ b/backend/src/layer/data/database/command.rs @@ -74,7 +74,12 @@ impl CommandDataAccess for PersistentCommandData { async fn add_upvote(&self, image_id: Uuid, user_id: Uuid) -> Result<()> { sqlx::query!( - "INSERT INTO image_rating (user_id, image_id, rating) VALUES ($1, $2, 1)", + " + INSERT INTO image_rating (user_id, image_id, rating) + VALUES ($1, $2, 1) + ON CONFLICT (user_id, image_id) + DO UPDATE SET rating = 1 + ", user_id, image_id ) @@ -85,7 +90,12 @@ impl CommandDataAccess for PersistentCommandData { async fn add_downvote(&self, image_id: Uuid, user_id: Uuid) -> Result<()> { sqlx::query!( - "INSERT INTO image_rating (user_id, image_id, rating) VALUES ($1, $2, -1)", + " + INSERT INTO image_rating (user_id, image_id, rating) + VALUES ($1, $2, -1) + ON CONFLICT (user_id, image_id) + DO UPDATE SET rating = -1 + ", user_id, image_id ) @@ -260,7 +270,7 @@ mod test { let upvotes = number_of_votes(&pool, 1).await; assert!(command.add_upvote(image_id, user_id).await.is_ok()); assert_eq!(number_of_votes(&pool, 1).await, upvotes + 1); - assert!(command.add_upvote(image_id, user_id).await.is_err()); + assert!(command.add_upvote(image_id, user_id).await.is_ok()); assert!(command.add_upvote(WRONG_UUID, user_id).await.is_err()); assert_eq!(number_of_votes(&pool, 1).await, upvotes + 1); } @@ -274,11 +284,42 @@ mod test { let downvotes = number_of_votes(&pool, -1).await; assert!(command.add_downvote(image_id, user_id).await.is_ok()); assert_eq!(number_of_votes(&pool, -1).await, downvotes + 1); - assert!(command.add_downvote(image_id, user_id).await.is_err()); + assert!(command.add_downvote(image_id, user_id).await.is_ok()); assert!(command.add_downvote(WRONG_UUID, user_id).await.is_err()); assert_eq!(number_of_votes(&pool, -1).await, downvotes + 1); } + #[sqlx::test(fixtures("meal", "image"))] + async fn test_override_votes(pool: PgPool) { + let command = PersistentCommandData { pool: pool.clone() }; + let image_id = Uuid::parse_str("76b904fe-d0f1-4122-8832-d0e21acab86d").unwrap(); + let user_id = Uuid::parse_str("00adb927-8cb9-4d80-ae01-d8f2e8f2d4cf").unwrap(); + + assert!(command.add_upvote(image_id, user_id).await.is_ok()); + assert!(command.add_downvote(image_id, user_id).await.is_ok()); + + let vote = sqlx::query_scalar!( + "SELECT rating FROM image_rating WHERE image_id = $1 AND user_id = $2", + image_id, + user_id, + ) + .fetch_one(&pool) + .await + .unwrap(); + assert_eq!(vote, -1); + + assert!(command.add_upvote(image_id, user_id).await.is_ok()); + let vote = sqlx::query_scalar!( + "SELECT rating FROM image_rating WHERE image_id = $1 AND user_id = $2", + image_id, + user_id, + ) + .fetch_one(&pool) + .await + .unwrap(); + assert_eq!(vote, 1); + } + #[sqlx::test(fixtures("meal", "image"))] async fn test_remove_upvote(pool: PgPool) { let command = PersistentCommandData { pool: pool.clone() }; From c1e560bf6a8b853032ff2c03ea65ba394add994f Mon Sep 17 00:00:00 2001 From: Jonatan Ziegler Date: Fri, 11 Aug 2023 16:30:13 +0200 Subject: [PATCH 33/45] sqlx --- ...0d096494183081ae2f474096b7c3f85e733978b532798168c91d811.json | 2 +- ...2a41a9ff120b64e11a200860a6369d3d472262583e991d201995a03.json | 2 +- ...6f09eb6bf55a46425929363c0f8574ea181807ff488f12ba3285fe0.json | 2 +- ...6db71587fd7bef4608c80e8baaf5fb4658de6b7ebc2bb2ae7fd83cb.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/.sqlx/query-4ccb2bf5b0d096494183081ae2f474096b7c3f85e733978b532798168c91d811.json b/backend/.sqlx/query-4ccb2bf5b0d096494183081ae2f474096b7c3f85e733978b532798168c91d811.json index 34e89ddf..ec7cd455 100644 --- a/backend/.sqlx/query-4ccb2bf5b0d096494183081ae2f474096b7c3f85e733978b532798168c91d811.json +++ b/backend/.sqlx/query-4ccb2bf5b0d096494183081ae2f474096b7c3f85e733978b532798168c91d811.json @@ -22,7 +22,7 @@ "PHOSPHATE", "SURFACE_WAXED", "SULPHUR", - "ARTIFICALLY_BLACKENED_OLIVES", + "ARTIFICIALLY_BLACKENED_OLIVES", "SWEETENER", "LAXATIVE_IF_OVERUSED", "PHENYLALANINE", diff --git a/backend/.sqlx/query-6248da40d2a41a9ff120b64e11a200860a6369d3d472262583e991d201995a03.json b/backend/.sqlx/query-6248da40d2a41a9ff120b64e11a200860a6369d3d472262583e991d201995a03.json index 7d4d225f..29ad6986 100644 --- a/backend/.sqlx/query-6248da40d2a41a9ff120b64e11a200860a6369d3d472262583e991d201995a03.json +++ b/backend/.sqlx/query-6248da40d2a41a9ff120b64e11a200860a6369d3d472262583e991d201995a03.json @@ -72,7 +72,7 @@ "PHOSPHATE", "SURFACE_WAXED", "SULPHUR", - "ARTIFICALLY_BLACKENED_OLIVES", + "ARTIFICIALLY_BLACKENED_OLIVES", "SWEETENER", "LAXATIVE_IF_OVERUSED", "PHENYLALANINE", diff --git a/backend/.sqlx/query-a0feec1f96f09eb6bf55a46425929363c0f8574ea181807ff488f12ba3285fe0.json b/backend/.sqlx/query-a0feec1f96f09eb6bf55a46425929363c0f8574ea181807ff488f12ba3285fe0.json index 5c1216b9..42cc1726 100644 --- a/backend/.sqlx/query-a0feec1f96f09eb6bf55a46425929363c0f8574ea181807ff488f12ba3285fe0.json +++ b/backend/.sqlx/query-a0feec1f96f09eb6bf55a46425929363c0f8574ea181807ff488f12ba3285fe0.json @@ -72,7 +72,7 @@ "PHOSPHATE", "SURFACE_WAXED", "SULPHUR", - "ARTIFICALLY_BLACKENED_OLIVES", + "ARTIFICIALLY_BLACKENED_OLIVES", "SWEETENER", "LAXATIVE_IF_OVERUSED", "PHENYLALANINE", diff --git a/backend/.sqlx/query-edc31a0336db71587fd7bef4608c80e8baaf5fb4658de6b7ebc2bb2ae7fd83cb.json b/backend/.sqlx/query-edc31a0336db71587fd7bef4608c80e8baaf5fb4658de6b7ebc2bb2ae7fd83cb.json index 7d5f55a8..3d0b5d35 100644 --- a/backend/.sqlx/query-edc31a0336db71587fd7bef4608c80e8baaf5fb4658de6b7ebc2bb2ae7fd83cb.json +++ b/backend/.sqlx/query-edc31a0336db71587fd7bef4608c80e8baaf5fb4658de6b7ebc2bb2ae7fd83cb.json @@ -18,7 +18,7 @@ "PHOSPHATE", "SURFACE_WAXED", "SULPHUR", - "ARTIFICALLY_BLACKENED_OLIVES", + "ARTIFICIALLY_BLACKENED_OLIVES", "SWEETENER", "LAXATIVE_IF_OVERUSED", "PHENYLALANINE", From fac4cb67ac7f46630ddc42eedac4b8b43bf7fe5d Mon Sep 17 00:00:00 2001 From: Jonatan Ziegler Date: Sat, 12 Aug 2023 16:23:04 +0200 Subject: [PATCH 34/45] docker compose --- backend/README.md | 2 +- backend/compose.yaml | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 backend/compose.yaml diff --git a/backend/README.md b/backend/README.md index 41d5dc08..ad6c593f 100644 --- a/backend/README.md +++ b/backend/README.md @@ -9,7 +9,7 @@ The docker container can be run using ``` docker run \ -p 80:80 - -e DATABASE_URL="postgres://:@:/" + -e DATABASE_URL=postgres://:@:/ -e SMTP_SERVER= \ -e SMTP_PORT= \ -e SMTP_USERNAME= \ diff --git a/backend/compose.yaml b/backend/compose.yaml new file mode 100644 index 00000000..d7368466 --- /dev/null +++ b/backend/compose.yaml @@ -0,0 +1,42 @@ +services: + mensa-app: + image: ghcr.io/kronos-et-al/mensa-app + command: --migrate + ports: + - 80:80 + environment: # please configure accordingly <------------------------------------------------------------ + - DATABASE_URL=postgres://postgres:secret_password@database/mensa_app # only change password if wanted + - SMTP_SERVER= + - SMTP_PORT= + - SMTP_USERNAME= + - SMTP_PASSWORD= + - ADMIN_EMAIL= + - FLICKR_API_KEY= + restart: unless-stopped + depends_on: + - database + database: + image: postgres + volumes: + - dbdata:/var/lib/postgresql/data + environment: + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=secret_password # change here and above <------------------------------------------ + - POSTGRES_DB=mensa_app + restart: unless-stopped + admin: + image: dpage/pgadmin4 + environment: # change <---------------------------------------------------------------------------------- + - PGADMIN_DEFAULT_EMAIL= + - PGADMIN_DEFAULT_PASSWORD= + ports: + - 8888:80 + volumes: + - pgadmin:/var/lib/pgadmin + restart: unless-stopped + depends_on: + - database + +volumes: + dbdata: + pgadmin: \ No newline at end of file From 9be41b9150b4a9d92cb1cdebb18b1903edecc11e Mon Sep 17 00:00:00 2001 From: Jonatan Ziegler Date: Sat, 12 Aug 2023 16:46:12 +0200 Subject: [PATCH 35/45] docker ci? --- .github/workflows/deploy_backend.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy_backend.yaml b/.github/workflows/deploy_backend.yaml index d2252bee..aeb1efc7 100644 --- a/.github/workflows/deploy_backend.yaml +++ b/.github/workflows/deploy_backend.yaml @@ -47,7 +47,7 @@ jobs: uses: docker/build-push-action@v4 with: context: . - file: ./Dockerfile + file: backend/Dockerfile push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From e3d1454eadfd2c291b12cc426bc1f04b7b56fa61 Mon Sep 17 00:00:00 2001 From: Jonatan Ziegler Date: Sat, 12 Aug 2023 16:48:46 +0200 Subject: [PATCH 36/45] docker ci? --- .github/workflows/deploy_backend.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy_backend.yaml b/.github/workflows/deploy_backend.yaml index aeb1efc7..39defbb1 100644 --- a/.github/workflows/deploy_backend.yaml +++ b/.github/workflows/deploy_backend.yaml @@ -46,8 +46,8 @@ jobs: - name: Build and push Docker image uses: docker/build-push-action@v4 with: - context: . - file: backend/Dockerfile + context: backend + file: Dockerfile push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From 578fb49497088bd1818afb9c41e50a14901e3ee4 Mon Sep 17 00:00:00 2001 From: Jonatan Ziegler Date: Sat, 12 Aug 2023 16:50:41 +0200 Subject: [PATCH 37/45] docker ci? --- .github/workflows/deploy_backend.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy_backend.yaml b/.github/workflows/deploy_backend.yaml index 39defbb1..a3a24a9f 100644 --- a/.github/workflows/deploy_backend.yaml +++ b/.github/workflows/deploy_backend.yaml @@ -46,7 +46,7 @@ jobs: - name: Build and push Docker image uses: docker/build-push-action@v4 with: - context: backend + context: "{{defaultContext}}:backend" file: Dockerfile push: true tags: ${{ steps.meta.outputs.tags }} From ea94d6bf78687e57cdfb4df7faacaac6691ce5dc Mon Sep 17 00:00:00 2001 From: Jonatan Ziegler Date: Sat, 12 Aug 2023 17:02:03 +0200 Subject: [PATCH 38/45] cleanup and correct image name --- .github/workflows/deploy_backend.yaml | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/.github/workflows/deploy_backend.yaml b/.github/workflows/deploy_backend.yaml index a3a24a9f..dd7a2889 100644 --- a/.github/workflows/deploy_backend.yaml +++ b/.github/workflows/deploy_backend.yaml @@ -1,18 +1,14 @@ -# name: Publish backend to GHCR -# Configures this workflow to run every time a change is pushed to the branch called `release`. on: workflow_dispatch: release: types: [published] -# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds. env: REGISTRY: ghcr.io - IMAGE_NAME: mensa-app -# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu. + IMAGE_NAME: kronos-et-al/mensa-app jobs: build-and-push-backend: runs-on: ubuntu-latest @@ -27,22 +23,17 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 - # Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here. - name: Log in to the Container registry - uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + uses: docker/login-action@v2 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - # This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels. - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 - with: + uses: docker/metadata-action@v4 + with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. - # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. - # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. - name: Build and push Docker image uses: docker/build-push-action@v4 with: From 61de5925b617836c7ed83bf3a8664b3814564f1c Mon Sep 17 00:00:00 2001 From: Jonatan Ziegler Date: Sat, 12 Aug 2023 17:20:14 +0200 Subject: [PATCH 39/45] docker ci on push --- .github/workflows/deploy_backend.yaml | 6 +++++- backend/compose.yaml | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy_backend.yaml b/.github/workflows/deploy_backend.yaml index dd7a2889..6ea39ae9 100644 --- a/.github/workflows/deploy_backend.yaml +++ b/.github/workflows/deploy_backend.yaml @@ -4,6 +4,10 @@ on: workflow_dispatch: release: types: [published] + push: + branches: + - 'main' + - 'backend' env: @@ -19,7 +23,7 @@ jobs: permissions: contents: read packages: write - # + steps: - name: Checkout repository uses: actions/checkout@v3 diff --git a/backend/compose.yaml b/backend/compose.yaml index d7368466..1e1dcd00 100644 --- a/backend/compose.yaml +++ b/backend/compose.yaml @@ -12,6 +12,7 @@ services: - SMTP_PASSWORD= - ADMIN_EMAIL= - FLICKR_API_KEY= + - TZ=Europe/Berlin restart: unless-stopped depends_on: - database @@ -23,12 +24,14 @@ services: - POSTGRES_USER=postgres - POSTGRES_PASSWORD=secret_password # change here and above <------------------------------------------ - POSTGRES_DB=mensa_app + - TZ=Europe/Berlin restart: unless-stopped admin: image: dpage/pgadmin4 environment: # change <---------------------------------------------------------------------------------- - PGADMIN_DEFAULT_EMAIL= - PGADMIN_DEFAULT_PASSWORD= + - TZ=Europe/Berlin ports: - 8888:80 volumes: From 5e4f2d6fd34d468bc007df8a81ee0ecc4167bfd7 Mon Sep 17 00:00:00 2001 From: Jonatan Ziegler Date: Sat, 12 Aug 2023 18:53:51 +0200 Subject: [PATCH 40/45] not always migrate --- backend/compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/compose.yaml b/backend/compose.yaml index 1e1dcd00..f69732bb 100644 --- a/backend/compose.yaml +++ b/backend/compose.yaml @@ -1,7 +1,7 @@ services: mensa-app: image: ghcr.io/kronos-et-al/mensa-app - command: --migrate + #command: --migrate # only run for the first time to create initial database structure ports: - 80:80 environment: # please configure accordingly <------------------------------------------------------------ From 623b77bf2f59eeef89fe9301668b0c3f530f1cd9 Mon Sep 17 00:00:00 2001 From: Jonatan Ziegler Date: Sat, 12 Aug 2023 18:58:31 +0200 Subject: [PATCH 41/45] build docker on every push --- .github/workflows/deploy_backend.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/deploy_backend.yaml b/.github/workflows/deploy_backend.yaml index 6ea39ae9..d6b72826 100644 --- a/.github/workflows/deploy_backend.yaml +++ b/.github/workflows/deploy_backend.yaml @@ -5,9 +5,7 @@ on: release: types: [published] push: - branches: - - 'main' - - 'backend' + paths: ["backend/**"] env: From 95198a237894d7fa8338ff42ae0c4c4ea59e1969 Mon Sep 17 00:00:00 2001 From: Jonatan Ziegler Date: Sat, 12 Aug 2023 19:03:55 +0200 Subject: [PATCH 42/45] docker image size badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ba97665f..c633a333 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # 🥘 MensaApp -[![Build-Rust](https://github.com/kronos-et-al/MensaApp/actions/workflows/rust.yml/badge.svg)](https://github.com/kronos-et-al/MensaApp/actions/workflows/rust.yml) [![codecov](https://codecov.io/gh/kronos-et-al/MensaApp/branch/main/graph/badge.svg?token=2CZXSPAP48)](https://codecov.io/gh/kronos-et-al/MensaApp) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/kronos-et-al/MensaApp/blob/main/LICENSE) [![version](https://shields.io/github/v/release/kronos-et-al/MensaApp)](https://github.com/kronos-et-al/MensaApp/releases) ![GitHub Repo stars](https://img.shields.io/github/stars/kronos-et-al/MensaApp) +[![Build-Rust](https://github.com/kronos-et-al/MensaApp/actions/workflows/rust.yml/badge.svg)](https://github.com/kronos-et-al/MensaApp/actions/workflows/rust.yml) [![Docker](https://ghcr-badge.egpl.dev/kronos-et-al/mensa-app/size?color=%2344cc11&tag=latest&label=docker+image+size&trim=)](https://github.com/kronos-et-al/MensaApp/pkgs/container/mensa-app) [![codecov](https://codecov.io/gh/kronos-et-al/MensaApp/branch/main/graph/badge.svg?token=2CZXSPAP48)](https://codecov.io/gh/kronos-et-al/MensaApp) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/kronos-et-al/MensaApp/blob/main/LICENSE) [![version](https://shields.io/github/v/release/kronos-et-al/MensaApp)](https://github.com/kronos-et-al/MensaApp/releases) ![GitHub Repo stars](https://img.shields.io/github/stars/kronos-et-al/MensaApp) **Application for communication and collective exchange of From 2c39c33e924bd377c619c1cbef3e3982dde35050 Mon Sep 17 00:00:00 2001 From: Jonatan Ziegler Date: Sun, 13 Aug 2023 13:12:25 +0200 Subject: [PATCH 43/45] no native tls and dns --- backend/Cargo.lock | 291 ++++++++++++++++++++++++++++++++++++++++++++- backend/Cargo.toml | 6 +- 2 files changed, 289 insertions(+), 8 deletions(-) diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 8979ac7a..f4eb1e82 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -666,6 +666,18 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "enum-as-inner" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9720bba047d567ffc8a3cba48bf19126600e249ab7f128e9233e6376976a116" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -1138,13 +1150,27 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2", + "socket2 0.4.9", "tokio", "tower-service", "tracing", "want", ] +[[package]] +name = "hyper-rustls" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" +dependencies = [ + "futures-util", + "http", + "hyper", + "rustls", + "tokio", + "tokio-rustls", +] + [[package]] name = "hyper-tls" version = "0.5.0" @@ -1187,6 +1213,17 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +[[package]] +name = "idna" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "idna" version = "0.3.0" @@ -1237,6 +1274,18 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "ipconfig" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" +dependencies = [ + "socket2 0.5.3", + "widestring", + "windows-sys", + "winreg 0.50.0", +] + [[package]] name = "ipnet" version = "2.8.0" @@ -1306,8 +1355,11 @@ dependencies = [ "nom", "once_cell", "quoted_printable", - "socket2", + "rustls", + "rustls-pemfile", + "socket2 0.4.9", "tokio", + "webpki-roots 0.23.1", ] [[package]] @@ -1333,6 +1385,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + [[package]] name = "linux-raw-sys" version = "0.4.3" @@ -1355,6 +1413,15 @@ version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" +[[package]] +name = "lru-cache" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" +dependencies = [ + "linked-hash-map", +] + [[package]] name = "mac" version = "0.1.1" @@ -1390,6 +1457,12 @@ dependencies = [ "regex-automata 0.1.10", ] +[[package]] +name = "matches" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" + [[package]] name = "matchit" version = "0.7.1" @@ -2053,6 +2126,7 @@ dependencies = [ "http", "http-body", "hyper", + "hyper-rustls", "hyper-tls", "ipnet", "js-sys", @@ -2062,17 +2136,47 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", + "rustls", + "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", "tokio", "tokio-native-tls", + "tokio-rustls", "tower-service", + "trust-dns-resolver", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "winreg", + "webpki-roots 0.22.6", + "winreg 0.10.1", +] + +[[package]] +name = "resolv-conf" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00" +dependencies = [ + "hostname", + "quick-error", +] + +[[package]] +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin 0.5.2", + "untrusted", + "web-sys", + "winapi", ] [[package]] @@ -2116,6 +2220,47 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "rustls" +version = "0.21.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79ea77c539259495ce8ca47f53e66ae0330a8819f67e23ac96ca02f50e7b7d36" +dependencies = [ + "log", + "ring", + "rustls-webpki 0.101.2", + "sct", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" +dependencies = [ + "base64 0.21.2", +] + +[[package]] +name = "rustls-webpki" +version = "0.100.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6207cd5ed3d8dca7816f8f3725513a34609c0c765bf652b8c3cb4cfd87db46b" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "513722fd73ad80a71f72b61009ea1b584bcfa1483ca93949c8f290298837fa59" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "rustversion" version = "1.0.14" @@ -2172,6 +2317,16 @@ dependencies = [ "tendril", ] +[[package]] +name = "sct" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "security-framework" version = "2.9.2" @@ -2382,6 +2537,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "socket2" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" +dependencies = [ + "libc", + "windows-sys", +] + [[package]] name = "spin" version = "0.5.2" @@ -2457,10 +2622,11 @@ dependencies = [ "indexmap 2.0.0", "log", "memchr", - "native-tls", "once_cell", "paste", "percent-encoding", + "rustls", + "rustls-pemfile", "serde", "serde_json", "sha2", @@ -2472,6 +2638,7 @@ dependencies = [ "tracing", "url", "uuid", + "webpki-roots 0.24.0", ] [[package]] @@ -2814,7 +2981,7 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2", + "socket2 0.4.9", "tokio-macros", "windows-sys", ] @@ -2855,6 +3022,16 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +dependencies = [ + "rustls", + "tokio", +] + [[package]] name = "tokio-stream" version = "0.1.14" @@ -3036,6 +3213,51 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "trust-dns-proto" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f7f83d1e4a0e4358ac54c5c3681e5d7da5efc5a7a632c90bb6d6669ddd9bc26" +dependencies = [ + "async-trait", + "cfg-if", + "data-encoding", + "enum-as-inner", + "futures-channel", + "futures-io", + "futures-util", + "idna 0.2.3", + "ipnet", + "lazy_static", + "rand", + "smallvec", + "thiserror", + "tinyvec", + "tokio", + "tracing", + "url", +] + +[[package]] +name = "trust-dns-resolver" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aff21aa4dcefb0a1afbfac26deb0adc93888c7d295fb63ab273ef276ba2b7cfe" +dependencies = [ + "cfg-if", + "futures-util", + "ipconfig", + "lazy_static", + "lru-cache", + "parking_lot", + "resolv-conf", + "smallvec", + "thiserror", + "tokio", + "tracing", + "trust-dns-proto", +] + [[package]] name = "try-lock" version = "0.2.4" @@ -3112,6 +3334,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + [[package]] name = "url" version = "2.4.0" @@ -3263,12 +3491,55 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "webpki-roots" +version = "0.22.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" +dependencies = [ + "webpki", +] + +[[package]] +name = "webpki-roots" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" +dependencies = [ + "rustls-webpki 0.100.1", +] + +[[package]] +name = "webpki-roots" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b291546d5d9d1eab74f069c77749f2cb8504a12caa20f0f2de93ddbf6f411888" +dependencies = [ + "rustls-webpki 0.101.2", +] + [[package]] name = "whoami" version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22fc3756b8a9133049b26c7f61ab35416c130e8c09b660f5b3958b446f52cc50" +[[package]] +name = "widestring" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8" + [[package]] name = "winapi" version = "0.3.9" @@ -3384,6 +3655,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "winreg" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +dependencies = [ + "cfg-if", + "windows-sys", +] + [[package]] name = "zeroize" version = "1.6.0" diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 19987b90..8ccddaf6 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -24,14 +24,14 @@ base64 = "0.21.2" sha2 = "0.10.7" heck = "0.4.1" dotenvy = "0.15.7" -reqwest = { version = "0.11", features = ["json"] } +reqwest = { version = "0.11", features = ["json", "rustls-tls", "trust-dns"] } serde = "1.0.171" scraper = "0.17.1" regex = "1.9.1" futures = "0.3.28" tokio-cron-scheduler = "0.9.4" -sqlx = { version = "0.7", features = [ "runtime-tokio", "tls-native-tls", "postgres", "uuid", "chrono", "macros"] } -lettre = "0.10.4" +sqlx = { version = "0.7", features = [ "runtime-tokio", "tls-rustls", "postgres", "uuid", "chrono", "macros"] } +lettre = {version = "0.10.4", features = ["rustls-tls"]} string_template = "0.2.1" lazy_static = "1.4.0" colored = "2.0.4" From b69299ae8b50189ad174dde7a6223eb3384c358b Mon Sep 17 00:00:00 2001 From: Jonatan Ziegler Date: Sun, 13 Aug 2023 13:23:20 +0200 Subject: [PATCH 44/45] Revert "no native tls and dns" This reverts commit 2c39c33e924bd377c619c1cbef3e3982dde35050. --- backend/Cargo.lock | 291 +-------------------------------------------- backend/Cargo.toml | 6 +- 2 files changed, 8 insertions(+), 289 deletions(-) diff --git a/backend/Cargo.lock b/backend/Cargo.lock index f4eb1e82..8979ac7a 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -666,18 +666,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "enum-as-inner" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9720bba047d567ffc8a3cba48bf19126600e249ab7f128e9233e6376976a116" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "equivalent" version = "1.0.1" @@ -1150,27 +1138,13 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.9", + "socket2", "tokio", "tower-service", "tracing", "want", ] -[[package]] -name = "hyper-rustls" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" -dependencies = [ - "futures-util", - "http", - "hyper", - "rustls", - "tokio", - "tokio-rustls", -] - [[package]] name = "hyper-tls" version = "0.5.0" @@ -1213,17 +1187,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" -[[package]] -name = "idna" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" -dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", -] - [[package]] name = "idna" version = "0.3.0" @@ -1274,18 +1237,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "ipconfig" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" -dependencies = [ - "socket2 0.5.3", - "widestring", - "windows-sys", - "winreg 0.50.0", -] - [[package]] name = "ipnet" version = "2.8.0" @@ -1355,11 +1306,8 @@ dependencies = [ "nom", "once_cell", "quoted_printable", - "rustls", - "rustls-pemfile", - "socket2 0.4.9", + "socket2", "tokio", - "webpki-roots 0.23.1", ] [[package]] @@ -1385,12 +1333,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "linked-hash-map" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" - [[package]] name = "linux-raw-sys" version = "0.4.3" @@ -1413,15 +1355,6 @@ version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" -[[package]] -name = "lru-cache" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" -dependencies = [ - "linked-hash-map", -] - [[package]] name = "mac" version = "0.1.1" @@ -1457,12 +1390,6 @@ dependencies = [ "regex-automata 0.1.10", ] -[[package]] -name = "matches" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" - [[package]] name = "matchit" version = "0.7.1" @@ -2126,7 +2053,6 @@ dependencies = [ "http", "http-body", "hyper", - "hyper-rustls", "hyper-tls", "ipnet", "js-sys", @@ -2136,47 +2062,17 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls", - "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", "tokio", "tokio-native-tls", - "tokio-rustls", "tower-service", - "trust-dns-resolver", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "webpki-roots 0.22.6", - "winreg 0.10.1", -] - -[[package]] -name = "resolv-conf" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00" -dependencies = [ - "hostname", - "quick-error", -] - -[[package]] -name = "ring" -version = "0.16.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" -dependencies = [ - "cc", - "libc", - "once_cell", - "spin 0.5.2", - "untrusted", - "web-sys", - "winapi", + "winreg", ] [[package]] @@ -2220,47 +2116,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "rustls" -version = "0.21.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79ea77c539259495ce8ca47f53e66ae0330a8819f67e23ac96ca02f50e7b7d36" -dependencies = [ - "log", - "ring", - "rustls-webpki 0.101.2", - "sct", -] - -[[package]] -name = "rustls-pemfile" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" -dependencies = [ - "base64 0.21.2", -] - -[[package]] -name = "rustls-webpki" -version = "0.100.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6207cd5ed3d8dca7816f8f3725513a34609c0c765bf652b8c3cb4cfd87db46b" -dependencies = [ - "ring", - "untrusted", -] - -[[package]] -name = "rustls-webpki" -version = "0.101.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "513722fd73ad80a71f72b61009ea1b584bcfa1483ca93949c8f290298837fa59" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "rustversion" version = "1.0.14" @@ -2317,16 +2172,6 @@ dependencies = [ "tendril", ] -[[package]] -name = "sct" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "security-framework" version = "2.9.2" @@ -2537,16 +2382,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "socket2" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" -dependencies = [ - "libc", - "windows-sys", -] - [[package]] name = "spin" version = "0.5.2" @@ -2622,11 +2457,10 @@ dependencies = [ "indexmap 2.0.0", "log", "memchr", + "native-tls", "once_cell", "paste", "percent-encoding", - "rustls", - "rustls-pemfile", "serde", "serde_json", "sha2", @@ -2638,7 +2472,6 @@ dependencies = [ "tracing", "url", "uuid", - "webpki-roots 0.24.0", ] [[package]] @@ -2981,7 +2814,7 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.4.9", + "socket2", "tokio-macros", "windows-sys", ] @@ -3022,16 +2855,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "tokio-rustls" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" -dependencies = [ - "rustls", - "tokio", -] - [[package]] name = "tokio-stream" version = "0.1.14" @@ -3213,51 +3036,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "trust-dns-proto" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f7f83d1e4a0e4358ac54c5c3681e5d7da5efc5a7a632c90bb6d6669ddd9bc26" -dependencies = [ - "async-trait", - "cfg-if", - "data-encoding", - "enum-as-inner", - "futures-channel", - "futures-io", - "futures-util", - "idna 0.2.3", - "ipnet", - "lazy_static", - "rand", - "smallvec", - "thiserror", - "tinyvec", - "tokio", - "tracing", - "url", -] - -[[package]] -name = "trust-dns-resolver" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aff21aa4dcefb0a1afbfac26deb0adc93888c7d295fb63ab273ef276ba2b7cfe" -dependencies = [ - "cfg-if", - "futures-util", - "ipconfig", - "lazy_static", - "lru-cache", - "parking_lot", - "resolv-conf", - "smallvec", - "thiserror", - "tokio", - "tracing", - "trust-dns-proto", -] - [[package]] name = "try-lock" version = "0.2.4" @@ -3334,12 +3112,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" -[[package]] -name = "untrusted" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" - [[package]] name = "url" version = "2.4.0" @@ -3491,55 +3263,12 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webpki" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" -dependencies = [ - "ring", - "untrusted", -] - -[[package]] -name = "webpki-roots" -version = "0.22.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" -dependencies = [ - "webpki", -] - -[[package]] -name = "webpki-roots" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" -dependencies = [ - "rustls-webpki 0.100.1", -] - -[[package]] -name = "webpki-roots" -version = "0.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b291546d5d9d1eab74f069c77749f2cb8504a12caa20f0f2de93ddbf6f411888" -dependencies = [ - "rustls-webpki 0.101.2", -] - [[package]] name = "whoami" version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22fc3756b8a9133049b26c7f61ab35416c130e8c09b660f5b3958b446f52cc50" -[[package]] -name = "widestring" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8" - [[package]] name = "winapi" version = "0.3.9" @@ -3655,16 +3384,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "winreg" -version = "0.50.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" -dependencies = [ - "cfg-if", - "windows-sys", -] - [[package]] name = "zeroize" version = "1.6.0" diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 8ccddaf6..19987b90 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -24,14 +24,14 @@ base64 = "0.21.2" sha2 = "0.10.7" heck = "0.4.1" dotenvy = "0.15.7" -reqwest = { version = "0.11", features = ["json", "rustls-tls", "trust-dns"] } +reqwest = { version = "0.11", features = ["json"] } serde = "1.0.171" scraper = "0.17.1" regex = "1.9.1" futures = "0.3.28" tokio-cron-scheduler = "0.9.4" -sqlx = { version = "0.7", features = [ "runtime-tokio", "tls-rustls", "postgres", "uuid", "chrono", "macros"] } -lettre = {version = "0.10.4", features = ["rustls-tls"]} +sqlx = { version = "0.7", features = [ "runtime-tokio", "tls-native-tls", "postgres", "uuid", "chrono", "macros"] } +lettre = "0.10.4" string_template = "0.2.1" lazy_static = "1.4.0" colored = "2.0.4" From 566385a67851a68f8322fe2512e328d10c15cbb4 Mon Sep 17 00:00:00 2001 From: Jonatan Ziegler Date: Sun, 13 Aug 2023 13:25:07 +0200 Subject: [PATCH 45/45] curl dep for docker --- backend/Dockerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 6ef9248a..3b412565 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -4,8 +4,12 @@ COPY . . ENV SQLX_OFFLINE=true RUN cargo install --path . --profile release +# actual running image FROM debian:bullseye-slim -# RUN apt-get update && apt-get install -y extra-runtime-dependencies && rm -rf /var/lib/apt/lists/* + +# install http dependencies (through curl) +RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* + COPY --from=builder /usr/local/cargo/bin/mensa-app-backend /usr/local/bin/mensa-app-backend EXPOSE 80/tcp