From 92fe223d96027fca45e06f9be7a4676fe84f0786 Mon Sep 17 00:00:00 2001
From: Quaternions <krakow20@gmail.com>
Date: Mon, 2 Dec 2024 21:09:59 -0800
Subject: [PATCH] json

---
 validation/Cargo.lock        |  2 ++
 validation/Cargo.toml        |  2 ++
 validation/src/main.rs       |  1 +
 validation/src/nats_types.rs | 47 ++++++++++++++++++++++++++++++++++++
 4 files changed, 52 insertions(+)
 create mode 100644 validation/src/nats_types.rs

diff --git a/validation/Cargo.lock b/validation/Cargo.lock
index 7923ce0..4904bea 100644
--- a/validation/Cargo.lock
+++ b/validation/Cargo.lock
@@ -1182,6 +1182,8 @@ dependencies = [
  "rbx_binary",
  "rbx_dom_weak",
  "rbx_xml",
+ "serde",
+ "serde_json",
  "sqlx",
  "tokio",
 ]
diff --git a/validation/Cargo.toml b/validation/Cargo.toml
index c717b52..4e8d806 100644
--- a/validation/Cargo.toml
+++ b/validation/Cargo.toml
@@ -10,5 +10,7 @@ rbx_asset = { version = "0.2.3", registry = "strafesnet" }
 rbx_binary = { version = "0.7.4", registry = "strafesnet"}
 rbx_dom_weak = { version = "2.9.0", registry = "strafesnet"}
 rbx_xml = { version = "0.13.3", registry = "strafesnet"}
+serde = { version = "1.0.215", features = ["derive"] }
+serde_json = "1.0.133"
 sqlx = "0.8.2"
 tokio = { version = "1.41.1", features = ["macros", "rt-multi-thread", "fs"] }
diff --git a/validation/src/main.rs b/validation/src/main.rs
index 8bf2d57..7c72b75 100644
--- a/validation/src/main.rs
+++ b/validation/src/main.rs
@@ -1,3 +1,4 @@
+mod nats_types;
 mod publisher;
 mod validator;
 
diff --git a/validation/src/nats_types.rs b/validation/src/nats_types.rs
new file mode 100644
index 0000000..29dc20f
--- /dev/null
+++ b/validation/src/nats_types.rs
@@ -0,0 +1,47 @@
+// These represent the information needed in the nats message
+// to perform the operation, not necessarily the over-the-wire format
+
+// Requests are sent from maps-service to validator
+// Responses are sent from validator to maps-service
+
+#[derive(serde::Deserialize)]
+pub struct ValidateRequest{
+	// submission_id is passed back in the response message
+	pub submission_id:u64,
+	pub model_id:u64,
+	pub model_version:u64,
+}
+
+pub struct ValidateResponse{
+	pub submission_id:u64,
+	// model id will be changed if scripts were replaced
+	pub model_id:u64,
+	pub model_version:u64,
+}
+
+// an invalidate is sent instead if validation fails
+pub struct InvalidateResponse{
+	pub submission_id:u64,
+}
+
+// Create a new map
+pub struct PublishNewRequest{
+	pub submission_id:u64,
+	pub model_id:u64,
+	pub model_version:u64,
+	pub creator:String,
+	pub display_name:String,
+	//games:HashSet<GameID>,
+}
+
+pub struct PublishFixRequest{
+	pub submission_id:u64,
+	pub model_id:u64,
+	pub model_version:u64,
+	pub target_asset_id:u64,
+}
+
+pub struct PublishResponse{
+	pub submission_id:u64,
+	pub success:bool,
+}