Skip to content

Commit

Permalink
fix: update msc number
Browse files Browse the repository at this point in the history
  • Loading branch information
hanadi92 committed May 8, 2024
1 parent 7021a21 commit 8c9aa73
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion changelog.d/16858.feature
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Experimental support for [MSC3767](https://github.com/matrix-org/matrix-spec-proposals/pull/3767): the `time_and_day` push rule condition. Contributed by @hanadi92.
Experimental support for [MSC4141](https://github.com/matrix-org/matrix-spec-proposals/pull/3767): the `time_and_day` push rule condition. Contributed by @hanadi92.
12 changes: 6 additions & 6 deletions rust/src/push/evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ pub struct PushRuleEvaluator {
/// flag as MSC1767 (extensible events core).
msc3931_enabled: bool,

/// If MSC3767 (time based notification filtering push rule condition) is enabled
msc3767_time_and_day: bool,
/// If MSC4141 (time based notification filtering push rule condition) is enabled
msc4141_time_and_day: bool,
}

#[pymethods]
Expand All @@ -126,7 +126,7 @@ impl PushRuleEvaluator {
related_event_match_enabled,
room_version_feature_flags,
msc3931_enabled,
msc3767_time_and_day,
msc4141_time_and_day,
))]
pub fn py_new(
flattened_keys: BTreeMap<String, JsonValue>,
Expand All @@ -138,7 +138,7 @@ impl PushRuleEvaluator {
related_event_match_enabled: bool,
room_version_feature_flags: Vec<String>,
msc3931_enabled: bool,
msc3767_time_and_day: bool,
msc4141_time_and_day: bool,
) -> Result<Self, Error> {
let body = match flattened_keys.get("content.body") {
Some(JsonValue::Value(SimpleJsonValue::Str(s))) => s.clone().into_owned(),
Expand All @@ -156,7 +156,7 @@ impl PushRuleEvaluator {
related_event_match_enabled,
room_version_feature_flags,
msc3931_enabled,
msc3767_time_and_day,
msc4141_time_and_day,
})
}

Expand Down Expand Up @@ -392,7 +392,7 @@ impl PushRuleEvaluator {
}
}
KnownCondition::TimeAndDay(time_and_day) => {
if !self.msc3767_time_and_day {
if !self.msc4141_time_and_day {
false
} else {
self.match_time_and_day(time_and_day.timezone, &time_and_day.intervals)?
Expand Down
4 changes: 2 additions & 2 deletions rust/src/push/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ pub enum KnownCondition {
RoomVersionSupports {
feature: Cow<'static, str>,
},
#[serde(rename = "org.matrix.msc3767.time_and_day")]
#[serde(rename = "org.matrix.msc4141.time_and_day")]
TimeAndDay(TimeAndDayCondition),
}

Expand Down Expand Up @@ -455,7 +455,7 @@ pub struct TimeAndDayCondition {
pub struct TimeAndDayIntervals {
/// Tuple of hh::mm representing start and end times of the day
pub time_of_day: Option<TimeInterval>,
/// 0 = Sunday, 1 = Monday, ..., 7 = Sunday
/// 0 = Sunday, 1 = Monday, ..., 6 = Saturday
pub day_of_week: Vec<u32>,
}

Expand Down
6 changes: 3 additions & 3 deletions synapse/config/experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None:
"msc4115_membership_on_events", False
)

# MSC3767: time based notification filtering
self.msc3767_time_and_day = experimental.get(
"org.matrix.msc3767.time_and_day", False
# MSC4141: time based notification filtering
self.msc4141_time_and_day = experimental.get(
"org.matrix.msc4141.time_and_day", False
)
2 changes: 1 addition & 1 deletion synapse/push/bulk_push_rule_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ async def _action_for_event_by_user(
self._related_event_match_enabled,
event.room_version.msc3931_push_features,
self.hs.config.experimental.msc1767_enabled, # MSC3931 flag
self.hs.config.experimental.msc3767_time_and_day,
self.hs.config.experimental.msc4141_time_and_day,
)

for uid, rules in rules_by_user.items():
Expand Down
2 changes: 1 addition & 1 deletion synapse/synapse_rust/push.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class PushRuleEvaluator:
related_event_match_enabled: bool,
room_version_feature_flags: Tuple[str, ...],
msc3931_enabled: bool,
msc3767_time_and_day: bool,
msc4141_time_and_day: bool,
): ...
def run(
self,
Expand Down
4 changes: 2 additions & 2 deletions tests/push/test_push_rule_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def _get_evaluator(
related_event_match_enabled=True,
room_version_feature_flags=event.room_version.msc3931_push_features,
msc3931_enabled=True,
msc3767_time_and_day=True,
msc4141_time_and_day=True,
)

def test_display_name(self) -> None:
Expand Down Expand Up @@ -806,7 +806,7 @@ def test_related_event_match_no_related_event(self) -> None:
def test_time_and_day_match(self) -> None:
# for testing, make whole day in do not disturb
condition = {
"kind": "org.matrix.msc3767.time_and_day",
"kind": "org.matrix.msc4141.time_and_day",
"timezone": None,
"intervals": [
{
Expand Down

0 comments on commit 8c9aa73

Please sign in to comment.