From 026af6b1a60b01f877e80dba5bc36850c6c506cf Mon Sep 17 00:00:00 2001
From: Jonas Platte <jplatte+git@posteo.de>
Date: Fri, 23 Apr 2021 19:04:59 +0200
Subject: [PATCH] Improve formatting of ruma_wrapper.rs

---
 src/ruma_wrapper.rs | 37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/src/ruma_wrapper.rs b/src/ruma_wrapper.rs
index 4ac7d7104..7777e1202 100644
--- a/src/ruma_wrapper.rs
+++ b/src/ruma_wrapper.rs
@@ -34,7 +34,8 @@ pub struct Ruma<T: Outgoing> {
     pub body: T::Incoming,
     pub sender_user: Option<UserId>,
     pub sender_device: Option<Box<DeviceId>>,
-    pub json_body: Option<Box<serde_json::value::RawValue>>, // This is None when body is not a valid string
+    // This is None when body is not a valid string
+    pub json_body: Option<Box<serde_json::value::RawValue>>,
     pub from_appservice: bool,
 }
 
@@ -124,22 +125,24 @@ async fn from_data(request: &'a Request<'_>, data: Data) -> data::Outcome<Self,
                 }
                 AuthScheme::ServerSignatures => {
                     // Get origin from header
-                    let x_matrix = match request
-                            .headers()
-                            .get_one("Authorization")
-                            .map(|s| {
-                                s[9..]
-                                    .split_terminator(',').map(|field| {let mut splits = field.splitn(2, '='); (splits.next(), splits.next().map(|s| s.trim_matches('"')))}).collect::<BTreeMap<_, _>>()
-                            }) // Split off "X-Matrix " and parse the rest
-                        {
-                            Some(t) => t,
-                            None => {
-                                warn!("No Authorization header");
-
-                                // Forbidden
-                                return Failure((Status::raw(580), ()));
-                            }
-                        };
+                    let x_matrix = match request.headers().get_one("Authorization").map(|s| {
+                        // Split off "X-Matrix " and parse the rest
+                        s[9..]
+                            .split_terminator(',')
+                            .map(|field| {
+                                let mut splits = field.splitn(2, '=');
+                                (splits.next(), splits.next().map(|s| s.trim_matches('"')))
+                            })
+                            .collect::<BTreeMap<_, _>>()
+                    }) {
+                        Some(t) => t,
+                        None => {
+                            warn!("No Authorization header");
+
+                            // Forbidden
+                            return Failure((Status::raw(580), ()));
+                        }
+                    };
 
                     let origin_str = match x_matrix.get(&Some("origin")) {
                         Some(Some(o)) => *o,
-- 
GitLab