Skip to content

Commit

Permalink
Merge pull request #54 from CoLearn-Dev/support-call-forwarding
Browse files Browse the repository at this point in the history
Call forwarding
  • Loading branch information
stneng authored Feb 17, 2023
2 parents 8ee76e5 + 87cbc1d commit 0d93ff9
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "colink"
version = "0.3.2"
version = "0.3.3"
edition = "2021"
description = "CoLink Rust SDK"
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CoLink SDK helps both application and protocol developers access the functionali
Add this to your Cargo.toml:
```toml
[dependencies]
colink = "0.3.2"
colink = "0.3.3"
```

## Getting Started
Expand Down
2 changes: 1 addition & 1 deletion proto
13 changes: 13 additions & 0 deletions src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,19 @@ impl CoLink {
Ok(())
}

pub async fn import_forwarding_user_id(
&self,
user_id: &str,
forwarding_user_id: &str,
) -> Result<(), Error> {
self.update_entry(
&format!("_internal:known_users:{}:forwarding_user_id", user_id),
forwarding_user_id.as_bytes(),
)
.await?;
Ok(())
}

/// The default expiration time is 1 day later. If you want to specify an expiration time, use run_task_with_expiration_time instead.
pub async fn run_task(
&self,
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/instant_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl InstantServer {
.arg("bash -c \"$(curl -fsSL https://raw.githubusercontent.com/CoLearn-Dev/colinkctl/main/install_colink.sh)\"")
.env("COLINK_INSTALL_SERVER_ONLY", "true")
.env("COLINK_INSTALL_SILENT", "true")
.env("COLINK_SERVER_VERSION", "v0.3.2")
.env("COLINK_SERVER_VERSION", "v0.3.3")
.status()
.unwrap();
}
Expand Down
28 changes: 28 additions & 0 deletions src/extensions/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,32 @@ impl crate::application::CoLink {
self.wait_task(&task_id).await?;
Ok(())
}

pub async fn set_forwarding_user_id(&self, forwarding_user_id: &str) -> Result<(), Error> {
self.update_entry(
"_registry:forwarding_user_id",
forwarding_user_id.as_bytes(),
)
.await?;
let _ = async {
let registries = self.read_entry("_registry:registries").await?;
let registries: Registries = Message::decode(&*registries)?;
self.update_registries(&registries).await?;
Ok::<(), Box<dyn std::error::Error + Send + Sync + 'static>>(())
}
.await;
Ok(())
}

pub async fn unset_forwarding_user_id(&self) -> Result<(), Error> {
self.delete_entry("_registry:forwarding_user_id").await?;
let _ = async {
let registries = self.read_entry("_registry:registries").await?;
let registries: Registries = Message::decode(&*registries)?;
self.update_registries(&registries).await?;
Ok::<(), Box<dyn std::error::Error + Send + Sync + 'static>>(())
}
.await;
Ok(())
}
}
2 changes: 1 addition & 1 deletion tests/download-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ PACKAGE_NAME="colink-server-linux-x86_64.tar.gz"
if [ "$(uname)" == "Darwin" ]; then
PACKAGE_NAME="colink-server-macos-x86_64.tar.gz"
fi
wget https://github.com/CoLearn-Dev/colink-server-dev/releases/download/v0.3.2/$PACKAGE_NAME
wget https://github.com/CoLearn-Dev/colink-server-dev/releases/download/v0.3.3/$PACKAGE_NAME
tar -xzf $PACKAGE_NAME
touch user_init_config.toml # create an empty user init config to prevent automatically starting protocols when importing users.
cd ..

0 comments on commit 0d93ff9

Please sign in to comment.