Remove associated pushers on device delete. (fixes #120)
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -24,7 +24,10 @@ use tuwunel_core::{
|
||||
Err, Result, debug_warn, err,
|
||||
matrix::Event,
|
||||
trace,
|
||||
utils::{stream::TryIgnore, string_from_bytes},
|
||||
utils::{
|
||||
stream::{BroadbandExt, TryIgnore},
|
||||
string_from_bytes,
|
||||
},
|
||||
warn,
|
||||
};
|
||||
use tuwunel_database::{Deserialized, Ignore, Interfix, Json, Map};
|
||||
@@ -134,6 +137,25 @@ impl Service {
|
||||
.ok();
|
||||
}
|
||||
|
||||
pub async fn get_device_pushkeys(
|
||||
&self,
|
||||
sender: &UserId,
|
||||
device_id: &DeviceId,
|
||||
) -> Vec<String> {
|
||||
self.get_pushkeys(sender)
|
||||
.map(ToOwned::to_owned)
|
||||
.broad_filter_map(async |pushkey| {
|
||||
self.get_pusher_device(&pushkey)
|
||||
.await
|
||||
.ok()
|
||||
.filter(|pusher_device| pusher_device == device_id)
|
||||
.is_some()
|
||||
.then_some(pushkey)
|
||||
})
|
||||
.collect()
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn get_pusher_device(&self, pushkey: &str) -> Result<OwnedDeviceId> {
|
||||
self.db
|
||||
.pushkey_deviceid
|
||||
|
||||
Reference in New Issue
Block a user