Compare commits

..
9 changed files with 13 additions and 84 deletions

No files matched your search

+1 -1
View File
@@ -24,7 +24,7 @@ repos:
- id: check-added-large-files
- repo: https://github.com/crate-ci/typos
rev: v1.53.0
rev: v1.52.2
hooks:
- id: typos
- id: typos
Generated
+1 -1
View File
@@ -4052,7 +4052,7 @@ dependencies = [
[[package]]
name = "opentelemetry-instrumentation-tower"
version = "0.19.0"
source = "git+https://github.com/open-telemetry/opentelemetry-rust-contrib?rev=08495866132a3fafbb62158b8eafbd42983e5a0b#08495866132a3fafbb62158b8eafbd42983e5a0b"
source = "git+https://github.com/open-telemetry/opentelemetry-rust-contrib?rev=e2b0440e6c03b5b17a5cfb5e64adf34496c1e4a5#e2b0440e6c03b5b17a5cfb5e64adf34496c1e4a5"
dependencies = [
"axum",
"http",
+1 -2
View File
@@ -398,7 +398,6 @@ features = [
"unstable-msc4484",
"unstable-msc4540",
"unstable-msc4560",
"unstable-msc4563",
"unstable-extensible-events",
]
@@ -433,7 +432,7 @@ version = "0.33.1"
[workspace.dependencies.opentelemetry-instrumentation-tower]
git = "https://github.com/open-telemetry/opentelemetry-rust-contrib"
rev = "08495866132a3fafbb62158b8eafbd42983e5a0b"
rev = "e2b0440e6c03b5b17a5cfb5e64adf34496c1e4a5"
default-features = false
features = ["axum"]
-1
View File
@@ -1 +0,0 @@
Added server-side support for [MSC4563: direct_message push rule](https://github.com/matrix-org/matrix-spec-proposals/pull/4563). Contributed by @nex.
-1
View File
@@ -1 +0,0 @@
Errors while sending push notifications will now appear in the server log under more conditions, and will be registered as failures in Prometheus metrics.
-12
View File
@@ -2808,18 +2808,6 @@
# env: CONTINUWUITY_EXPERIMENTS__MSC4560
#msc4560 = false
# MSC4563: `direct_message` push rule
#
# Creates a new kind of push rule that creates a notification if a message
# is received in a room that is in the user's direct message list. This
# more accurately identifies direct messages, rather than relying on a "DM
# room" only consisting of two members.
#
# https://github.com/matrix-org/matrix-spec-proposals/pull/4563
#
# env: CONTINUWUITY_EXPERIMENTS__MSC4563
#msc4563 = false
#[global.experiments.msc2815]
# MSC2815: Proposal to allow room moderators to view redacted event content
#
-13
View File
@@ -146,19 +146,6 @@ pub struct Experiments {
/// default: false
#[serde(default)]
pub msc4560: SimpleExperiment,
/// MSC4563: `direct_message` push rule
///
/// Creates a new kind of push rule that creates a notification if a message
/// is received in a room that is in the user's direct message list. This
/// more accurately identifies direct messages, rather than relying on a "DM
/// room" only consisting of two members.
///
/// https://github.com/matrix-org/matrix-spec-proposals/pull/4563
///
/// default: false
#[serde(default)]
pub msc4563: SimpleExperiment,
}
/// Represents a "simple" experiment, which is either disabled or enabled.
+7 -36
View File
@@ -2,7 +2,6 @@ mod webpush;
use std::{fmt::Debug, mem, net::IpAddr, sync::Arc};
use assign::assign;
use bytes::BytesMut;
use conduwuit::{config::experiments::ToggledExperiment, utils::response::LimitReadExt};
use conduwuit_core::{
@@ -24,10 +23,7 @@ use ruma::{
v1::{Device, Notification, NotificationCounts, NotificationPriority},
},
},
events::{
AnySyncTimelineEvent, GlobalAccountDataEvent, GlobalAccountDataEventType,
TimelineEventType, direct::DirectEventContent, room::power_levels::RoomPowerLevels,
},
events::{AnySyncTimelineEvent, TimelineEventType, room::power_levels::RoomPowerLevels},
push::{
Action, HighlightTweakValue, PushConditionPowerLevelsCtx, PushConditionRoomCtx,
PushFormat, Ruleset, Tweak,
@@ -40,7 +36,7 @@ use url::Host;
pub use self::webpush::ActivationOutcome;
use self::webpush::Vapid;
use crate::{Dep, account_data, client, config, globals, rooms, sending, users};
use crate::{Dep, client, config, globals, rooms, sending, users};
const PUSH_GATEWAY_SCHEMES: &[&str] = &["http", "https"];
const WEBPUSH_SCHEMES: &[&str] = &["https"];
@@ -61,7 +57,6 @@ pub struct Service {
struct Services {
server: Arc<Server>,
globals: Dep<globals::Service>,
account_data: Dep<account_data::Service>,
config: Dep<config::Service>,
client: Dep<client::Service>,
state_accessor: Dep<rooms::state_accessor::Service>,
@@ -91,7 +86,6 @@ impl crate::Service for Service {
services: Services {
server: args.server.clone(),
globals: args.depend::<globals::Service>("globals"),
account_data: args.depend::<account_data::Service>("account_data"),
client: args.depend::<client::Service>("client"),
config: args.depend::<config::Service>("config"),
state_accessor: args
@@ -494,34 +488,11 @@ impl Service {
.await
.unwrap_or_else(|_| user.localpart().to_owned());
let is_direct = self.services.config.experiments.msc4563.is_enabled()
&& self
.services
.account_data
.get_global::<GlobalAccountDataEvent<DirectEventContent>>(
user,
GlobalAccountDataEventType::Direct,
)
.await
.ok()
.and_then(|direct| {
direct
.content
.values()
.flatten()
.any(|dm_room_id| dm_room_id == room_id)
.then_some(())
})
.is_some();
assign!(
PushConditionRoomCtx::new(
room_id.to_owned(),
room_joined_count,
user.to_owned(),
user_display_name,
),
{ is_direct }
PushConditionRoomCtx::new(
room_id.to_owned(),
room_joined_count,
user.to_owned(),
user_display_name,
)
.with_power_levels(power_levels)
}
+3 -17
View File
@@ -970,8 +970,6 @@ impl Service {
}
}
let mut first_push_error = None;
for pdu in pdus {
// Redacted events are not notification targets (we don't send push
// for them)
@@ -997,27 +995,15 @@ impl Service {
.try_into()
.expect("notification count can't go that high");
let response = self
let _response = self
.services
.pusher
.send_push_notice(&user_id, unread, &pusher, rules_for_user, &pdu)
.await
.map_err(|e| (Destination::Push(user_id.clone(), pushkey.clone()), Box::new(e)));
if let Err(err) = response {
error!(event = %pdu.event_id, pusher = %pusher.app_display_name, "Failed to deliver push notification: {err:?}");
if first_push_error.is_none() {
first_push_error = Some(err);
}
}
.map_err(|e| (Destination::Push(user_id.clone(), pushkey.clone()), e));
}
if let Some(err) = first_push_error {
Err(err)
} else {
Ok(Destination::Push(user_id, pushkey))
}
Ok(Destination::Push(user_id, pushkey))
}
async fn send_events_dest_federation(