|
|
|
@ -182,7 +182,8 @@ pub async fn send_push_notice( |
|
|
|
_ => None, |
|
|
|
_ => None, |
|
|
|
}) |
|
|
|
}) |
|
|
|
.collect::<Vec<_>>(); |
|
|
|
.collect::<Vec<_>>(); |
|
|
|
send_notice(unread, pushers, tweaks, pdu, db).await?; |
|
|
|
send_notice(unread, pushers, tweaks, pdu, db, rule.rule_id.as_str()).await?; |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
".m.rule.invite_for_me" => { |
|
|
|
".m.rule.invite_for_me" => { |
|
|
|
@ -201,7 +202,9 @@ pub async fn send_push_notice( |
|
|
|
_ => None, |
|
|
|
_ => None, |
|
|
|
}) |
|
|
|
}) |
|
|
|
.collect::<Vec<_>>(); |
|
|
|
.collect::<Vec<_>>(); |
|
|
|
send_notice(unread, pushers, tweaks, pdu, db).await?; |
|
|
|
send_notice(unread, pushers, tweaks, pdu, db, rule.rule_id.as_str()) |
|
|
|
|
|
|
|
.await?; |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -231,7 +234,9 @@ pub async fn send_push_notice( |
|
|
|
_ => None, |
|
|
|
_ => None, |
|
|
|
}) |
|
|
|
}) |
|
|
|
.collect::<Vec<_>>(); |
|
|
|
.collect::<Vec<_>>(); |
|
|
|
send_notice(unread, pushers, tweaks, pdu, db).await?; |
|
|
|
send_notice(unread, pushers, tweaks, pdu, db, rule.rule_id.as_str()) |
|
|
|
|
|
|
|
.await?; |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -255,7 +260,9 @@ pub async fn send_push_notice( |
|
|
|
_ => None, |
|
|
|
_ => None, |
|
|
|
}) |
|
|
|
}) |
|
|
|
.collect::<Vec<_>>(); |
|
|
|
.collect::<Vec<_>>(); |
|
|
|
send_notice(unread, pushers, tweaks, pdu, db).await?; |
|
|
|
send_notice(unread, pushers, tweaks, pdu, db, rule.rule_id.as_str()) |
|
|
|
|
|
|
|
.await?; |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -270,7 +277,8 @@ pub async fn send_push_notice( |
|
|
|
_ => None, |
|
|
|
_ => None, |
|
|
|
}) |
|
|
|
}) |
|
|
|
.collect::<Vec<_>>(); |
|
|
|
.collect::<Vec<_>>(); |
|
|
|
send_notice(unread, pushers, tweaks, pdu, db).await?; |
|
|
|
send_notice(unread, pushers, tweaks, pdu, db, rule.rule_id.as_str()).await?; |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
".m.rule.roomnotif" => { |
|
|
|
".m.rule.roomnotif" => { |
|
|
|
@ -307,7 +315,9 @@ pub async fn send_push_notice( |
|
|
|
_ => None, |
|
|
|
_ => None, |
|
|
|
}) |
|
|
|
}) |
|
|
|
.collect::<Vec<_>>(); |
|
|
|
.collect::<Vec<_>>(); |
|
|
|
send_notice(unread, pushers, tweaks, pdu, db).await?; |
|
|
|
send_notice(unread, pushers, tweaks, pdu, db, rule.rule_id.as_str()) |
|
|
|
|
|
|
|
.await?; |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -331,7 +341,9 @@ pub async fn send_push_notice( |
|
|
|
_ => None, |
|
|
|
_ => None, |
|
|
|
}) |
|
|
|
}) |
|
|
|
.collect::<Vec<_>>(); |
|
|
|
.collect::<Vec<_>>(); |
|
|
|
send_notice(unread, pushers, tweaks, pdu, db).await?; |
|
|
|
send_notice(unread, pushers, tweaks, pdu, db, rule.rule_id.as_str()) |
|
|
|
|
|
|
|
.await?; |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -346,7 +358,8 @@ pub async fn send_push_notice( |
|
|
|
_ => None, |
|
|
|
_ => None, |
|
|
|
}) |
|
|
|
}) |
|
|
|
.collect::<Vec<_>>(); |
|
|
|
.collect::<Vec<_>>(); |
|
|
|
send_notice(unread, pushers, tweaks, pdu, db).await?; |
|
|
|
send_notice(unread, pushers, tweaks, pdu, db, rule.rule_id.as_str()).await?; |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
".m.rule.encrypted_room_one_to_one" => { |
|
|
|
".m.rule.encrypted_room_one_to_one" => { |
|
|
|
@ -361,7 +374,8 @@ pub async fn send_push_notice( |
|
|
|
_ => None, |
|
|
|
_ => None, |
|
|
|
}) |
|
|
|
}) |
|
|
|
.collect::<Vec<_>>(); |
|
|
|
.collect::<Vec<_>>(); |
|
|
|
send_notice(unread, pushers, tweaks, pdu, db).await?; |
|
|
|
send_notice(unread, pushers, tweaks, pdu, db, rule.rule_id.as_str()).await?; |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
".m.rule.room_one_to_one" => { |
|
|
|
".m.rule.room_one_to_one" => { |
|
|
|
@ -376,7 +390,8 @@ pub async fn send_push_notice( |
|
|
|
_ => None, |
|
|
|
_ => None, |
|
|
|
}) |
|
|
|
}) |
|
|
|
.collect::<Vec<_>>(); |
|
|
|
.collect::<Vec<_>>(); |
|
|
|
send_notice(unread, pushers, tweaks, pdu, db).await?; |
|
|
|
send_notice(unread, pushers, tweaks, pdu, db, rule.rule_id.as_str()).await?; |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
".m.rule.message" => { |
|
|
|
".m.rule.message" => { |
|
|
|
@ -389,7 +404,8 @@ pub async fn send_push_notice( |
|
|
|
_ => None, |
|
|
|
_ => None, |
|
|
|
}) |
|
|
|
}) |
|
|
|
.collect::<Vec<_>>(); |
|
|
|
.collect::<Vec<_>>(); |
|
|
|
send_notice(unread, pushers, tweaks, pdu, db).await?; |
|
|
|
send_notice(unread, pushers, tweaks, pdu, db, rule.rule_id.as_str()).await?; |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
".m.rule.encrypted" => { |
|
|
|
".m.rule.encrypted" => { |
|
|
|
@ -402,12 +418,14 @@ pub async fn send_push_notice( |
|
|
|
_ => None, |
|
|
|
_ => None, |
|
|
|
}) |
|
|
|
}) |
|
|
|
.collect::<Vec<_>>(); |
|
|
|
.collect::<Vec<_>>(); |
|
|
|
send_notice(unread, pushers, tweaks, pdu, db).await?; |
|
|
|
send_notice(unread, pushers, tweaks, pdu, db, rule.rule_id.as_str()).await?; |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
_ => {} |
|
|
|
_ => {} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -417,6 +435,7 @@ async fn send_notice( |
|
|
|
tweaks: Vec<Tweak>, |
|
|
|
tweaks: Vec<Tweak>, |
|
|
|
event: &PduEvent, |
|
|
|
event: &PduEvent, |
|
|
|
db: &Database, |
|
|
|
db: &Database, |
|
|
|
|
|
|
|
name: &str, |
|
|
|
) -> Result<()> { |
|
|
|
) -> Result<()> { |
|
|
|
let (http, _emails): (Vec<&Pusher>, _) = pushers |
|
|
|
let (http, _emails): (Vec<&Pusher>, _) = pushers |
|
|
|
.iter() |
|
|
|
.iter() |
|
|
|
@ -436,10 +455,15 @@ async fn send_notice( |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
let mut device = Device::new(pusher.app_id.clone(), pusher.pushkey.clone()); |
|
|
|
let mut device = Device::new(pusher.app_id.clone(), pusher.pushkey.clone()); |
|
|
|
device.data = Some(pusher.data.clone()); |
|
|
|
let mut data_minus_url = pusher.data.clone(); |
|
|
|
|
|
|
|
// The url must be stripped off according to spec
|
|
|
|
// this is not done if "event_id_only" is the format
|
|
|
|
data_minus_url.url = None; |
|
|
|
device.tweaks = tweaks.clone(); |
|
|
|
device.data = Some(data_minus_url); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Tweaks are only added if the format is NOT event_id_only
|
|
|
|
|
|
|
|
if !event_id_only { |
|
|
|
|
|
|
|
device.tweaks = tweaks.clone(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let d = &[device]; |
|
|
|
let d = &[device]; |
|
|
|
let mut notifi = Notification::new(d); |
|
|
|
let mut notifi = Notification::new(d); |
|
|
|
@ -459,12 +483,13 @@ async fn send_notice( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if event_id_only { |
|
|
|
if event_id_only { |
|
|
|
// send_request(
|
|
|
|
error!("SEND PUSH NOTICE `{}`", name); |
|
|
|
// &db.globals,
|
|
|
|
// send_request(
|
|
|
|
// &url,
|
|
|
|
// &db.globals,
|
|
|
|
// send_event_notification::v1::Request::new(notifi),
|
|
|
|
// &url,
|
|
|
|
// )
|
|
|
|
// send_event_notification::v1::Request::new(notifi),
|
|
|
|
// .await?;
|
|
|
|
// )
|
|
|
|
|
|
|
|
// .await?;
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
notifi.sender = Some(&event.sender); |
|
|
|
notifi.sender = Some(&event.sender); |
|
|
|
notifi.event_type = Some(&event.kind); |
|
|
|
notifi.event_type = Some(&event.kind); |
|
|
|
@ -474,8 +499,8 @@ async fn send_notice( |
|
|
|
notifi.user_is_target = event.state_key.as_deref() == Some(event.sender.as_str()); |
|
|
|
notifi.user_is_target = event.state_key.as_deref() == Some(event.sender.as_str()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let name = db.users.displayname(&event.sender)?; |
|
|
|
let user_name = db.users.displayname(&event.sender)?; |
|
|
|
notifi.sender_display_name = name.as_deref(); |
|
|
|
notifi.sender_display_name = user_name.as_deref(); |
|
|
|
let room_name = db |
|
|
|
let room_name = db |
|
|
|
.rooms |
|
|
|
.rooms |
|
|
|
.room_state_get(&event.room_id, &EventType::RoomName, "")? |
|
|
|
.room_state_get(&event.room_id, &EventType::RoomName, "")? |
|
|
|
@ -486,12 +511,13 @@ async fn send_notice( |
|
|
|
.flatten(); |
|
|
|
.flatten(); |
|
|
|
notifi.room_name = room_name.as_deref(); |
|
|
|
notifi.room_name = room_name.as_deref(); |
|
|
|
|
|
|
|
|
|
|
|
send_request( |
|
|
|
error!("SEND PUSH NOTICE Full `{}`", name); |
|
|
|
&db.globals, |
|
|
|
// send_request(
|
|
|
|
&url, |
|
|
|
// &db.globals,
|
|
|
|
send_event_notification::v1::Request::new(notifi), |
|
|
|
// &url,
|
|
|
|
) |
|
|
|
// send_event_notification::v1::Request::new(notifi),
|
|
|
|
.await?; |
|
|
|
// )
|
|
|
|
|
|
|
|
// .await?;
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|