mirror of
https://github.com/element-hq/synapse.git
synced 2026-03-31 01:55:43 +00:00
Introduce internal_metadata for spam_checker_spammy
This commit is contained in:
@@ -55,6 +55,7 @@ enum EventInternalMetadataData {
|
||||
SoftFailed(bool),
|
||||
ProactivelySend(bool),
|
||||
PolicyServerSpammy(bool),
|
||||
SpamCheckerSpammy(bool),
|
||||
Redacted(bool),
|
||||
TxnId(Box<str>),
|
||||
TokenId(i64),
|
||||
@@ -104,6 +105,13 @@ impl EventInternalMetadataData {
|
||||
.to_owned()
|
||||
.into_any(),
|
||||
),
|
||||
EventInternalMetadataData::SpamCheckerSpammy(o) => (
|
||||
pyo3::intern!(py, "spam_checker_spammy"),
|
||||
o.into_pyobject(py)
|
||||
.unwrap_infallible()
|
||||
.to_owned()
|
||||
.into_any(),
|
||||
),
|
||||
EventInternalMetadataData::Redacted(o) => (
|
||||
pyo3::intern!(py, "redacted"),
|
||||
o.into_pyobject(py)
|
||||
@@ -168,6 +176,11 @@ impl EventInternalMetadataData {
|
||||
.extract()
|
||||
.with_context(|| format!("'{key_str}' has invalid type"))?,
|
||||
),
|
||||
"spam_checker_spammy" => EventInternalMetadataData::SpamCheckerSpammy(
|
||||
value
|
||||
.extract()
|
||||
.with_context(|| format!("'{key_str}' has invalid type"))?,
|
||||
),
|
||||
"redacted" => EventInternalMetadataData::Redacted(
|
||||
value
|
||||
.extract()
|
||||
@@ -451,6 +464,17 @@ impl EventInternalMetadata {
|
||||
set_property!(self, PolicyServerSpammy, obj);
|
||||
}
|
||||
|
||||
#[getter]
|
||||
fn get_spam_checker_spammy(&self) -> PyResult<bool> {
|
||||
Ok(get_property_opt!(self, SpamCheckerSpammy)
|
||||
.copied()
|
||||
.unwrap_or(false))
|
||||
}
|
||||
#[setter]
|
||||
fn set_spam_checker_spammy(&mut self, obj: bool) {
|
||||
set_property!(self, SpamCheckerSpammy, obj);
|
||||
}
|
||||
|
||||
#[getter]
|
||||
fn get_redacted(&self) -> PyResult<bool> {
|
||||
let bool = get_property!(self, Redacted)?;
|
||||
|
||||
@@ -36,6 +36,19 @@ class EventInternalMetadata:
|
||||
policy_server_spammy: bool
|
||||
"""whether the policy server indicated that this event is spammy"""
|
||||
|
||||
spam_checker_spammy: bool
|
||||
"""Whether a spam checker module indicated that this event is spammy
|
||||
|
||||
Note that spam checkers also cause the event to be marked as soft-failed.
|
||||
|
||||
This flags exists for two reasons:
|
||||
1. as debugging information
|
||||
2. to prevent the soft-failed re-evaluation of spammy events
|
||||
(the re-evaluation behaviour originates from MSC4354 Sticky Events)
|
||||
|
||||
Note that historical spammy events won't have this flag.
|
||||
"""
|
||||
|
||||
txn_id: str
|
||||
"""The transaction ID, if it was set when the event was created."""
|
||||
token_id: int
|
||||
|
||||
Reference in New Issue
Block a user