Remove associated pushers on device delete. (fixes #120)

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-08-26 19:55:44 +00:00
committed by dasha_uwu
parent 146b72265d
commit 7a3496869b
3 changed files with 40 additions and 29 deletions

View File

@@ -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