fix: don't always query aliases of appservices
only do so if the alias matches the regex in the registration file
This commit is contained in:
parent
1a198e7336
commit
f2ec2be821
1 changed files with 18 additions and 9 deletions
|
@ -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,7 +87,15 @@ 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
|
||||||
|
.get("namespaces")
|
||||||
|
.and_then(|ns| ns.get("aliases"))
|
||||||
|
.and_then(|users| users.get("regex"))
|
||||||
|
.and_then(|regex| regex.as_str())
|
||||||
|
.and_then(|regex| Regex::new(regex).ok());
|
||||||
|
|
||||||
|
if aliases.map_or(false, |aliases| aliases.is_match(room_alias.as_str()))
|
||||||
|
&& db
|
||||||
.sending
|
.sending
|
||||||
.send_appservice_request(
|
.send_appservice_request(
|
||||||
&db.globals,
|
&db.globals,
|
||||||
|
|
Loading…
Add table
Reference in a new issue