mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2025-04-01 06:03:28 +03:00
commit
3d9056e968
19 changed files with 43 additions and 43 deletions
|
@ -11,7 +11,7 @@ cookie_secret = "Zae0OOxf^bOJ#zN^&k7VozgW&QAx%n02TQFXpRMG4cCU0xMzgu3dna@tQ9dvc&T
|
||||||
# The port at which you want authentication to listen to
|
# The port at which you want authentication to listen to
|
||||||
# takes a number, choose from 1000-10000 if you dont know what you are doing
|
# takes a number, choose from 1000-10000 if you dont know what you are doing
|
||||||
port = 7000
|
port = 7000
|
||||||
#IP address. Enter 0.0.0.0 to listen on all availale addresses
|
#IP address. Enter 0.0.0.0 to listen on all available addresses
|
||||||
ip= "0.0.0.0"
|
ip= "0.0.0.0"
|
||||||
# enter your hostname, eg: example.com
|
# enter your hostname, eg: example.com
|
||||||
domain = "localhost"
|
domain = "localhost"
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
//!
|
//!
|
||||||
//! ## Organisation
|
//! ## Organisation
|
||||||
//!
|
//!
|
||||||
//! Database functionallity is divided accross various modules:
|
//! Database functionality is divided across various modules:
|
||||||
//!
|
//!
|
||||||
//! - [errors](crate::auth): error data structures used in this crate
|
//! - [errors](crate::auth): error data structures used in this crate
|
||||||
//! - [ops](crate::ops): meta operations like connection pool creation, migrations and getting
|
//! - [ops](crate::ops): meta operations like connection pool creation, migrations and getting
|
||||||
|
@ -242,13 +242,13 @@ pub trait MCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase {
|
||||||
/// record PoWConfig confirms
|
/// record PoWConfig confirms
|
||||||
async fn record_confirm(&self, key: &str) -> DBResult<()>;
|
async fn record_confirm(&self, key: &str) -> DBResult<()>;
|
||||||
|
|
||||||
/// featch PoWConfig fetches
|
/// fetch PoWConfig fetches
|
||||||
async fn fetch_config_fetched(&self, user: &str, key: &str) -> DBResult<Vec<i64>>;
|
async fn fetch_config_fetched(&self, user: &str, key: &str) -> DBResult<Vec<i64>>;
|
||||||
|
|
||||||
/// featch PoWConfig solves
|
/// fetch PoWConfig solves
|
||||||
async fn fetch_solve(&self, user: &str, key: &str) -> DBResult<Vec<i64>>;
|
async fn fetch_solve(&self, user: &str, key: &str) -> DBResult<Vec<i64>>;
|
||||||
|
|
||||||
/// featch PoWConfig confirms
|
/// fetch PoWConfig confirms
|
||||||
async fn fetch_confirm(&self, user: &str, key: &str) -> DBResult<Vec<i64>>;
|
async fn fetch_confirm(&self, user: &str, key: &str) -> DBResult<Vec<i64>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,7 +287,7 @@ pub struct AddNotification<'a> {
|
||||||
pub from: &'a str,
|
pub from: &'a str,
|
||||||
/// heading of the notification
|
/// heading of the notification
|
||||||
pub heading: &'a str,
|
pub heading: &'a str,
|
||||||
/// mesage of the notification
|
/// message of the notification
|
||||||
pub message: &'a str,
|
pub message: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,12 +298,12 @@ pub struct TrafficPattern {
|
||||||
pub avg_traffic: u32,
|
pub avg_traffic: u32,
|
||||||
/// the peak traffic that the user's website can handle
|
/// the peak traffic that the user's website can handle
|
||||||
pub peak_sustainable_traffic: u32,
|
pub peak_sustainable_traffic: u32,
|
||||||
/// trafic that bought the user's website down; optional
|
/// traffic that bought the user's website down; optional
|
||||||
pub broke_my_site_traffic: Option<u32>,
|
pub broke_my_site_traffic: Option<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)]
|
||||||
/// data requried to create new captcha
|
/// data required to create new captcha
|
||||||
pub struct CreateCaptcha<'a> {
|
pub struct CreateCaptcha<'a> {
|
||||||
/// cool down duration
|
/// cool down duration
|
||||||
pub duration: i32,
|
pub duration: i32,
|
||||||
|
|
|
@ -30,7 +30,7 @@ pub trait GetConnection {
|
||||||
async fn get_conn(&self) -> DBResult<Self::Conn>;
|
async fn get_conn(&self) -> DBResult<Self::Conn>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create databse connection
|
/// Create database connection
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait Connect {
|
pub trait Connect {
|
||||||
/// database specific pool-type
|
/// database specific pool-type
|
||||||
|
|
|
@ -33,7 +33,7 @@ pub async fn database_works<'a, T: MCDatabase>(
|
||||||
db.delete_user(p.username).await.unwrap();
|
db.delete_user(p.username).await.unwrap();
|
||||||
assert!(
|
assert!(
|
||||||
!db.username_exists(p.username).await.unwrap(),
|
!db.username_exists(p.username).await.unwrap(),
|
||||||
"user is deleted so username shouldn't exsit"
|
"user is deleted so username shouldn't exist"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,11 +89,11 @@ pub async fn database_works<'a, T: MCDatabase>(
|
||||||
// testing email exists
|
// testing email exists
|
||||||
assert!(
|
assert!(
|
||||||
db.email_exists(p.email.as_ref().unwrap()).await.unwrap(),
|
db.email_exists(p.email.as_ref().unwrap()).await.unwrap(),
|
||||||
"user is registered so email should exsit"
|
"user is registered so email should exist"
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
db.username_exists(p.username).await.unwrap(),
|
db.username_exists(p.username).await.unwrap(),
|
||||||
"user is registered so username should exsit"
|
"user is registered so username should exist"
|
||||||
);
|
);
|
||||||
|
|
||||||
// update password test. setting password = username
|
// update password test. setting password = username
|
||||||
|
@ -124,7 +124,7 @@ pub async fn database_works<'a, T: MCDatabase>(
|
||||||
db.delete_user(p.email.as_ref().unwrap()).await.unwrap();
|
db.delete_user(p.email.as_ref().unwrap()).await.unwrap();
|
||||||
assert!(
|
assert!(
|
||||||
!db.username_exists(p.email.as_ref().unwrap()).await.unwrap(),
|
!db.username_exists(p.email.as_ref().unwrap()).await.unwrap(),
|
||||||
"user is deleted so username shouldn't exsit"
|
"user is deleted so username shouldn't exist"
|
||||||
);
|
);
|
||||||
|
|
||||||
// register with email = None
|
// register with email = None
|
||||||
|
@ -133,11 +133,11 @@ pub async fn database_works<'a, T: MCDatabase>(
|
||||||
db.register(&p2).await.unwrap();
|
db.register(&p2).await.unwrap();
|
||||||
assert!(
|
assert!(
|
||||||
db.username_exists(p2.username).await.unwrap(),
|
db.username_exists(p2.username).await.unwrap(),
|
||||||
"user is registered so username should exsit"
|
"user is registered so username should exist"
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
!db.email_exists(p.email.as_ref().unwrap()).await.unwrap(),
|
!db.email_exists(p.email.as_ref().unwrap()).await.unwrap(),
|
||||||
"user registration with email is deleted; so email shouldn't exsit"
|
"user registration with email is deleted; so email shouldn't exist"
|
||||||
);
|
);
|
||||||
|
|
||||||
// testing get_email = None
|
// testing get_email = None
|
||||||
|
@ -155,7 +155,7 @@ pub async fn database_works<'a, T: MCDatabase>(
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
db.email_exists(p.email.as_ref().unwrap()).await.unwrap(),
|
db.email_exists(p.email.as_ref().unwrap()).await.unwrap(),
|
||||||
"user was with empty email but email is set; so email should exsit"
|
"user was with empty email but email is set; so email should exist"
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -35,7 +35,7 @@ pub struct Database {
|
||||||
/// Use an existing database pool
|
/// Use an existing database pool
|
||||||
pub struct Conn(pub MySqlPool);
|
pub struct Conn(pub MySqlPool);
|
||||||
|
|
||||||
/// Connect to databse
|
/// Connect to database
|
||||||
pub enum ConnectionOptions {
|
pub enum ConnectionOptions {
|
||||||
/// fresh connection
|
/// fresh connection
|
||||||
Fresh(Fresh),
|
Fresh(Fresh),
|
||||||
|
@ -824,7 +824,7 @@ impl MCDatabase for Database {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// featch PoWConfig fetches
|
/// fetch PoWConfig fetches
|
||||||
async fn fetch_config_fetched(&self, user: &str, key: &str) -> DBResult<Vec<i64>> {
|
async fn fetch_config_fetched(&self, user: &str, key: &str) -> DBResult<Vec<i64>> {
|
||||||
let records = sqlx::query_as!(
|
let records = sqlx::query_as!(
|
||||||
Date,
|
Date,
|
||||||
|
@ -850,7 +850,7 @@ impl MCDatabase for Database {
|
||||||
Ok(Date::dates_to_unix(records))
|
Ok(Date::dates_to_unix(records))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// featch PoWConfig solves
|
/// fetch PoWConfig solves
|
||||||
async fn fetch_solve(&self, user: &str, key: &str) -> DBResult<Vec<i64>> {
|
async fn fetch_solve(&self, user: &str, key: &str) -> DBResult<Vec<i64>> {
|
||||||
let records = sqlx::query_as!(
|
let records = sqlx::query_as!(
|
||||||
Date,
|
Date,
|
||||||
|
@ -874,7 +874,7 @@ impl MCDatabase for Database {
|
||||||
Ok(Date::dates_to_unix(records))
|
Ok(Date::dates_to_unix(records))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// featch PoWConfig confirms
|
/// fetch PoWConfig confirms
|
||||||
async fn fetch_confirm(&self, user: &str, key: &str) -> DBResult<Vec<i64>> {
|
async fn fetch_confirm(&self, user: &str, key: &str) -> DBResult<Vec<i64>> {
|
||||||
let records = sqlx::query_as!(
|
let records = sqlx::query_as!(
|
||||||
Date,
|
Date,
|
||||||
|
|
|
@ -35,7 +35,7 @@ pub struct Database {
|
||||||
/// Use an existing database pool
|
/// Use an existing database pool
|
||||||
pub struct Conn(pub PgPool);
|
pub struct Conn(pub PgPool);
|
||||||
|
|
||||||
/// Connect to databse
|
/// Connect to database
|
||||||
pub enum ConnectionOptions {
|
pub enum ConnectionOptions {
|
||||||
/// fresh connection
|
/// fresh connection
|
||||||
Fresh(Fresh),
|
Fresh(Fresh),
|
||||||
|
@ -830,7 +830,7 @@ impl MCDatabase for Database {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// featch PoWConfig fetches
|
/// fetch PoWConfig fetches
|
||||||
async fn fetch_config_fetched(&self, user: &str, key: &str) -> DBResult<Vec<i64>> {
|
async fn fetch_config_fetched(&self, user: &str, key: &str) -> DBResult<Vec<i64>> {
|
||||||
let records = sqlx::query_as!(
|
let records = sqlx::query_as!(
|
||||||
Date,
|
Date,
|
||||||
|
@ -856,7 +856,7 @@ impl MCDatabase for Database {
|
||||||
Ok(Date::dates_to_unix(records))
|
Ok(Date::dates_to_unix(records))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// featch PoWConfig solves
|
/// fetch PoWConfig solves
|
||||||
async fn fetch_solve(&self, user: &str, key: &str) -> DBResult<Vec<i64>> {
|
async fn fetch_solve(&self, user: &str, key: &str) -> DBResult<Vec<i64>> {
|
||||||
let records = sqlx::query_as!(
|
let records = sqlx::query_as!(
|
||||||
Date,
|
Date,
|
||||||
|
@ -880,7 +880,7 @@ impl MCDatabase for Database {
|
||||||
Ok(Date::dates_to_unix(records))
|
Ok(Date::dates_to_unix(records))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// featch PoWConfig confirms
|
/// fetch PoWConfig confirms
|
||||||
async fn fetch_confirm(&self, user: &str, key: &str) -> DBResult<Vec<i64>> {
|
async fn fetch_confirm(&self, user: &str, key: &str) -> DBResult<Vec<i64>> {
|
||||||
let records = sqlx::query_as!(
|
let records = sqlx::query_as!(
|
||||||
Date,
|
Date,
|
||||||
|
|
|
@ -51,7 +51,7 @@ pub async fn uname_email_exists_works(data: ArcData) {
|
||||||
let cookies = get_cookie!(signin_resp);
|
let cookies = get_cookie!(signin_resp);
|
||||||
let app = get_app!(data).await;
|
let app = get_app!(data).await;
|
||||||
|
|
||||||
// chech if get user secret works
|
// check if get user secret works
|
||||||
let resp = test::call_service(
|
let resp = test::call_service(
|
||||||
&app,
|
&app,
|
||||||
test::TestRequest::get()
|
test::TestRequest::get()
|
||||||
|
@ -62,7 +62,7 @@ pub async fn uname_email_exists_works(data: ArcData) {
|
||||||
.await;
|
.await;
|
||||||
assert_eq!(resp.status(), StatusCode::OK);
|
assert_eq!(resp.status(), StatusCode::OK);
|
||||||
|
|
||||||
// chech if get user secret works
|
// check if get user secret works
|
||||||
let resp = test::call_service(
|
let resp = test::call_service(
|
||||||
&app,
|
&app,
|
||||||
test::TestRequest::post()
|
test::TestRequest::post()
|
||||||
|
@ -178,7 +178,7 @@ pub async fn email_udpate_password_validation_del_userworks(data: ArcData) {
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
// wrong password while deleteing account
|
// wrong password while deleting account
|
||||||
let mut payload = Password {
|
let mut payload = Password {
|
||||||
password: NAME.into(),
|
password: NAME.into(),
|
||||||
};
|
};
|
||||||
|
|
|
@ -86,7 +86,7 @@ pub mod runners {
|
||||||
pub password: String,
|
pub password: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// returns Ok(()) when everything checks out and the user is authenticated. Erros otherwise
|
/// returns Ok(()) when everything checks out and the user is authenticated. Errors otherwise
|
||||||
pub async fn login_runner(payload: Login, data: &AppData) -> ServiceResult<String> {
|
pub async fn login_runner(payload: Login, data: &AppData) -> ServiceResult<String> {
|
||||||
use argon2_creds::Config;
|
use argon2_creds::Config;
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ pub struct TrafficPatternRequest {
|
||||||
pub avg_traffic: u32,
|
pub avg_traffic: u32,
|
||||||
/// the peak traffic that the user's website can handle
|
/// the peak traffic that the user's website can handle
|
||||||
pub peak_sustainable_traffic: u32,
|
pub peak_sustainable_traffic: u32,
|
||||||
/// trafic that bought the user's website down; optional
|
/// traffic that bought the user's website down; optional
|
||||||
pub broke_my_site_traffic: Option<u32>,
|
pub broke_my_site_traffic: Option<u32>,
|
||||||
/// Captcha description
|
/// Captcha description
|
||||||
pub description: String,
|
pub description: String,
|
||||||
|
|
|
@ -191,7 +191,7 @@ mod tests {
|
||||||
let updated_token: MCaptchaDetails =
|
let updated_token: MCaptchaDetails =
|
||||||
test::read_body_json(update_token_resp).await;
|
test::read_body_json(update_token_resp).await;
|
||||||
|
|
||||||
// get levels with udpated key
|
// get levels with updated key
|
||||||
let get_token_resp = test::call_service(
|
let get_token_resp = test::call_service(
|
||||||
&app,
|
&app,
|
||||||
post_request!(&updated_token, ROUTES.captcha.get)
|
post_request!(&updated_token, ROUTES.captcha.get)
|
||||||
|
@ -199,7 +199,7 @@ mod tests {
|
||||||
.to_request(),
|
.to_request(),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
// if updated key doesn't exist in databse, a non 200 result will bereturned
|
// if updated key doesn't exist in database, a non 200 result will bereturned
|
||||||
assert_eq!(get_token_resp.status(), StatusCode::OK);
|
assert_eq!(get_token_resp.status(), StatusCode::OK);
|
||||||
|
|
||||||
// get stats
|
// get stats
|
||||||
|
@ -211,7 +211,7 @@ mod tests {
|
||||||
.to_request(),
|
.to_request(),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
// if updated key doesn't exist in databse, a non 200 result will bereturned
|
// if updated key doesn't exist in database, a non 200 result will bereturned
|
||||||
assert_eq!(get_statis_resp.status(), StatusCode::OK);
|
assert_eq!(get_statis_resp.status(), StatusCode::OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ pub mod routes {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// emmits build details of the bninary
|
/// emits build details of the bninary
|
||||||
#[my_codegen::get(path = "crate::V1_API_ROUTES.meta.build_details")]
|
#[my_codegen::get(path = "crate::V1_API_ROUTES.meta.build_details")]
|
||||||
async fn build_details() -> impl Responder {
|
async fn build_details() -> impl Responder {
|
||||||
let build = BuildDetails {
|
let build = BuildDetails {
|
||||||
|
|
|
@ -42,7 +42,7 @@ pub async fn add_notification(
|
||||||
id: Identity,
|
id: Identity,
|
||||||
) -> ServiceResult<impl Responder> {
|
) -> ServiceResult<impl Responder> {
|
||||||
let sender = id.identity().unwrap();
|
let sender = id.identity().unwrap();
|
||||||
// TODO handle error where payload.to doesnt exist
|
// TODO handle error where payload.to doesn't exist
|
||||||
|
|
||||||
let p = AddNotification {
|
let p = AddNotification {
|
||||||
from: &sender,
|
from: &sender,
|
||||||
|
@ -98,7 +98,7 @@ pub mod tests {
|
||||||
let msg = AddNotificationRequest {
|
let msg = AddNotificationRequest {
|
||||||
to: NAME2.into(),
|
to: NAME2.into(),
|
||||||
heading: "Test notification".into(),
|
heading: "Test notification".into(),
|
||||||
message: "Testeing notifications with a dummy message".into(),
|
message: "Testing notifications with a dummy message".into(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let send_notification_resp = test::call_service(
|
let send_notification_resp = test::call_service(
|
||||||
|
|
|
@ -68,7 +68,7 @@ pub async fn get_notification(
|
||||||
id: Identity,
|
id: Identity,
|
||||||
) -> ServiceResult<impl Responder> {
|
) -> ServiceResult<impl Responder> {
|
||||||
let receiver = id.identity().unwrap();
|
let receiver = id.identity().unwrap();
|
||||||
// TODO handle error where payload.to doesnt exist
|
// TODO handle error where payload.to doesn't exist
|
||||||
|
|
||||||
let notifications = data.db.get_all_unread_notifications(&receiver).await?;
|
let notifications = data.db.get_all_unread_notifications(&receiver).await?;
|
||||||
let notifications = NotificationResp::from_notifications(notifications);
|
let notifications = NotificationResp::from_notifications(notifications);
|
||||||
|
|
|
@ -38,7 +38,7 @@ pub async fn mark_read(
|
||||||
id: Identity,
|
id: Identity,
|
||||||
) -> ServiceResult<impl Responder> {
|
) -> ServiceResult<impl Responder> {
|
||||||
let receiver = id.identity().unwrap();
|
let receiver = id.identity().unwrap();
|
||||||
// TODO handle error where payload.to doesnt exist
|
// TODO handle error where payload.to doesn't exist
|
||||||
|
|
||||||
// TODO get payload from path /api/v1/notifications/{id}/read"
|
// TODO get payload from path /api/v1/notifications/{id}/read"
|
||||||
data.db
|
data.db
|
||||||
|
|
|
@ -135,7 +135,7 @@ pub mod tests {
|
||||||
// .await;
|
// .await;
|
||||||
// assert_eq!(pow_config_resp.status(), StatusCode::OK);
|
// assert_eq!(pow_config_resp.status(), StatusCode::OK);
|
||||||
// I'm not checking for errors because changing work.result triggered
|
// I'm not checking for errors because changing work.result triggered
|
||||||
// InssuficientDifficulty, which is possible becuase libmcaptcha calculates
|
// InssuficientDifficulty, which is possible because libmcaptcha calculates
|
||||||
// difficulty with the submitted result. Besides, this endpoint is merely
|
// difficulty with the submitted result. Besides, this endpoint is merely
|
||||||
// propagating errors from libmcaptcha and libmcaptcha has tests covering the
|
// propagating errors from libmcaptcha and libmcaptcha has tests covering the
|
||||||
// pow aspects ¯\_(ツ)_/¯
|
// pow aspects ¯\_(ツ)_/¯
|
||||||
|
|
|
@ -47,7 +47,7 @@ impl From<VerifyCaptchaResultPayload> for VerifyCaptchaResult {
|
||||||
|
|
||||||
// API keys are mcaptcha actor names
|
// API keys are mcaptcha actor names
|
||||||
|
|
||||||
/// route hander that validates a PoW solution token
|
/// route handler that validates a PoW solution token
|
||||||
#[my_codegen::post(path = "V1_API_ROUTES.pow.validate_captcha_token()")]
|
#[my_codegen::post(path = "V1_API_ROUTES.pow.validate_captcha_token()")]
|
||||||
pub async fn validate_captcha_token(
|
pub async fn validate_captcha_token(
|
||||||
payload: web::Json<VerifyCaptchaResultPayload>,
|
payload: web::Json<VerifyCaptchaResultPayload>,
|
||||||
|
|
|
@ -69,7 +69,7 @@ macro_rules! enum_system_wrapper {
|
||||||
|
|
||||||
/// Represents mCaptcha cache and master system.
|
/// Represents mCaptcha cache and master system.
|
||||||
/// When Redis is configured, [SystemGroup::Redis] is used and
|
/// When Redis is configured, [SystemGroup::Redis] is used and
|
||||||
/// in its absense, [SystemGroup::Embedded] is used
|
/// in its absence, [SystemGroup::Embedded] is used
|
||||||
pub enum SystemGroup {
|
pub enum SystemGroup {
|
||||||
Embedded(System<HashCache, EmbeddedMaster>),
|
Embedded(System<HashCache, EmbeddedMaster>),
|
||||||
Redis(System<RedisCache, RedisMaster>),
|
Redis(System<RedisCache, RedisMaster>),
|
||||||
|
|
|
@ -71,7 +71,7 @@ const PAGE: &str = "Notifications";
|
||||||
)]
|
)]
|
||||||
pub async fn notifications(data: AppData, id: Identity) -> PageResult<impl Responder> {
|
pub async fn notifications(data: AppData, id: Identity) -> PageResult<impl Responder> {
|
||||||
let receiver = id.identity().unwrap();
|
let receiver = id.identity().unwrap();
|
||||||
// TODO handle error where payload.to doesnt exist
|
// TODO handle error where payload.to doesn't exist
|
||||||
|
|
||||||
// let mut notifications = runner::get_notification(&data, &receiver).await?;
|
// let mut notifications = runner::get_notification(&data, &receiver).await?;
|
||||||
let mut notifications = data.db.get_all_unread_notifications(&receiver).await?;
|
let mut notifications = data.db.get_all_unread_notifications(&receiver).await?;
|
||||||
|
|
|
@ -78,7 +78,7 @@ impl Server {
|
||||||
//impl DatabaseBuilder {
|
//impl DatabaseBuilder {
|
||||||
// #[cfg(not(tarpaulin_include))]
|
// #[cfg(not(tarpaulin_include))]
|
||||||
// fn extract_database_url(url: &Url) -> Self {
|
// fn extract_database_url(url: &Url) -> Self {
|
||||||
// debug!("Databse name: {}", url.path());
|
// debug!("Database name: {}", url.path());
|
||||||
// let mut path = url.path().split('/');
|
// let mut path = url.path().split('/');
|
||||||
// path.next();
|
// path.next();
|
||||||
// let name = path.next().expect("no database name").to_string();
|
// let name = path.next().expect("no database name").to_string();
|
||||||
|
@ -223,7 +223,7 @@ fn set_database_url(s: &mut Config) {
|
||||||
.expect("Couldn't access database name")
|
.expect("Couldn't access database name")
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.expect("Couldn't set databse url");
|
.expect("Couldn't set database url");
|
||||||
}
|
}
|
||||||
|
|
||||||
//#[cfg(test)]
|
//#[cfg(test)]
|
||||||
|
|
Loading…
Add table
Reference in a new issue