improvement: update ruma
This commit is contained in:
parent
1f84013b2a
commit
6e84d317b2
8 changed files with 106 additions and 125 deletions
|
@ -2,7 +2,7 @@ use crate::{Database, Error, PduEvent, Result};
|
|||
use log::{error, info, warn};
|
||||
use ruma::{
|
||||
api::{
|
||||
client::r0::push::{Pusher, PusherKind},
|
||||
client::r0::push::{get_pushers, set_pusher, PusherKind},
|
||||
push_gateway::send_event_notification::{
|
||||
self,
|
||||
v1::{Device, Notification, NotificationCounts, NotificationPriority},
|
||||
|
@ -30,7 +30,7 @@ impl PushData {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn set_pusher(&self, sender: &UserId, pusher: Pusher) -> Result<()> {
|
||||
pub fn set_pusher(&self, sender: &UserId, pusher: set_pusher::Pusher) -> Result<()> {
|
||||
let mut key = sender.as_bytes().to_vec();
|
||||
key.push(0xff);
|
||||
key.extend_from_slice(pusher.pushkey.as_bytes());
|
||||
|
@ -52,7 +52,7 @@ impl PushData {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn get_pusher(&self, senderkey: &[u8]) -> Result<Option<Pusher>> {
|
||||
pub fn get_pusher(&self, senderkey: &[u8]) -> Result<Option<get_pushers::Pusher>> {
|
||||
self.senderkey_pusher
|
||||
.get(senderkey)?
|
||||
.map(|push| {
|
||||
|
@ -62,7 +62,7 @@ impl PushData {
|
|||
.transpose()
|
||||
}
|
||||
|
||||
pub fn get_pushers(&self, sender: &UserId) -> Result<Vec<Pusher>> {
|
||||
pub fn get_pushers(&self, sender: &UserId) -> Result<Vec<get_pushers::Pusher>> {
|
||||
let mut prefix = sender.as_bytes().to_vec();
|
||||
prefix.push(0xff);
|
||||
|
||||
|
@ -164,7 +164,7 @@ where
|
|||
pub async fn send_push_notice(
|
||||
user: &UserId,
|
||||
unread: UInt,
|
||||
pusher: &Pusher,
|
||||
pusher: &get_pushers::Pusher,
|
||||
ruleset: Ruleset,
|
||||
pdu: &PduEvent,
|
||||
db: &Database,
|
||||
|
@ -205,7 +205,7 @@ pub fn get_actions<'a>(
|
|||
ruleset: &'a Ruleset,
|
||||
pdu: &PduEvent,
|
||||
db: &Database,
|
||||
) -> Result<impl 'a + Iterator<Item = Action>> {
|
||||
) -> Result<&'a [Action]> {
|
||||
let power_levels: PowerLevelsEventContent = db
|
||||
.rooms
|
||||
.room_state_get(&pdu.room_id, &EventType::RoomPowerLevels, "")?
|
||||
|
@ -228,20 +228,18 @@ pub fn get_actions<'a>(
|
|||
notification_power_levels: power_levels.notifications,
|
||||
};
|
||||
|
||||
Ok(ruleset
|
||||
.get_actions(&pdu.to_sync_room_event(), &ctx)
|
||||
.map(Clone::clone))
|
||||
Ok(ruleset.get_actions(&pdu.to_sync_room_event(), &ctx))
|
||||
}
|
||||
|
||||
async fn send_notice(
|
||||
unread: UInt,
|
||||
pusher: &Pusher,
|
||||
pusher: &get_pushers::Pusher,
|
||||
tweaks: Vec<Tweak>,
|
||||
event: &PduEvent,
|
||||
db: &Database,
|
||||
) -> Result<()> {
|
||||
// TODO: email
|
||||
if pusher.kind == Some(PusherKind::Email) {
|
||||
if pusher.kind == PusherKind::Email {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
|
@ -250,7 +248,7 @@ async fn send_notice(
|
|||
// 1. if "event_id_only" is the only format kind it seems we should never add more info
|
||||
// 2. can pusher/devices have conflicting formats
|
||||
let event_id_only = pusher.data.format == Some(PushFormat::EventIdOnly);
|
||||
let url = if let Some(url) = pusher.data.url.as_ref() {
|
||||
let url = if let Some(url) = &pusher.data.url {
|
||||
url
|
||||
} else {
|
||||
error!("Http Pusher must have URL specified.");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue