1
0
Fork 0
mirror of https://github.com/element-hq/synapse.git synced 2025-03-05 15:37:02 +00:00

Fix legacy modules check_username_for_spam (#18135)

Broke in #17916, as the signature inspection incorrectly looks at the
wrapper function. We fix this by setting the signature on the wrapper
function to that of the wrapped function via `@functools.wraps`.
This commit is contained in:
Erik Johnston 2025-02-05 13:07:49 +01:00 committed by GitHub
parent e41174cae3
commit b8a333004a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 0 deletions

1
changelog.d/18135.bugfix Normal file
View file

@ -0,0 +1 @@
Fix user directory search when using a legacy module with a `check_username_for_spam` callback. Broke in v1.122.0.

View file

@ -19,6 +19,7 @@
#
#
import functools
import inspect
import logging
from typing import (
@ -297,6 +298,7 @@ def load_legacy_spam_checkers(hs: "synapse.server.HomeServer") -> None:
"Bad signature for callback check_registration_for_spam",
)
@functools.wraps(wrapped_func)
def run(*args: Any, **kwargs: Any) -> Awaitable:
# Assertion required because mypy can't prove we won't change `f`
# back to `None`. See