-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branches 'quenting/rust-1.66.0', 'quenting/rust-twisted-http' a…
…nd 'quenting/msc4108-delegation' into quenting/merge
- Loading branch information
Showing
12 changed files
with
402 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add helpers to transform Twisted requests to Rust http Requests/Responses. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Support delegating the rendezvous mechanism described MSC4108 to an external implementation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* This file is licensed under the Affero General Public License (AGPL) version 3. | ||
* | ||
* Copyright (C) 2024 New Vector, Ltd | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* See the GNU Affero General Public License for more details: | ||
* <https://www.gnu.org/licenses/agpl-3.0.html>. | ||
*/ | ||
|
||
#![allow(clippy::new_ret_no_self)] | ||
|
||
use std::collections::HashMap; | ||
|
||
use http::{HeaderMap, StatusCode}; | ||
use pyo3::import_exception; | ||
|
||
import_exception!(synapse.api.errors, SynapseError); | ||
|
||
impl SynapseError { | ||
pub fn new( | ||
code: StatusCode, | ||
message: String, | ||
errcode: &'static str, | ||
additional_fields: Option<HashMap<String, String>>, | ||
headers: Option<HeaderMap>, | ||
) -> pyo3::PyErr { | ||
// Transform the HeaderMap into a HashMap<String, String> | ||
let headers = headers.map(|headers| { | ||
headers | ||
.iter() | ||
.map(|(key, value)| { | ||
( | ||
key.as_str().to_owned(), | ||
value | ||
.to_str() | ||
// XXX: will that ever panic? | ||
.expect("header value is valid ASCII") | ||
.to_owned(), | ||
) | ||
}) | ||
.collect::<HashMap<String, String>>() | ||
}); | ||
|
||
SynapseError::new_err((code.as_u16(), message, errcode, additional_fields, headers)) | ||
} | ||
} | ||
|
||
import_exception!(synapse.api.errors, NotFoundError); | ||
|
||
impl NotFoundError { | ||
pub fn new() -> pyo3::PyErr { | ||
NotFoundError::new_err(()) | ||
} | ||
} |
Oops, something went wrong.