Merge branch 'as-fix' into 'master'
fix: don't always query aliases of appservices See merge request famedly/conduit!29next
commit
1a940b6e05
|
@ -1,5 +1,6 @@
|
||||||
use super::State;
|
use super::State;
|
||||||
use crate::{ConduitResult, Database, Error, Ruma};
|
use crate::{ConduitResult, Database, Error, Ruma};
|
||||||
|
use regex::Regex;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::{
|
api::{
|
||||||
appservice,
|
appservice,
|
||||||
|
@ -86,15 +87,23 @@ pub async fn get_alias_helper(
|
||||||
Some(r) => room_id = Some(r),
|
Some(r) => room_id = Some(r),
|
||||||
None => {
|
None => {
|
||||||
for (_id, registration) in db.appservice.iter_all().filter_map(|r| r.ok()) {
|
for (_id, registration) in db.appservice.iter_all().filter_map(|r| r.ok()) {
|
||||||
if db
|
let aliases = registration
|
||||||
.sending
|
.get("namespaces")
|
||||||
.send_appservice_request(
|
.and_then(|ns| ns.get("aliases"))
|
||||||
&db.globals,
|
.and_then(|users| users.get("regex"))
|
||||||
registration,
|
.and_then(|regex| regex.as_str())
|
||||||
appservice::query::query_room_alias::v1::Request { room_alias },
|
.and_then(|regex| Regex::new(regex).ok());
|
||||||
)
|
|
||||||
.await
|
if aliases.map_or(false, |aliases| aliases.is_match(room_alias.as_str()))
|
||||||
.is_ok()
|
&& db
|
||||||
|
.sending
|
||||||
|
.send_appservice_request(
|
||||||
|
&db.globals,
|
||||||
|
registration,
|
||||||
|
appservice::query::query_room_alias::v1::Request { room_alias },
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.is_ok()
|
||||||
{
|
{
|
||||||
room_id = Some(db.rooms.id_from_alias(&room_alias)?.ok_or_else(|| {
|
room_id = Some(db.rooms.id_from_alias(&room_alias)?.ok_or_else(|| {
|
||||||
Error::bad_config("Appservice lied to us. Room does not exist.")
|
Error::bad_config("Appservice lied to us. Room does not exist.")
|
||||||
|
|
Loading…
Reference in New Issue