summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/sellershut-core/Cargo.toml2
-rw-r--r--lib/sellershut-core/build.rs22
-rw-r--r--lib/sellershut-core/proto/users/users.proto (renamed from lib/sellershut-core/proto/profile/profile.proto)42
-rw-r--r--lib/sellershut-core/src/lib.rs8
-rw-r--r--lib/sellershut-core/src/profile.rs4
-rw-r--r--lib/sellershut-core/src/users.rs36
6 files changed, 84 insertions, 30 deletions
diff --git a/lib/sellershut-core/Cargo.toml b/lib/sellershut-core/Cargo.toml
index 1b7d5f7..0be2ce7 100644
--- a/lib/sellershut-core/Cargo.toml
+++ b/lib/sellershut-core/Cargo.toml
@@ -18,7 +18,7 @@ tonic-types = "0.13.0"
[features]
default = []
auth = []
-profile = []
+users = []
serde = ["dep:serde", "serde/derive", "serde_json"]
time = [
"dep:time",
diff --git a/lib/sellershut-core/build.rs b/lib/sellershut-core/build.rs
index 13e3d06..ff57fec 100644
--- a/lib/sellershut-core/build.rs
+++ b/lib/sellershut-core/build.rs
@@ -1,12 +1,12 @@
-#[cfg(any(feature = "auth", feature = "profile"))]
+#[cfg(any(feature = "auth", feature = "users"))]
enum Entity {
#[cfg(feature = "auth")]
Auth,
- #[cfg(feature = "profile")]
- Profile,
+ #[cfg(feature = "users")]
+ User,
}
-#[cfg(any(feature = "auth", feature = "profile"))]
+#[cfg(any(feature = "auth", feature = "users"))]
impl Entity {
fn protos(&self) -> Vec<&'static str> {
let mut res: Vec<&'static str> = vec![];
@@ -16,9 +16,9 @@ impl Entity {
Entity::Auth => {
res.extend(vec!["proto/auth/auth.proto"]);
}
- #[cfg(feature = "profile")]
- Entity::Profile => {
- res.extend(vec!["proto/profile/profile.proto"]);
+ #[cfg(feature = "users")]
+ Entity::User => {
+ res.extend(vec!["proto/users/users.proto"]);
}
}
res
@@ -31,13 +31,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
#[cfg(feature = "auth")]
build_proto("auth", Entity::Auth);
- #[cfg(feature = "profile")]
- build_proto("profile", Entity::Profile);
+ #[cfg(feature = "users")]
+ build_proto("users", Entity::User);
Ok(())
}
-#[cfg(any(feature = "auth", feature = "profile"))]
+#[cfg(any(feature = "auth", feature = "users"))]
fn build_proto(package: &str, entity: Entity) {
let out_dir = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap());
@@ -81,7 +81,7 @@ fn build_proto(package: &str, entity: Entity) {
.compile_protos(&entity.protos(), include_paths).unwrap();
}
-#[cfg(all(feature = "serde", any(feature = "auth", feature = "profile")))]
+#[cfg(all(feature = "serde", any(feature = "auth", feature = "users")))]
fn add_serde(config: tonic_build::Builder) -> tonic_build::Builder {
config.type_attribute(
".",
diff --git a/lib/sellershut-core/proto/profile/profile.proto b/lib/sellershut-core/proto/users/users.proto
index 61181b3..d1cf692 100644
--- a/lib/sellershut-core/proto/profile/profile.proto
+++ b/lib/sellershut-core/proto/users/users.proto
@@ -1,10 +1,18 @@
syntax = "proto3";
-package profile;
+package users;
import "google/protobuf/timestamp.proto";
-// A message representing a user profile
+enum UserType {
+ PERSON = 0;
+ APPLICATION = 1;
+ GROUP = 2;
+ ORGANIZATION = 3;
+ SERVICE = 4;
+}
+
+// A message representing a user user
message User {
// Unique identifier for the user
string id = 1;
@@ -20,9 +28,13 @@ message User {
google.protobuf.Timestamp updated_at = 6;
// User-provided description or bio
optional string description = 7;
+ // User type
+ UserType user_type = 8;
+ // Public key
+ string public_key = 9;
}
-// Request message for creating a new user profile
+// Request message for creating a new user
message CreateUserRequest {
// Email address of the new user
string email = 1;
@@ -36,22 +48,32 @@ message CreateUserResponse {
string temp_id = 1;
}
-// Message to finalise profile creation
+// Message to finalise user creation
message CompleteUserRequest {
// ID of the user to finalise
string id = 1;
- // Required: username to finalise the profile
+ // Required: username to finalise the user
string username = 2;
// Optional: user-provided description
optional string description = 3;
// Optional: update avatar
optional string avatar = 4;
+ // Inbox URL for this user
+ string inbox = 5;
+ // Outbox URL for this user
+ string outbox = 6;
+ // Is this user local or remote
+ bool local = 7;
+ // Public key for this user
+ string public_key = 8;
+ // User type
+ UserType user_type = 9;
}
-// Profile gRPC service
-service Profile {
- // Create a new user profile
+// Users gRPC service
+service UsersService {
+ // Create a new user
rpc CreateUser (CreateUserRequest) returns (CreateUserResponse);
- // Complete Profile
- rpc CompleteProfile (CompleteUserRequest) returns (User);
+ // Complete user
+ rpc CompleteUser (CompleteUserRequest) returns (User);
}
diff --git a/lib/sellershut-core/src/lib.rs b/lib/sellershut-core/src/lib.rs
index 70544cf..afbd20f 100644
--- a/lib/sellershut-core/src/lib.rs
+++ b/lib/sellershut-core/src/lib.rs
@@ -7,13 +7,13 @@
)]
/// Protobuf types
-#[cfg(any(feature = "auth", feature = "profile"))]
+#[cfg(any(feature = "auth", feature = "users"))]
pub mod google;
/// Interactions with Auth server
#[cfg(feature = "auth")]
pub mod auth;
-/// Interactions with Profile server
-#[cfg(feature = "profile")]
-pub mod profile;
+/// Interactions with user server
+#[cfg(feature = "users")]
+pub mod users;
diff --git a/lib/sellershut-core/src/profile.rs b/lib/sellershut-core/src/profile.rs
deleted file mode 100644
index 06484d9..0000000
--- a/lib/sellershut-core/src/profile.rs
+++ /dev/null
@@ -1,4 +0,0 @@
-tonic::include_proto!("profile");
-/// Profile file descriptor
-pub const PROFILE_FILE_DESCRIPTOR_SET: &[u8] =
- tonic::include_file_descriptor_set!("profile_descriptor");
diff --git a/lib/sellershut-core/src/users.rs b/lib/sellershut-core/src/users.rs
new file mode 100644
index 0000000..5721d53
--- /dev/null
+++ b/lib/sellershut-core/src/users.rs
@@ -0,0 +1,36 @@
+tonic::include_proto!("users");
+/// Users file descriptor
+pub const USERS_FILE_DESCRIPTOR_SET: &[u8] =
+ tonic::include_file_descriptor_set!("users_descriptor");
+
+impl std::fmt::Display for UserType {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(
+ f,
+ "{}",
+ match self {
+ UserType::Person => "person",
+ UserType::Application => "application",
+ UserType::Group => "group",
+ UserType::Organization => "organization",
+ UserType::Service => "service",
+ }
+ .to_uppercase()
+ )
+ }
+}
+
+impl std::str::FromStr for UserType {
+ type Err = String;
+
+ fn from_str(value: &str) -> Result<Self, Self::Err> {
+ match value.to_lowercase().as_str() {
+ "person" => Ok(Self::Person),
+ "application" => Ok(Self::Application),
+ "group" => Ok(Self::Group),
+ "organization" => Ok(Self::Organization),
+ "service" => Ok(Self::Service),
+ _ => Err(format!("invalid user type: {value}")),
+ }
+ }
+}