Skip to content

Commit 0d93ff9

Browse files
authored
Merge pull request #54 from CoLearn-Dev/support-call-forwarding
Call forwarding
2 parents 8ee76e5 + 87cbc1d commit 0d93ff9

File tree

7 files changed

+46
-5
lines changed

7 files changed

+46
-5
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "colink"
3-
version = "0.3.2"
3+
version = "0.3.3"
44
edition = "2021"
55
description = "CoLink Rust SDK"
66
license = "MIT"

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ CoLink SDK helps both application and protocol developers access the functionali
99
Add this to your Cargo.toml:
1010
```toml
1111
[dependencies]
12-
colink = "0.3.2"
12+
colink = "0.3.3"
1313
```
1414

1515
## Getting Started

src/application.rs

+13
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,19 @@ impl CoLink {
356356
Ok(())
357357
}
358358

359+
pub async fn import_forwarding_user_id(
360+
&self,
361+
user_id: &str,
362+
forwarding_user_id: &str,
363+
) -> Result<(), Error> {
364+
self.update_entry(
365+
&format!("_internal:known_users:{}:forwarding_user_id", user_id),
366+
forwarding_user_id.as_bytes(),
367+
)
368+
.await?;
369+
Ok(())
370+
}
371+
359372
/// The default expiration time is 1 day later. If you want to specify an expiration time, use run_task_with_expiration_time instead.
360373
pub async fn run_task(
361374
&self,

src/extensions/instant_server.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl InstantServer {
4848
.arg("bash -c \"$(curl -fsSL https://raw.githubusercontent.com/CoLearn-Dev/colinkctl/main/install_colink.sh)\"")
4949
.env("COLINK_INSTALL_SERVER_ONLY", "true")
5050
.env("COLINK_INSTALL_SILENT", "true")
51-
.env("COLINK_SERVER_VERSION", "v0.3.2")
51+
.env("COLINK_SERVER_VERSION", "v0.3.3")
5252
.status()
5353
.unwrap();
5454
}

src/extensions/registry.rs

+28
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,32 @@ impl crate::application::CoLink {
2121
self.wait_task(&task_id).await?;
2222
Ok(())
2323
}
24+
25+
pub async fn set_forwarding_user_id(&self, forwarding_user_id: &str) -> Result<(), Error> {
26+
self.update_entry(
27+
"_registry:forwarding_user_id",
28+
forwarding_user_id.as_bytes(),
29+
)
30+
.await?;
31+
let _ = async {
32+
let registries = self.read_entry("_registry:registries").await?;
33+
let registries: Registries = Message::decode(&*registries)?;
34+
self.update_registries(&registries).await?;
35+
Ok::<(), Box<dyn std::error::Error + Send + Sync + 'static>>(())
36+
}
37+
.await;
38+
Ok(())
39+
}
40+
41+
pub async fn unset_forwarding_user_id(&self) -> Result<(), Error> {
42+
self.delete_entry("_registry:forwarding_user_id").await?;
43+
let _ = async {
44+
let registries = self.read_entry("_registry:registries").await?;
45+
let registries: Registries = Message::decode(&*registries)?;
46+
self.update_registries(&registries).await?;
47+
Ok::<(), Box<dyn std::error::Error + Send + Sync + 'static>>(())
48+
}
49+
.await;
50+
Ok(())
51+
}
2452
}

tests/download-server.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ PACKAGE_NAME="colink-server-linux-x86_64.tar.gz"
66
if [ "$(uname)" == "Darwin" ]; then
77
PACKAGE_NAME="colink-server-macos-x86_64.tar.gz"
88
fi
9-
wget https://github.com/CoLearn-Dev/colink-server-dev/releases/download/v0.3.2/$PACKAGE_NAME
9+
wget https://github.com/CoLearn-Dev/colink-server-dev/releases/download/v0.3.3/$PACKAGE_NAME
1010
tar -xzf $PACKAGE_NAME
1111
touch user_init_config.toml # create an empty user init config to prevent automatically starting protocols when importing users.
1212
cd ..

0 commit comments

Comments
 (0)