1
0
This commit is contained in:
hughns
2025-06-04 11:28:06 +00:00
parent b41dd8ab8b
commit 197ac5d6f4
4 changed files with 52 additions and 2 deletions

View File

@@ -382,6 +382,31 @@ callback returns <code>synapse.module_api.NOT_SPAM</code>, Synapse falls through
The value of the first callback that does not return <code>synapse.module_api.NOT_SPAM</code> will
be used. If this happens, Synapse will not call any of the subsequent implementations of
this callback.</p>
<h3 id="user_may_send_state_event"><a class="header" href="#user_may_send_state_event"><code>user_may_send_state_event</code></a></h3>
<p><em>First introduced in Synapse v1.132.0</em></p>
<pre><code class="language-python">async def user_may_send_state_event(user_id: str, room_id: str, event_type: str, state_key: str, content: JsonDict) -&gt; Union[&quot;synapse.module_api.NOT_SPAM&quot;, &quot;synapse.module_api.errors.Codes&quot;]
</code></pre>
<p>Called when processing a request to <a href="https://spec.matrix.org/latest/client-server-api/#put_matrixclientv3roomsroomidstateeventtypestatekey">send state events</a> to a room.</p>
<p>The arguments passed to this callback are:</p>
<ul>
<li><code>user_id</code>: The Matrix user ID of the user (e.g. <code>@alice:example.com</code>) sending the state event.</li>
<li><code>room_id</code>: The ID of the room that the requested state event is being sent to.</li>
<li><code>event_type</code>: The requested type of event.</li>
<li><code>state_key</code>: The requested state key.</li>
<li><code>content</code>: The requested event contents.</li>
</ul>
<p>The callback must return one of:</p>
<ul>
<li><code>synapse.module_api.NOT_SPAM</code>, to allow the operation. Other callbacks may still
decide to reject it.</li>
<li><code>synapse.module_api.errors.Codes</code> to reject the operation with an error code. In case
of doubt, <code>synapse.module_api.errors.Codes.FORBIDDEN</code> is a good error code.</li>
</ul>
<p>If multiple modules implement this callback, they will be considered in order. If a
callback returns <code>synapse.module_api.NOT_SPAM</code>, Synapse falls through to the next one.
The value of the first callback that does not return <code>synapse.module_api.NOT_SPAM</code> will
be used. If this happens, Synapse will not call any of the subsequent implementations of
this callback.</p>
<h3 id="check_username_for_spam"><a class="header" href="#check_username_for_spam"><code>check_username_for_spam</code></a></h3>
<p><em>First introduced in Synapse v1.37.0</em></p>
<pre><code class="language-python">async def check_username_for_spam(user_profile: synapse.module_api.UserProfile, requester_id: str) -&gt; bool