fix(appservices): don't panic on empty registration url
perf(appservices): cache regex for namespaces
This commit is contained in:
		
							parent
							
								
									a095e02d04
								
							
						
					
					
						commit
						fa930182ae
					
				
					 15 changed files with 335 additions and 244 deletions
				
			
		|  | @ -81,12 +81,9 @@ where | |||
|         let mut json_body = serde_json::from_slice::<CanonicalJsonValue>(&body).ok(); | ||||
| 
 | ||||
|         let appservices = services().appservice.all().unwrap(); | ||||
|         let appservice_registration = appservices.iter().find(|(_id, registration)| { | ||||
|             registration | ||||
|                 .get("as_token") | ||||
|                 .and_then(|as_token| as_token.as_str()) | ||||
|                 .map_or(false, |as_token| token == Some(as_token)) | ||||
|         }); | ||||
|         let appservice_registration = appservices | ||||
|             .iter() | ||||
|             .find(|(_id, registration)| Some(registration.as_token.as_str()) == token); | ||||
| 
 | ||||
|         let (sender_user, sender_device, sender_servername, from_appservice) = | ||||
|             if let Some((_id, registration)) = appservice_registration { | ||||
|  | @ -95,11 +92,7 @@ where | |||
|                         let user_id = query_params.user_id.map_or_else( | ||||
|                             || { | ||||
|                                 UserId::parse_with_server_name( | ||||
|                                     registration | ||||
|                                         .get("sender_localpart") | ||||
|                                         .unwrap() | ||||
|                                         .as_str() | ||||
|                                         .unwrap(), | ||||
|                                     registration.sender_localpart.as_str(), | ||||
|                                     services().globals.server_name(), | ||||
|                                 ) | ||||
|                                 .unwrap() | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Matthias Ahouansou
						Matthias Ahouansou