-
Notifications
You must be signed in to change notification settings - Fork 354
Allow admins to see policy server-flagged events #18585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,51 @@ | |||
# Client-Server API Extensions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed in the #synapse-dev:matrix.org
room
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The term "spammy" doesn't feel like a real term to me... Can we just say "marked as spam"?
If you were looking for a short field name, policy_server_spam
seems fine.
e343076
to
32d605f
Compare
sorry for the force push: I thought I set this PR up for a clean merge of develop->PR, but forgot all of the important steps. |
"spammy" comes from the detail that the policy server doesn't technically get final say on whether the event is spam or not, despite that being the current implementation. It's also used in other places throughout the codebase, especially around the existing spam checker interfaces. I'd prefer to keep it as an invented word, but can change it if needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more iteration.
Could you also add some unit tests for this new field please?
|
||
if account_data: | ||
self.return_soft_failed_events = account_data.get( | ||
"return_soft_failed_events", False | ||
) | ||
self.return_policy_server_spammy_events = account_data.get( | ||
"return_policy_server_spammy_events", False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To match the docs:
"return_policy_server_spammy_events", False | |
"return_policy_server_spammy_events", self.return_soft_failed_events |
@@ -120,10 +120,26 @@ async def filter_events_for_client( | |||
client_config = await storage.main.get_admin_client_config_for_user(user_id) | |||
if not ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this not
supposed to be here?
or e.internal_metadata.policy_server_spammy | ||
] | ||
else: | ||
events = [e for e in events if not e.internal_metadata.is_soft_failed()] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic here is currently quite difficult (for me) to follow. I'd find this easier to read as:
if (
filter_send_to_client
and await storage.main.is_server_admin(UserID.from_string(user_id))
):
if client_config.return_soft_failed_events:
# Include events that were soft-failed by any means.
# `events` does not need to be modified in this case.
else if (
not client_config.return_soft_failed_events
and client_config.return_policy_server_spammy_events
):
# Include events that were only soft-failed by a policy server.
# Events that were soft-failed by other means are excluded.
events = [
e
for e in events
# Return non-soft-failed events as well as those explicitly marked
# as spam by a policy server. This excludes events that were soft
# failed by other means.
if not e.internal_metadata.is_soft_failed()
or e.internal_metadata.policy_server_spammy
]
else if (
not client_config.return_soft_failed_events
and not client_config.return_policy_server_spammy_events
):
# Only include non-soft-failed events.
events = [e for e in events if not e.internal_metadata.is_soft_failed()]
Requires #18238Merged!Real diff: 881d521...travis/flag-ps-eventsPull Request Checklist
EventStore
toEventWorkerStore
.".code blocks
.