Skip to content

Commit

Permalink
Fix legacy modules check_username_for_spam (#18135)
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
erikjohnston authored Feb 5, 2025
1 parent e41174c commit b8a3330
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/18135.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix user directory search when using a legacy module with a `check_username_for_spam` callback. Broke in v1.122.0.
2 changes: 2 additions & 0 deletions synapse/module_api/callbacks/spamchecker_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#
#

import functools
import inspect
import logging
from typing import (
Expand Down Expand Up @@ -297,6 +298,7 @@ def wrapper(
"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
Expand Down

0 comments on commit b8a3330

Please sign in to comment.