mirror of
https://git.asonix.dog/asonix/relay.git
synced 2024-11-28 20:41:33 +00:00
Allow sub-actors of connected server-actors
This commit is contained in:
parent
3074823dc9
commit
b9f9fd4a12
1 changed files with 12 additions and 3 deletions
15
src/db.rs
15
src/db.rs
|
@ -420,11 +420,19 @@ impl Db {
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn is_connected(&self, id: Url) -> Result<bool, MyError> {
|
pub(crate) async fn is_connected(&self, mut id: Url) -> Result<bool, MyError> {
|
||||||
|
id.set_path("");
|
||||||
|
id.set_query(None);
|
||||||
|
id.set_fragment(None);
|
||||||
|
|
||||||
self.unblock(move |inner| {
|
self.unblock(move |inner| {
|
||||||
let connected = inner
|
let connected = inner
|
||||||
.connected_actor_ids
|
.connected_actor_ids
|
||||||
.contains_key(id.as_str().as_bytes())?;
|
.scan_prefix(id.as_str().as_bytes())
|
||||||
|
.values()
|
||||||
|
.filter_map(|res| res.ok())
|
||||||
|
.next()
|
||||||
|
.is_some();
|
||||||
|
|
||||||
Ok(connected)
|
Ok(connected)
|
||||||
})
|
})
|
||||||
|
@ -634,8 +642,9 @@ mod tests {
|
||||||
fn connect_and_verify() {
|
fn connect_and_verify() {
|
||||||
run(|db| async move {
|
run(|db| async move {
|
||||||
let example_actor: Url = "http://example.com/actor".parse().unwrap();
|
let example_actor: Url = "http://example.com/actor".parse().unwrap();
|
||||||
|
let example_sub_actor: Url = "http://example.com/users/fake".parse().unwrap();
|
||||||
db.add_connection(example_actor.clone()).await.unwrap();
|
db.add_connection(example_actor.clone()).await.unwrap();
|
||||||
assert!(db.is_connected(example_actor).await.unwrap());
|
assert!(db.is_connected(example_sub_actor).await.unwrap());
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue