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
2ee302d0
Commit
2ee302d0
authored
4 years ago
by
Richard van der Hoff
Browse files
Options
Downloads
Patches
Plain Diff
Move shadow-ban check down into `handle_new_client_event`.
parent
b520a1bf
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/message.py
+24
-8
24 additions, 8 deletions
synapse/handlers/message.py
with
24 additions
and
8 deletions
synapse/handlers/message.py
+
24
−
8
View file @
2ee302d0
...
@@ -657,25 +657,23 @@ class EventCreationHandler:
...
@@ -657,25 +657,23 @@ class EventCreationHandler:
Return:
Return:
The stream_id of the persisted event.
The stream_id of the persisted event.
Raises:
ShadowBanError if the requester has been shadow-banned.
"""
"""
if
event
.
type
==
EventTypes
.
Member
:
if
event
.
type
==
EventTypes
.
Member
:
raise
SynapseError
(
raise
SynapseError
(
500
,
"
Tried to send member event through non-member codepath
"
500
,
"
Tried to send member event through non-member codepath
"
)
)
if
not
ignore_shadow_ban
and
requester
.
shadow_banned
:
# We randomly sleep a bit just to annoy the requester.
await
self
.
clock
.
sleep
(
random
.
randint
(
1
,
10
))
raise
ShadowBanError
()
user
=
UserID
.
from_string
(
event
.
sender
)
user
=
UserID
.
from_string
(
event
.
sender
)
assert
self
.
hs
.
is_mine
(
user
),
"
User must be our own: %s
"
%
(
user
,)
assert
self
.
hs
.
is_mine
(
user
),
"
User must be our own: %s
"
%
(
user
,)
ev
=
await
self
.
handle_new_client_event
(
ev
=
await
self
.
handle_new_client_event
(
requester
=
requester
,
event
=
event
,
context
=
context
,
ratelimit
=
ratelimit
requester
=
requester
,
event
=
event
,
context
=
context
,
ratelimit
=
ratelimit
,
ignore_shadow_ban
=
ignore_shadow_ban
,
)
)
# we know it was persisted, so must have a stream ordering
# we know it was persisted, so must have a stream ordering
...
@@ -837,6 +835,7 @@ class EventCreationHandler:
...
@@ -837,6 +835,7 @@ class EventCreationHandler:
context
:
EventContext
,
context
:
EventContext
,
ratelimit
:
bool
=
True
,
ratelimit
:
bool
=
True
,
extra_users
:
List
[
UserID
]
=
[],
extra_users
:
List
[
UserID
]
=
[],
ignore_shadow_ban
:
bool
=
False
,
)
->
EventBase
:
)
->
EventBase
:
"""
Processes a new event.
"""
Processes a new event.
...
@@ -853,11 +852,28 @@ class EventCreationHandler:
...
@@ -853,11 +852,28 @@ class EventCreationHandler:
ratelimit
ratelimit
extra_users: Any extra users to notify about event
extra_users: Any extra users to notify about event
ignore_shadow_ban: True if shadow-banned users should be allowed to
send this event.
Return:
Return:
If the event was deduplicated, the previous, duplicate, event. Otherwise,
If the event was deduplicated, the previous, duplicate, event. Otherwise,
`event`.
`event`.
Raises:
ShadowBanError if the requester has been shadow-banned.
"""
"""
# we don't apply shadow-banning to membership events, so that the user
# can come and go as they want.
if
(
event
.
type
!=
EventTypes
.
Member
and
not
ignore_shadow_ban
and
requester
.
shadow_banned
):
# We randomly sleep a bit just to annoy the requester.
await
self
.
clock
.
sleep
(
random
.
randint
(
1
,
10
))
raise
ShadowBanError
()
if
event
.
is_state
():
if
event
.
is_state
():
prev_event
=
await
self
.
deduplicate_state_event
(
event
,
context
)
prev_event
=
await
self
.
deduplicate_state_event
(
event
,
context
)
if
prev_event
is
not
None
:
if
prev_event
is
not
None
:
...
...
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