Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
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
Maunium
synapse
Commits
fd40a80a
Commit
fd40a80a
authored
10 years ago
by
Mark Haines
Browse files
Options
Downloads
Patches
Plain Diff
Return 404 M_NOT_FOUND when trying to look up a room alias that doesn't exist
parent
5f19c557
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/handlers/directory.py
+24
-12
24 additions, 12 deletions
synapse/handlers/directory.py
with
24 additions
and
12 deletions
synapse/handlers/directory.py
+
24
−
12
View file @
fd40a80a
...
...
@@ -17,7 +17,7 @@
from
twisted.internet
import
defer
from
._base
import
BaseHandler
from
synapse.api.errors
import
SynapseError
from
synapse.api.errors
import
SynapseError
,
Codes
,
CodeMessageException
from
synapse.api.events.room
import
RoomAliasesEvent
import
logging
...
...
@@ -84,22 +84,32 @@ class DirectoryHandler(BaseHandler):
room_id
=
result
.
room_id
servers
=
result
.
servers
else
:
result
=
yield
self
.
federation
.
make_query
(
destination
=
room_alias
.
domain
,
query_type
=
"
directory
"
,
args
=
{
"
room_alias
"
:
room_alias
.
to_string
(),
},
retry_on_dns_fail
=
False
,
)
try
:
result
=
yield
self
.
federation
.
make_query
(
destination
=
room_alias
.
domain
,
query_type
=
"
directory
"
,
args
=
{
"
room_alias
"
:
room_alias
.
to_string
(),
},
retry_on_dns_fail
=
False
,
)
except
CodeMessageException
as
e
:
logging
.
warn
(
"
Error retrieving alias
"
)
if
e
.
code
==
404
:
result
=
None
else
:
raise
if
result
and
"
room_id
"
in
result
and
"
servers
"
in
result
:
room_id
=
result
[
"
room_id
"
]
servers
=
result
[
"
servers
"
]
if
not
room_id
:
defer
.
returnValue
({})
return
raise
SynapseError
(
404
,
"
Room alias %r not found
"
%
(
room_alias
.
to_string
(),),
Codes
.
NOT_FOUND
)
extra_servers
=
yield
self
.
store
.
get_joined_hosts_for_room
(
room_id
)
servers
=
list
(
set
(
extra_servers
)
|
set
(
servers
))
...
...
@@ -129,7 +139,9 @@ class DirectoryHandler(BaseHandler):
})
else
:
raise
SynapseError
(
404
,
"
Room alias
\"
%s
\"
not found
"
%
(
room_alias
,)
404
,
"
Room alias %r not found
"
%
(
room_alias
.
to_string
(),),
Codes
.
NOT_FOUND
)
@defer.inlineCallbacks
...
...
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