From b53c437cee8966950dfe2551eaaf807f741da4ca Mon Sep 17 00:00:00 2001 From: stneng Date: Thu, 16 Feb 2023 12:19:54 +0000 Subject: [PATCH 1/5] add set_forwarding_user_id --- proto | 2 +- src/extensions/registry.rs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/proto b/proto index fa61d53..f3e8d87 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit fa61d530b47515e9b6aa3d032cfc90ad4740b7e2 +Subproject commit f3e8d87d915b717d6dec07ea6fd99886c98d8ddd diff --git a/src/extensions/registry.rs b/src/extensions/registry.rs index 3a8976b..ff913ca 100644 --- a/src/extensions/registry.rs +++ b/src/extensions/registry.rs @@ -21,4 +21,20 @@ 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(®istries).await?; + Ok::<(), Box>(()) + } + .await; + Ok(()) + } } From 115c543ac839618afa6a00bae356e152179b22f2 Mon Sep 17 00:00:00 2001 From: stneng Date: Thu, 16 Feb 2023 12:52:51 +0000 Subject: [PATCH 2/5] add import_forwarding_user_id --- src/application.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/application.rs b/src/application.rs index faa8df6..4bfb903 100644 --- a/src/application.rs +++ b/src/application.rs @@ -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, From 1ce3294532cca7ed8b11646db8411e3cd80edc77 Mon Sep 17 00:00:00 2001 From: stneng Date: Thu, 16 Feb 2023 15:56:49 +0000 Subject: [PATCH 3/5] bump version to 0.3.3 --- Cargo.toml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e7e030e..534d4f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "colink" -version = "0.3.2" +version = "0.3.3" edition = "2021" description = "CoLink Rust SDK" license = "MIT" diff --git a/README.md b/README.md index b01da17..46d601a 100644 --- a/README.md +++ b/README.md @@ -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 From 4fe17621541ecff40db19233958450248dadf77f Mon Sep 17 00:00:00 2001 From: stneng Date: Fri, 17 Feb 2023 07:24:58 +0000 Subject: [PATCH 4/5] bump server verion to 0.3.3 --- src/extensions/instant_server.rs | 2 +- tests/download-server.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/extensions/instant_server.rs b/src/extensions/instant_server.rs index ff3de6d..b88008c 100644 --- a/src/extensions/instant_server.rs +++ b/src/extensions/instant_server.rs @@ -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(); } diff --git a/tests/download-server.sh b/tests/download-server.sh index ce00e99..466205e 100755 --- a/tests/download-server.sh +++ b/tests/download-server.sh @@ -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 .. From 87cbc1d6f7819fe232fc60143ac015a679b73aed Mon Sep 17 00:00:00 2001 From: stneng Date: Fri, 17 Feb 2023 07:51:31 +0000 Subject: [PATCH 5/5] add unset_forwarding_user_id --- src/extensions/registry.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/extensions/registry.rs b/src/extensions/registry.rs index ff913ca..721f091 100644 --- a/src/extensions/registry.rs +++ b/src/extensions/registry.rs @@ -37,4 +37,16 @@ impl crate::application::CoLink { .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(®istries).await?; + Ok::<(), Box>(()) + } + .await; + Ok(()) + } }