Format code
This commit is contained in:
parent
70ca962f8c
commit
5a7ddb03e1
@ -20,8 +20,8 @@ pub fn db_msg(item: TokenStream) -> TokenStream {
|
|||||||
panic!("Expect to find keyword struct but nothing was found")
|
panic!("Expect to find keyword struct but nothing was found")
|
||||||
}
|
}
|
||||||
let _name = it
|
let _name = it
|
||||||
.next()
|
.next()
|
||||||
.expect("Expect to struct name but nothing was found");
|
.expect("Expect to struct name but nothing was found");
|
||||||
|
|
||||||
"".parse().unwrap()
|
"".parse().unwrap()
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use {
|
use {
|
||||||
crate::{db_find, tokens::FindAccessToken},
|
crate::{db_find, tokens::FindAccessToken},
|
||||||
diesel::prelude::*,
|
diesel::prelude::*,
|
||||||
jirs_data::User,
|
jirs_data::User,
|
||||||
};
|
};
|
||||||
|
|
||||||
db_find! {
|
db_find! {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use {
|
use {
|
||||||
crate::{db_create, db_delete, db_load, db_update},
|
crate::{db_create, db_delete, db_load, db_update},
|
||||||
diesel::prelude::*,
|
diesel::prelude::*,
|
||||||
jirs_data::{Comment, CommentId, IssueId, UserId},
|
jirs_data::{Comment, CommentId, IssueId, UserId},
|
||||||
};
|
};
|
||||||
|
|
||||||
db_load! {
|
db_load! {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use {
|
use {
|
||||||
crate::{db_create, db_delete, db_load, db_update},
|
crate::{db_create, db_delete, db_load, db_update},
|
||||||
diesel::prelude::*,
|
diesel::prelude::*,
|
||||||
jirs_data::Epic,
|
jirs_data::Epic,
|
||||||
};
|
};
|
||||||
|
|
||||||
db_load! {
|
db_load! {
|
||||||
|
@ -101,7 +101,7 @@ impl AcceptInvitation {
|
|||||||
let invitation = crate::invitations::FindByBindToken {
|
let invitation = crate::invitations::FindByBindToken {
|
||||||
token: self.invitation_token,
|
token: self.invitation_token,
|
||||||
}
|
}
|
||||||
.execute(conn)?;
|
.execute(conn)?;
|
||||||
|
|
||||||
if invitation.state == InvitationState::Revoked {
|
if invitation.state == InvitationState::Revoked {
|
||||||
return Err(crate::DatabaseError::Invitation(
|
return Err(crate::DatabaseError::Invitation(
|
||||||
@ -113,13 +113,13 @@ impl AcceptInvitation {
|
|||||||
id: invitation.id,
|
id: invitation.id,
|
||||||
state: InvitationState::Accepted,
|
state: InvitationState::Accepted,
|
||||||
}
|
}
|
||||||
.execute(conn)?;
|
.execute(conn)?;
|
||||||
|
|
||||||
UpdateInvitationState {
|
UpdateInvitationState {
|
||||||
id: invitation.id,
|
id: invitation.id,
|
||||||
state: InvitationState::Accepted,
|
state: InvitationState::Accepted,
|
||||||
}
|
}
|
||||||
.execute(conn)?;
|
.execute(conn)?;
|
||||||
|
|
||||||
match {
|
match {
|
||||||
Register {
|
Register {
|
||||||
@ -128,7 +128,7 @@ impl AcceptInvitation {
|
|||||||
project_id: Some(invitation.project_id),
|
project_id: Some(invitation.project_id),
|
||||||
role: UserRole::User,
|
role: UserRole::User,
|
||||||
}
|
}
|
||||||
.execute(conn)
|
.execute(conn)
|
||||||
} {
|
} {
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(crate::DatabaseError::User(crate::UserError::InvalidPair(..))) => (),
|
Err(crate::DatabaseError::User(crate::UserError::InvalidPair(..))) => (),
|
||||||
@ -139,7 +139,7 @@ impl AcceptInvitation {
|
|||||||
name: invitation.name.clone(),
|
name: invitation.name.clone(),
|
||||||
email: invitation.email.clone(),
|
email: invitation.email.clone(),
|
||||||
}
|
}
|
||||||
.execute(conn)?;
|
.execute(conn)?;
|
||||||
CreateBindToken { user_id: user.id }.execute(conn)?;
|
CreateBindToken { user_id: user.id }.execute(conn)?;
|
||||||
|
|
||||||
crate::user_projects::CreateUserProject {
|
crate::user_projects::CreateUserProject {
|
||||||
@ -149,7 +149,7 @@ impl AcceptInvitation {
|
|||||||
is_default: false,
|
is_default: false,
|
||||||
role: invitation.role,
|
role: invitation.role,
|
||||||
}
|
}
|
||||||
.execute(conn)?;
|
.execute(conn)?;
|
||||||
|
|
||||||
crate::tokens::FindUserId { user_id: user.id }.execute(conn)
|
crate::tokens::FindUserId { user_id: user.id }.execute(conn)
|
||||||
})
|
})
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use {
|
use {
|
||||||
crate::{db_create, db_delete, db_load, db_load_field},
|
crate::{db_create, db_delete, db_load, db_load_field},
|
||||||
diesel::{expression::dsl::not, prelude::*},
|
diesel::{expression::dsl::not, prelude::*},
|
||||||
jirs_data::{IssueAssignee, IssueId, UserId},
|
jirs_data::{IssueAssignee, IssueId, UserId},
|
||||||
};
|
};
|
||||||
|
|
||||||
db_create! {
|
db_create! {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use {
|
use {
|
||||||
crate::{db_create, db_delete, db_load, db_update},
|
crate::{db_create, db_delete, db_load, db_update},
|
||||||
diesel::prelude::*,
|
diesel::prelude::*,
|
||||||
jirs_data::{IssueStatus, IssueStatusId, Position, ProjectId, TitleString},
|
jirs_data::{IssueStatus, IssueStatusId, Position, ProjectId, TitleString},
|
||||||
};
|
};
|
||||||
|
|
||||||
db_load! {
|
db_load! {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
db_create_with_conn, db_delete_with_conn, db_find, db_load, db_update_with_conn,
|
db_create_with_conn, db_delete_with_conn, db_find, db_load, db_update_with_conn,
|
||||||
models::Issue,
|
models::Issue,
|
||||||
},
|
},
|
||||||
diesel::{expression::sql_literal::sql, prelude::*},
|
diesel::{expression::sql_literal::sql, prelude::*},
|
||||||
jirs_data::{IssueId, IssuePriority, IssueStatusId, IssueType, ProjectId, UserId},
|
jirs_data::{IssueId, IssuePriority, IssueStatusId, IssueType, ProjectId, UserId},
|
||||||
};
|
};
|
||||||
|
|
||||||
db_find! {
|
db_find! {
|
||||||
@ -91,13 +91,13 @@ db_delete_with_conn! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod inner {
|
mod inner {
|
||||||
use {
|
use {
|
||||||
crate::{db_create, models::Issue},
|
crate::{db_create, models::Issue},
|
||||||
diesel::prelude::*,
|
diesel::prelude::*,
|
||||||
jirs_data::{IssuePriority, IssueStatusId, IssueType},
|
jirs_data::{IssuePriority, IssueStatusId, IssueType},
|
||||||
};
|
};
|
||||||
|
|
||||||
db_create! {
|
db_create! {
|
||||||
CreateIssue,
|
CreateIssue,
|
||||||
msg => issues => diesel::insert_into(issues)
|
msg => issues => diesel::insert_into(issues)
|
||||||
.values((
|
.values((
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
db_create_with_conn, db_delete, db_load,
|
db_create_with_conn, db_delete, db_load,
|
||||||
users::{FindUser, LookupUser},
|
users::{FindUser, LookupUser},
|
||||||
},
|
},
|
||||||
diesel::prelude::*,
|
diesel::prelude::*,
|
||||||
jirs_data::{BindToken, Message, MessageId, MessageType, User, UserId},
|
jirs_data::{BindToken, Message, MessageId, MessageType, User, UserId},
|
||||||
};
|
};
|
||||||
|
|
||||||
db_load! {
|
db_load! {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use {
|
use {
|
||||||
crate::{db_create_with_conn, db_find, db_load, db_update},
|
crate::{db_create_with_conn, db_find, db_load, db_update},
|
||||||
diesel::prelude::*,
|
diesel::prelude::*,
|
||||||
jirs_data::{NameString, Project, ProjectCategory, ProjectId, TimeTracking, UserId},
|
jirs_data::{NameString, Project, ProjectCategory, ProjectId, TimeTracking, UserId},
|
||||||
};
|
};
|
||||||
|
|
||||||
db_find! {
|
db_find! {
|
||||||
@ -12,13 +12,13 @@ db_find! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod inner {
|
mod inner {
|
||||||
use {
|
use {
|
||||||
crate::db_create,
|
crate::db_create,
|
||||||
diesel::prelude::*,
|
diesel::prelude::*,
|
||||||
jirs_data::{NameString, Project, ProjectCategory, TimeTracking},
|
jirs_data::{NameString, Project, ProjectCategory, TimeTracking},
|
||||||
};
|
};
|
||||||
|
|
||||||
db_create! {
|
db_create! {
|
||||||
CreateProject,
|
CreateProject,
|
||||||
msg => projects => diesel::insert_into(projects)
|
msg => projects => diesel::insert_into(projects)
|
||||||
.values((
|
.values((
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use {
|
use {
|
||||||
crate::{db_create, db_find, db_update_with_conn},
|
crate::{db_create, db_find, db_update_with_conn},
|
||||||
diesel::prelude::*,
|
diesel::prelude::*,
|
||||||
jirs_data::{Token, UserId},
|
jirs_data::{Token, UserId},
|
||||||
};
|
};
|
||||||
|
|
||||||
db_find! {
|
db_find! {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use {
|
use {
|
||||||
crate::{db_create, db_delete_with_conn, db_find, db_load, db_update_with_conn},
|
crate::{db_create, db_delete_with_conn, db_find, db_load, db_update_with_conn},
|
||||||
diesel::prelude::*,
|
diesel::prelude::*,
|
||||||
jirs_data::{ProjectId, UserId, UserProject, UserProjectId, UserRole},
|
jirs_data::{ProjectId, UserId, UserProject, UserProjectId, UserRole},
|
||||||
};
|
};
|
||||||
|
|
||||||
db_find! {
|
db_find! {
|
||||||
@ -27,13 +27,13 @@ db_load! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod inner {
|
mod inner {
|
||||||
use {
|
use {
|
||||||
crate::db_update,
|
crate::db_update,
|
||||||
diesel::prelude::*,
|
diesel::prelude::*,
|
||||||
jirs_data::{UserId, UserProject, UserProjectId},
|
jirs_data::{UserId, UserProject, UserProjectId},
|
||||||
};
|
};
|
||||||
|
|
||||||
db_update! {
|
db_update! {
|
||||||
ChangeProjectIsCurrent,
|
ChangeProjectIsCurrent,
|
||||||
msg => user_projects => {
|
msg => user_projects => {
|
||||||
match msg.id {
|
match msg.id {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
db_create, db_create_with_conn, db_find, db_load, db_update, projects::CreateProject, q,
|
db_create, db_create_with_conn, db_find, db_load, db_update, projects::CreateProject, q,
|
||||||
user_projects::CreateUserProject, DbPooledConn,
|
user_projects::CreateUserProject, DbPooledConn,
|
||||||
},
|
},
|
||||||
diesel::prelude::*,
|
diesel::prelude::*,
|
||||||
jirs_data::{EmailString, IssueId, ProjectId, User, UserId, UserRole, UsernameString},
|
jirs_data::{EmailString, IssueId, ProjectId, User, UserId, UserRole, UsernameString},
|
||||||
};
|
};
|
||||||
|
|
||||||
db_find! {
|
db_find! {
|
||||||
@ -205,7 +205,7 @@ mod tests {
|
|||||||
|
|
||||||
use jirs_data::{Project, ProjectCategory};
|
use jirs_data::{Project, ProjectCategory};
|
||||||
|
|
||||||
use crate::build_pool;
|
use crate::build_pool;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
@ -32,13 +32,13 @@ fn mail_client(config: &jirs_config::mail::Configuration) -> lettre::SmtpClient
|
|||||||
let mail_host = config.host.as_str();
|
let mail_host = config.host.as_str();
|
||||||
|
|
||||||
lettre::SmtpClient::new_simple(mail_host)
|
lettre::SmtpClient::new_simple(mail_host)
|
||||||
.expect("Failed to init SMTP client")
|
.expect("Failed to init SMTP client")
|
||||||
.credentials(lettre::smtp::authentication::Credentials::new(
|
.credentials(lettre::smtp::authentication::Credentials::new(
|
||||||
mail_user.to_string(),
|
mail_user.to_string(),
|
||||||
mail_pass.to_string(),
|
mail_pass.to_string(),
|
||||||
))
|
))
|
||||||
.connection_reuse(lettre::smtp::ConnectionReuseParameters::ReuseUnlimited)
|
.connection_reuse(lettre::smtp::ConnectionReuseParameters::ReuseUnlimited)
|
||||||
.smtp_utf8(true)
|
.smtp_utf8(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mail_transport(config: &jirs_config::mail::Configuration) -> MailTransport {
|
fn mail_transport(config: &jirs_config::mail::Configuration) -> MailTransport {
|
||||||
|
@ -46,7 +46,7 @@ pub async fn upload(
|
|||||||
disposition,
|
disposition,
|
||||||
fs.clone(),
|
fs.clone(),
|
||||||
)
|
)
|
||||||
.await?,
|
.await?,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
_ => continue,
|
_ => continue,
|
||||||
|
@ -57,13 +57,13 @@ impl Into<HttpResponse> for ServiceError {
|
|||||||
errors: vec![error.to_str().to_string()],
|
errors: vec![error.to_str().to_string()],
|
||||||
}),
|
}),
|
||||||
ServiceError::Highlight(HighlightError::UnknownTheme) => HttpResponse::BadRequest()
|
ServiceError::Highlight(HighlightError::UnknownTheme) => HttpResponse::BadRequest()
|
||||||
.json(ErrorResponse::single(
|
.json(ErrorResponse::single(
|
||||||
"Code highlight Failed. Unexpected theme",
|
"Code highlight Failed. Unexpected theme",
|
||||||
)),
|
)),
|
||||||
ServiceError::Highlight(HighlightError::UnknownLanguage) => HttpResponse::BadRequest()
|
ServiceError::Highlight(HighlightError::UnknownLanguage) => HttpResponse::BadRequest()
|
||||||
.json(ErrorResponse::single(
|
.json(ErrorResponse::single(
|
||||||
"Can't highlight in given language. It's unknown",
|
"Can't highlight in given language. It's unknown",
|
||||||
)),
|
)),
|
||||||
ServiceError::Highlight(HighlightError::ResultUnserializable) => {
|
ServiceError::Highlight(HighlightError::ResultUnserializable) => {
|
||||||
HttpResponse::BadRequest().json(ErrorResponse::single(
|
HttpResponse::BadRequest().json(ErrorResponse::single(
|
||||||
"Highlight succeed but result can't be send",
|
"Highlight succeed but result can't be send",
|
||||||
|
@ -76,11 +76,11 @@ pub(crate) async fn handle_image(
|
|||||||
{
|
{
|
||||||
use filesystem_actor::RemoveTmpFile;
|
use filesystem_actor::RemoveTmpFile;
|
||||||
let _ = fs
|
let _ = fs
|
||||||
.send(RemoveTmpFile {
|
.send(RemoveTmpFile {
|
||||||
file_name: format!("{}-{}", user_id, filename),
|
file_name: format!("{}-{}", user_id, filename),
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.ok();
|
.ok();
|
||||||
};
|
};
|
||||||
Ok(new_link.unwrap_or_default())
|
Ok(new_link.unwrap_or_default())
|
||||||
}
|
}
|
||||||
@ -113,11 +113,11 @@ pub(crate) async fn handle_image(
|
|||||||
{
|
{
|
||||||
use filesystem_actor::RemoveTmpFile;
|
use filesystem_actor::RemoveTmpFile;
|
||||||
let _ = fs
|
let _ = fs
|
||||||
.send(RemoveTmpFile {
|
.send(RemoveTmpFile {
|
||||||
file_name: format!("{}-{}", user_id, filename),
|
file_name: format!("{}-{}", user_id, filename),
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.ok();
|
.ok();
|
||||||
};
|
};
|
||||||
Ok(new_link.unwrap_or_default())
|
Ok(new_link.unwrap_or_default())
|
||||||
}
|
}
|
||||||
@ -183,11 +183,11 @@ async fn local_storage_write(
|
|||||||
let fs_config = jirs_config::fs::Configuration::read();
|
let fs_config = jirs_config::fs::Configuration::read();
|
||||||
|
|
||||||
let _ = fs
|
let _ = fs
|
||||||
.send(filesystem_actor::CreateFile {
|
.send(filesystem_actor::CreateFile {
|
||||||
source: receiver,
|
source: receiver,
|
||||||
file_name: system_file_name.clone(),
|
file_name: system_file_name.clone(),
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
Some(format!(
|
Some(format!(
|
||||||
"{proto}://{bind}{port}{client_path}/{user_id}-{filename}",
|
"{proto}://{bind}{port}{client_path}/{user_id}-{filename}",
|
||||||
|
@ -3,11 +3,11 @@ extern crate log;
|
|||||||
|
|
||||||
pub use errors::*;
|
pub use errors::*;
|
||||||
use {
|
use {
|
||||||
crate::middleware::authorize::token_from_headers,
|
crate::middleware::authorize::token_from_headers,
|
||||||
actix::Addr,
|
actix::Addr,
|
||||||
actix_web::{web::Data, HttpRequest, HttpResponse},
|
actix_web::{web::Data, HttpRequest, HttpResponse},
|
||||||
database_actor::{authorize_user::AuthorizeUser, DbExecutor},
|
database_actor::{authorize_user::AuthorizeUser, DbExecutor},
|
||||||
jirs_data::User,
|
jirs_data::User,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub mod avatar;
|
pub mod avatar;
|
||||||
@ -16,21 +16,21 @@ pub mod handlers;
|
|||||||
pub mod middleware;
|
pub mod middleware;
|
||||||
|
|
||||||
pub async fn user_from_request(
|
pub async fn user_from_request(
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
db: &Data<Addr<DbExecutor>>,
|
db: &Data<Addr<DbExecutor>>,
|
||||||
) -> Result<User, HttpResponse> {
|
) -> Result<User, HttpResponse> {
|
||||||
let token = match token_from_headers(req.headers()) {
|
let token = match token_from_headers(req.headers()) {
|
||||||
Ok(uuid) => uuid,
|
Ok(uuid) => uuid,
|
||||||
_ => return Err(ServiceError::Unauthorized.into_http_response()),
|
_ => return Err(ServiceError::Unauthorized.into_http_response()),
|
||||||
};
|
};
|
||||||
match db
|
match db
|
||||||
.send(AuthorizeUser {
|
.send(AuthorizeUser {
|
||||||
access_token: token,
|
access_token: token,
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(Ok(user)) => Ok(user),
|
Ok(Ok(user)) => Ok(user),
|
||||||
Ok(Err(_e)) => Err(HttpResponse::InternalServerError().body("Critical database error")),
|
Ok(Err(_e)) => Err(HttpResponse::InternalServerError().body("Critical database error")),
|
||||||
_ => Err(ServiceError::Unauthorized.into_http_response()),
|
_ => Err(ServiceError::Unauthorized.into_http_response()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,11 +100,11 @@ fn check_token(
|
|||||||
token_from_headers(headers).and_then(|access_token| {
|
token_from_headers(headers).and_then(|access_token| {
|
||||||
use database_actor::authorize_user::AuthorizeUser;
|
use database_actor::authorize_user::AuthorizeUser;
|
||||||
let conn = pool
|
let conn = pool
|
||||||
.get()
|
.get()
|
||||||
.map_err(|_| crate::errors::ServiceError::DatabaseConnectionLost)?;
|
.map_err(|_| crate::errors::ServiceError::DatabaseConnectionLost)?;
|
||||||
AuthorizeUser { access_token }
|
AuthorizeUser { access_token }
|
||||||
.execute(&conn)
|
.execute(&conn)
|
||||||
.map_err(|_| crate::errors::ServiceError::Unauthorized)
|
.map_err(|_| crate::errors::ServiceError::Unauthorized)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ impl WsHandler<LoadEpics> for WebSocketActor {
|
|||||||
fn handle_msg(&mut self, _msg: LoadEpics, _ctx: &mut Self::Context) -> WsResult {
|
fn handle_msg(&mut self, _msg: LoadEpics, _ctx: &mut Self::Context) -> WsResult {
|
||||||
let project_id = self.require_user_project()?.project_id;
|
let project_id = self.require_user_project()?.project_id;
|
||||||
let epics =
|
let epics =
|
||||||
crate::query_db_or_print!(self, database_actor::epics::LoadEpics { project_id });
|
crate::query_db_or_print!(self, database_actor::epics::LoadEpics { project_id });
|
||||||
Ok(Some(WsMsg::EpicsLoaded(epics)))
|
Ok(Some(WsMsg::EpicsLoaded(epics)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,23 +46,23 @@ impl WsHandler<CreateInvitation> for WebSocketActor {
|
|||||||
|
|
||||||
let CreateInvitation { email, name, role } = msg;
|
let CreateInvitation { email, name, role } = msg;
|
||||||
let invitation =
|
let invitation =
|
||||||
match block_on(self.db.send(database_actor::invitations::CreateInvitation {
|
match block_on(self.db.send(database_actor::invitations::CreateInvitation {
|
||||||
user_id,
|
user_id,
|
||||||
project_id,
|
project_id,
|
||||||
email: email.clone(),
|
email: email.clone(),
|
||||||
name: name.clone(),
|
name: name.clone(),
|
||||||
role,
|
role,
|
||||||
})) {
|
})) {
|
||||||
Ok(Ok(invitation)) => invitation,
|
Ok(Ok(invitation)) => invitation,
|
||||||
Ok(Err(e)) => {
|
Ok(Err(e)) => {
|
||||||
error!("{:?}", e);
|
error!("{:?}", e);
|
||||||
return Ok(Some(WsMsg::InvitationSendFailure));
|
return Ok(Some(WsMsg::InvitationSendFailure));
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("{}", e);
|
error!("{}", e);
|
||||||
return Ok(Some(WsMsg::InvitationSendFailure));
|
return Ok(Some(WsMsg::InvitationSendFailure));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
match block_on(self.mail.send(mail_actor::invite::Invite {
|
match block_on(self.mail.send(mail_actor::invite::Invite {
|
||||||
bind_token: invitation.bind_token,
|
bind_token: invitation.bind_token,
|
||||||
email: invitation.email,
|
email: invitation.email,
|
||||||
@ -168,13 +168,13 @@ impl WsHandler<AcceptInvitation> for WebSocketActor {
|
|||||||
|
|
||||||
for message in block_on(
|
for message in block_on(
|
||||||
self.db
|
self.db
|
||||||
.send(database_actor::messages::LookupMessagesByToken {
|
.send(database_actor::messages::LookupMessagesByToken {
|
||||||
token: invitation_token,
|
token: invitation_token,
|
||||||
user_id: token.user_id,
|
user_id: token.user_id,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.unwrap_or_else(|_| Ok(vec![]))
|
.unwrap_or_else(|_| Ok(vec![]))
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
{
|
{
|
||||||
match block_on(self.db.send(database_actor::messages::MarkMessageSeen {
|
match block_on(self.db.send(database_actor::messages::MarkMessageSeen {
|
||||||
user_id: token.user_id,
|
user_id: token.user_id,
|
||||||
|
@ -151,7 +151,7 @@ impl WsHandler<DeleteIssue> for WebSocketActor {
|
|||||||
self.require_user()?;
|
self.require_user()?;
|
||||||
let m = match block_on(
|
let m = match block_on(
|
||||||
self.db
|
self.db
|
||||||
.send(database_actor::issues::DeleteIssue { issue_id: msg.id }),
|
.send(database_actor::issues::DeleteIssue { issue_id: msg.id }),
|
||||||
) {
|
) {
|
||||||
Ok(Ok(n)) => Some(WsMsg::IssueDeleted(msg.id, n)),
|
Ok(Ok(n)) => Some(WsMsg::IssueDeleted(msg.id, n)),
|
||||||
Ok(Err(e)) => {
|
Ok(Err(e)) => {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
pub use {
|
pub use {
|
||||||
auth::*, comments::*, epics::*, invitations::*, issue_statuses::*, issues::*, messages::*,
|
auth::*, comments::*, epics::*, invitations::*, issue_statuses::*, issues::*, messages::*,
|
||||||
projects::*, user_projects::*, users::*,
|
projects::*, user_projects::*, users::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub mod auth;
|
pub mod auth;
|
||||||
|
@ -32,7 +32,7 @@ impl WsHandler<UpdateProjectPayload> for WebSocketActor {
|
|||||||
};
|
};
|
||||||
let projects = match block_on(
|
let projects = match block_on(
|
||||||
self.db
|
self.db
|
||||||
.send(database_actor::projects::LoadProjects { user_id: *user_id }),
|
.send(database_actor::projects::LoadProjects { user_id: *user_id }),
|
||||||
) {
|
) {
|
||||||
Ok(Ok(projects)) => projects,
|
Ok(Ok(projects)) => projects,
|
||||||
Ok(Err(e)) => {
|
Ok(Err(e)) => {
|
||||||
|
@ -67,7 +67,7 @@ impl WsHandler<LoadInvitedUsers> for WebSocketActor {
|
|||||||
|
|
||||||
let users = match block_on(
|
let users = match block_on(
|
||||||
self.db
|
self.db
|
||||||
.send(database_actor::users::LoadInvitedUsers { user_id }),
|
.send(database_actor::users::LoadInvitedUsers { user_id }),
|
||||||
) {
|
) {
|
||||||
Ok(Ok(users)) => users,
|
Ok(Ok(users)) => users,
|
||||||
_ => return Ok(None),
|
_ => return Ok(None),
|
||||||
@ -123,11 +123,11 @@ impl WsHandler<RemoveInvitedUser> for WebSocketActor {
|
|||||||
} = self.require_user_project()?.clone();
|
} = self.require_user_project()?.clone();
|
||||||
match block_on(
|
match block_on(
|
||||||
self.db
|
self.db
|
||||||
.send(database_actor::user_projects::RemoveInvitedUser {
|
.send(database_actor::user_projects::RemoveInvitedUser {
|
||||||
invited_id,
|
invited_id,
|
||||||
inviter_id,
|
inviter_id,
|
||||||
project_id,
|
project_id,
|
||||||
}),
|
}),
|
||||||
) {
|
) {
|
||||||
Ok(Ok(_users)) => Ok(Some(WsMsg::InvitedUserRemoveSuccess(invited_id))),
|
Ok(Ok(_users)) => Ok(Some(WsMsg::InvitedUserRemoveSuccess(invited_id))),
|
||||||
Ok(Err(e)) => {
|
Ok(Err(e)) => {
|
||||||
|
@ -44,9 +44,9 @@ impl actix::Handler<InnerMsg> for WsServer {
|
|||||||
match msg {
|
match msg {
|
||||||
InnerMsg::Join(project_id, user_id, recipient) => {
|
InnerMsg::Join(project_id, user_id, recipient) => {
|
||||||
let v = self
|
let v = self
|
||||||
.sessions
|
.sessions
|
||||||
.entry(user_id)
|
.entry(user_id)
|
||||||
.or_insert_with(Default::default);
|
.or_insert_with(Default::default);
|
||||||
v.push(recipient);
|
v.push(recipient);
|
||||||
self.ensure_room(project_id);
|
self.ensure_room(project_id);
|
||||||
|
|
||||||
|
@ -26,9 +26,9 @@ pub fn update(msg: &Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
Msg::WebSocketChange(WebSocketChanged::WsMsg(WsMsg::IssueStatusDeleted(
|
Msg::WebSocketChange(WebSocketChanged::WsMsg(WsMsg::IssueStatusDeleted(
|
||||||
_id,
|
_id,
|
||||||
_n_deleted,
|
_n_deleted,
|
||||||
))) => {
|
))) => {
|
||||||
orders.skip().send_msg(Msg::ModalDropped);
|
orders.skip().send_msg(Msg::ModalDropped);
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
|
@ -46,17 +46,17 @@ pub fn update(msg: Msg, model: &mut crate::model::Model, orders: &mut impl Order
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Msg::WebSocketChange(WebSocketChanged::WsMsg(WsMsg::IssueDeleted(id, count)))
|
Msg::WebSocketChange(WebSocketChanged::WsMsg(WsMsg::IssueDeleted(id, count)))
|
||||||
if count > 0 =>
|
if count > 0 =>
|
||||||
{
|
{
|
||||||
let mut old: Vec<Issue> = vec![];
|
let mut old: Vec<Issue> = vec![];
|
||||||
std::mem::swap(&mut old, &mut model.issues);
|
std::mem::swap(&mut old, &mut model.issues);
|
||||||
for is in old {
|
for is in old {
|
||||||
if is.id != id {
|
if is.id != id {
|
||||||
model.issues.push(is);
|
model.issues.push(is);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
orders.skip().send_msg(Msg::ModalDropped);
|
|
||||||
}
|
}
|
||||||
|
orders.skip().send_msg(Msg::ModalDropped);
|
||||||
|
}
|
||||||
Msg::StyledSelectChanged(
|
Msg::StyledSelectChanged(
|
||||||
FieldId::EditIssueModal(EditIssueModalSection::Issue(IssueFieldId::Type)),
|
FieldId::EditIssueModal(EditIssueModalSection::Issue(IssueFieldId::Type)),
|
||||||
StyledSelectChanged::Text(text),
|
StyledSelectChanged::Text(text),
|
||||||
|
@ -160,8 +160,8 @@ pub fn update(msg: &WsMsg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
model
|
model
|
||||||
.issue_statuses
|
.issue_statuses
|
||||||
.sort_by(|a, b| a.position.cmp(&b.position));
|
.sort_by(|a, b| a.position.cmp(&b.position));
|
||||||
}
|
}
|
||||||
WsMsg::IssueStatusDeleted(dropped_id, _count) => {
|
WsMsg::IssueStatusDeleted(dropped_id, _count) => {
|
||||||
let mut old = vec![];
|
let mut old = vec![];
|
||||||
@ -172,8 +172,8 @@ pub fn update(msg: &WsMsg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
model
|
model
|
||||||
.issue_statuses
|
.issue_statuses
|
||||||
.sort_by(|a, b| a.position.cmp(&b.position));
|
.sort_by(|a, b| a.position.cmp(&b.position));
|
||||||
}
|
}
|
||||||
WsMsg::IssueDeleted(id, _count) => {
|
WsMsg::IssueDeleted(id, _count) => {
|
||||||
let mut old = vec![];
|
let mut old = vec![];
|
||||||
@ -185,7 +185,7 @@ pub fn update(msg: &WsMsg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
|||||||
model.issue_statuses.push(is);
|
model.issue_statuses.push(is);
|
||||||
}
|
}
|
||||||
model
|
model
|
||||||
.issue_statuses
|
.issue_statuses
|
||||||
.sort_by(|a, b| a.position.cmp(&b.position));
|
.sort_by(|a, b| a.position.cmp(&b.position));
|
||||||
}
|
}
|
||||||
// users
|
// users
|
||||||
|
@ -36,7 +36,7 @@ async fn main() -> Result<(), String> {
|
|||||||
highlight_actor::HighlightActor::default,
|
highlight_actor::HighlightActor::default,
|
||||||
);
|
);
|
||||||
#[cfg(feature = "local-storage")]
|
#[cfg(feature = "local-storage")]
|
||||||
let fs_addr = actix::SyncArbiter::start(
|
let fs_addr = actix::SyncArbiter::start(
|
||||||
jirs_config::fs::Configuration::read().concurrency,
|
jirs_config::fs::Configuration::read().concurrency,
|
||||||
filesystem_actor::FileSystemExecutor::default,
|
filesystem_actor::FileSystemExecutor::default,
|
||||||
);
|
);
|
||||||
@ -48,21 +48,19 @@ async fn main() -> Result<(), String> {
|
|||||||
|
|
||||||
// data step
|
// data step
|
||||||
let app = app
|
let app = app
|
||||||
.data(ws_server.clone())
|
.data(ws_server.clone())
|
||||||
.data(db_addr.clone())
|
.data(db_addr.clone())
|
||||||
.data(mail_addr.clone())
|
.data(mail_addr.clone())
|
||||||
.data(hi_addr.clone())
|
.data(hi_addr.clone())
|
||||||
.data(database_actor::build_pool());
|
.data(database_actor::build_pool());
|
||||||
featured! { app, "local-storage", app.data(fs_addr.clone()) }
|
featured! { app, "local-storage", app.data(fs_addr.clone()) };
|
||||||
;
|
|
||||||
|
|
||||||
// services step
|
// services step
|
||||||
let app = app
|
let app = app
|
||||||
.service(websocket_actor::index)
|
.service(websocket_actor::index)
|
||||||
.service(actix_web::web::scope("/avatar").service(web_actor::avatar::upload));
|
.service(actix_web::web::scope("/avatar").service(web_actor::avatar::upload));
|
||||||
|
|
||||||
featured! { app, "local-storage", app.service(filesystem_actor::service()) }
|
featured! { app, "local-storage", app.service(filesystem_actor::service()) };
|
||||||
;
|
|
||||||
app
|
app
|
||||||
})
|
})
|
||||||
.workers(web_config.concurrency)
|
.workers(web_config.concurrency)
|
||||||
|
@ -12,7 +12,7 @@ impl Default for Configuration {
|
|||||||
"postgres://postgres@localhost:5432/jirs_test".to_string()
|
"postgres://postgres@localhost:5432/jirs_test".to_string()
|
||||||
} else {
|
} else {
|
||||||
std::env::var("DATABASE_URL")
|
std::env::var("DATABASE_URL")
|
||||||
.unwrap_or_else(|_| "postgres://postgres@localhost:5432/jirs".to_string())
|
.unwrap_or_else(|_| "postgres://postgres@localhost:5432/jirs".to_string())
|
||||||
};
|
};
|
||||||
Self {
|
Self {
|
||||||
concurrency: 2,
|
concurrency: 2,
|
||||||
|
Loading…
Reference in New Issue
Block a user