Skip to content

Commit

Permalink
refactor: rustfmt [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
pyro-kitchen committed Apr 21, 2024
1 parent 065d859 commit af06d9f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
1 change: 0 additions & 1 deletion crates/alerion_core/src/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ pub async fn setup_directories() -> anyhow::Result<ProjectDirs> {

Ok(project_dirs)
}

1 change: 0 additions & 1 deletion crates/alerion_core/src/websocket/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ impl Permissions {
this.insert(Permissions::RESTART);
this.insert(Permissions::CONSOLE);
this.insert(Permissions::BACKUP_READ);

}
"websocket.connect" => {
this.insert(Permissions::CONNECT);
Expand Down
18 changes: 12 additions & 6 deletions crates/alerion_core/src/websocket/conn.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::convert::Infallible;
use std::cell::Cell;
use std::convert::Infallible;

use actix::{Actor, ActorContext, Addr, Handler, StreamHandler};
use actix_web_actors::ws;
Expand Down Expand Up @@ -109,7 +109,9 @@ impl WebsocketConnectionImpl {

match event.event() {
EventType::Authentication => {
let maybe_permissions = self.auth.validate(&event.into_first_arg()?, &self.server_uuid);
let maybe_permissions = self
.auth
.validate(&event.into_first_arg()?, &self.server_uuid);

if let Some(permissions) = maybe_permissions {
if permissions.contains(Permissions::CONNECT) {
Expand All @@ -132,11 +134,11 @@ impl WebsocketConnectionImpl {
EventType::SendCommand => {
if permissions.contains(Permissions::CONSOLE) {
if let Some(command) = event.into_first_arg() {
self.server_conn.send_if_authenticated(PanelMessage::Command(command));
self.server_conn
.send_if_authenticated(PanelMessage::Command(command));
} else {
self.send_error(ctx, MessageError::InvalidJwt);
}

}
}

Expand All @@ -149,7 +151,8 @@ impl WebsocketConnectionImpl {

EventType::SendLogs => {
if permissions.contains(Permissions::CONSOLE) {
self.server_conn.send_if_authenticated(PanelMessage::ReceiveLogs);
self.server_conn
.send_if_authenticated(PanelMessage::ReceiveLogs);

if permissions.contains(Permissions::ADMIN_INSTALL) {
self.server_conn.force_send(PanelMessage::ReceiveInstallLog);
Expand All @@ -176,7 +179,10 @@ impl WebsocketConnectionImpl {
MessageError::Generic(s) => RawMessage::new(EventType::DaemonError, s),
}
} else {
RawMessage::new(EventType::DaemonError, "An unexpected error occurred".to_owned())
RawMessage::new(
EventType::DaemonError,
"An unexpected error occurred".to_owned(),
)
};

ctx.text(raw_msg)
Expand Down

0 comments on commit af06d9f

Please sign in to comment.