Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
conduwuit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
🥺
conduwuit
Commits
a0fa0ee7
Unverified
Commit
a0fa0ee7
authored
4 years ago
by
Timo Kösters
Browse files
Options
Downloads
Patches
Plain Diff
fix: join appservice room with alias
parent
a77fcd10
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/client_server/alias.rs
+16
-4
16 additions, 4 deletions
src/client_server/alias.rs
src/database/rooms.rs
+16
-8
16 additions, 8 deletions
src/database/rooms.rs
with
32 additions
and
12 deletions
src/client_server/alias.rs
+
16
−
4
View file @
a0fa0ee7
...
@@ -90,11 +90,23 @@ pub async fn get_alias_helper(
...
@@ -90,11 +90,23 @@ pub async fn get_alias_helper(
let
aliases
=
registration
let
aliases
=
registration
.get
(
"namespaces"
)
.get
(
"namespaces"
)
.and_then
(|
ns
|
ns
.get
(
"aliases"
))
.and_then
(|
ns
|
ns
.get
(
"aliases"
))
.and_then
(|
users
|
users
.get
(
"regex"
))
.and_then
(|
aliases
|
aliases
.as_sequence
())
.and_then
(|
regex
|
regex
.as_str
())
.map_or_else
(
Vec
::
new
,
|
aliases
|
{
.and_then
(|
regex
|
Regex
::
new
(
regex
)
.ok
());
aliases
.iter
()
.map
(|
aliases
|
{
aliases
.get
(
"regex"
)
.and_then
(|
regex
|
regex
.as_str
())
.and_then
(|
regex
|
Regex
::
new
(
regex
)
.ok
())
})
.filter_map
(|
o
|
o
)
.collect
::
<
Vec
<
_
>>
()
});
if
aliases
.map_or
(
false
,
|
aliases
|
aliases
.is_match
(
room_alias
.as_str
()))
if
aliases
.iter
()
.any
(|
aliases
|
aliases
.is_match
(
room_alias
.as_str
()))
&&
db
&&
db
.sending
.sending
.send_appservice_request
(
.send_appservice_request
(
...
...
This diff is collapsed.
Click to expand it.
src/database/rooms.rs
+
16
−
8
View file @
a0fa0ee7
...
@@ -1142,15 +1142,23 @@ pub fn build_and_append_pdu(
...
@@ -1142,15 +1142,23 @@ pub fn build_and_append_pdu(
});
});
let
aliases
=
namespaces
let
aliases
=
namespaces
.get
(
"aliases"
)
.get
(
"aliases"
)
.and_then
(|
users
|
users
.get
(
"regex"
))
.and_then
(|
aliases
|
aliases
.as_sequence
())
.and_then
(|
regex
|
regex
.as_str
())
.map_or_else
(
Vec
::
new
,
|
aliases
|
{
.and_then
(|
regex
|
Regex
::
new
(
regex
)
.ok
());
aliases
.iter
()
.map
(|
aliases
|
{
aliases
.get
(
"regex"
)
.and_then
(|
regex
|
regex
.as_str
())
.and_then
(|
regex
|
Regex
::
new
(
regex
)
.ok
())
})
.filter_map
(|
o
|
o
)
.collect
::
<
Vec
<
_
>>
()
});
let
rooms
=
namespaces
let
rooms
=
namespaces
.get
(
"rooms"
)
.get
(
"rooms"
)
.and_then
(|
rooms
|
rooms
.as_sequence
());
.and_then
(|
rooms
|
rooms
.as_sequence
());
let
room_aliases
=
self
.room_aliases
(
&
room_id
);
let
bridge_user_id
=
appservice
let
bridge_user_id
=
appservice
.1
.1
.get
(
"sender_localpart"
)
.get
(
"sender_localpart"
)
...
@@ -1170,15 +1178,15 @@ pub fn build_and_append_pdu(
...
@@ -1170,15 +1178,15 @@ pub fn build_and_append_pdu(
.as_ref
()
.as_ref
()
.map_or
(
false
,
|
state_key
|
users
.is_match
(
&
state_key
))
.map_or
(
false
,
|
state_key
|
users
.is_match
(
&
state_key
))
};
};
let
matching_aliases
=
|
aliases
:
Regex
|
{
let
matching_aliases
=
|
aliases
:
&
Regex
|
{
room_aliases
self
.
room_aliases
(
&
room_id
)
.filter_map
(|
r
|
r
.ok
())
.filter_map
(|
r
|
r
.ok
())
.any
(|
room_alias
|
aliases
.is_match
(
room_alias
.as_str
()))
.any
(|
room_alias
|
aliases
.is_match
(
room_alias
.as_str
()))
};
};
if
bridge_user_id
.map_or
(
false
,
user_is_joined
)
if
bridge_user_id
.map_or
(
false
,
user_is_joined
)
||
users
.iter
()
.any
(
matching_users
)
||
users
.iter
()
.any
(
matching_users
)
||
aliases
.
map_or
(
false
,
matching_aliases
)
||
aliases
.
iter
()
.any
(
matching_aliases
)
||
rooms
.map_or
(
false
,
|
rooms
|
rooms
.contains
(
&
room_id
.as_str
()
.into
()))
||
rooms
.map_or
(
false
,
|
rooms
|
rooms
.contains
(
&
room_id
.as_str
()
.into
()))
{
{
db
.sending
.send_pdu_appservice
(
&
appservice
.0
,
&
pdu_id
)
?
;
db
.sending
.send_pdu_appservice
(
&
appservice
.0
,
&
pdu_id
)
?
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment