From 4f6e6163cc7406f3ebf0a1b4222038ba9989a8df Mon Sep 17 00:00:00 2001 From: Natty Date: Tue, 7 Nov 2023 21:15:35 +0100 Subject: [PATCH] Ported MkAvatars to Magnetar --- Cargo.lock | 3 ++ Cargo.toml | 3 ++ ext_calckey_model/src/lib.rs | 10 ++++ .../{MkAvatars.vue => MagAvatars.vue} | 28 ++++++++--- .../client/src/components/global/MkAvatar.vue | 2 +- .../client/src/pages/my-groups/index.vue | 6 +-- .../client/src/pages/my-lists/index.vue | 4 +- .../client/src/ui/deck/bookmarks-column.vue | 4 +- .../frontend/client/src/widgets/user-list.vue | 4 +- .../frontend/magnetar-common/src/be-api.ts | 2 +- .../frontend/magnetar-common/src/endpoints.ts | 1 + .../src/types/ManyUsersByIdReq.ts | 3 ++ .../src/types/endpoints/GetManyUsersById.ts | 12 +++++ magnetar_sdk/Cargo.toml | 1 + magnetar_sdk/macros/src/lib.rs | 50 ++++++++++++++++--- magnetar_sdk/src/endpoints/user.rs | 20 +++++++- magnetar_sdk/src/util_types.rs | 22 +++++++- src/api_v1/mod.rs | 7 ++- src/api_v1/user.rs | 50 ++++++++++++++++++- src/model/processing/mod.rs | 2 + src/web/mod.rs | 19 +++++++ 21 files changed, 222 insertions(+), 31 deletions(-) rename fe_calckey/frontend/client/src/components/{MkAvatars.vue => MagAvatars.vue} (56%) create mode 100644 fe_calckey/frontend/magnetar-common/src/types/ManyUsersByIdReq.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/endpoints/GetManyUsersById.ts diff --git a/Cargo.lock b/Cargo.lock index 1ff71a3..c452700 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -888,6 +888,7 @@ checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" dependencies = [ "futures-channel", "futures-core", + "futures-executor", "futures-io", "futures-sink", "futures-task", @@ -1455,6 +1456,7 @@ dependencies = [ "compact_str", "dotenvy", "either", + "futures", "futures-util", "headers", "hyper", @@ -1590,6 +1592,7 @@ dependencies = [ "magnetar_sdk_macros", "serde", "serde_json", + "serde_urlencoded", "ts-rs", "unicode-segmentation", ] diff --git a/Cargo.toml b/Cargo.toml index f13447f..e3d0596 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,7 @@ compact_str = "0.7" dotenvy = "0.15" either = "1.9" emojis = "0.6" +futures = "0.3" futures-core = "0.3" futures-util = "0.3" headers = "0.3" @@ -53,6 +54,7 @@ sea-orm = "0.12" sea-orm-migration = "0.12" serde = "1" serde_json = "1" +serde_urlencoded = "0.7" strum = "0.25" tera = { version = "1", default-features = false } thiserror = "1" @@ -101,6 +103,7 @@ cfg-if = { workspace = true } compact_str = { workspace = true } either = { workspace = true } +futures = { workspace = true } futures-util = { workspace = true } itertools = { workspace = true } lazy_static = { workspace = true } diff --git a/ext_calckey_model/src/lib.rs b/ext_calckey_model/src/lib.rs index 573c749..da54175 100644 --- a/ext_calckey_model/src/lib.rs +++ b/ext_calckey_model/src/lib.rs @@ -114,6 +114,16 @@ impl CalckeyModel { .await?) } + pub async fn get_many_users_by_id( + &self, + id: &[String], + ) -> Result, CalckeyDbError> { + Ok(user::Entity::find() + .filter(user::Column::Id.is_in(id)) + .all(&self.0) + .await?) + } + pub async fn get_user_by_token( &self, token: &str, diff --git a/fe_calckey/frontend/client/src/components/MkAvatars.vue b/fe_calckey/frontend/client/src/components/MagAvatars.vue similarity index 56% rename from fe_calckey/frontend/client/src/components/MkAvatars.vue rename to fe_calckey/frontend/client/src/components/MagAvatars.vue index 9928de9..ab5b42a 100644 --- a/fe_calckey/frontend/client/src/components/MkAvatars.vue +++ b/fe_calckey/frontend/client/src/components/MagAvatars.vue @@ -9,25 +9,37 @@