1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-07-13 17:07:45 +00:00

Fix the API for support desk headlines

This commit is contained in:
Joshua Goins 2025-07-12 10:11:18 -04:00
parent eb73af03d6
commit 217ed2466c
4 changed files with 81 additions and 14 deletions

13
Cargo.lock generated
View file

@ -2579,6 +2579,7 @@ dependencies = [
"rkon", "rkon",
"rusqlite", "rusqlite",
"serde", "serde",
"serde-xml-rs",
"serde_json", "serde_json",
"serde_yaml_ng", "serde_yaml_ng",
"sha1_smol", "sha1_smol",
@ -3883,6 +3884,18 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "serde-xml-rs"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53630160a98edebde0123eb4dfd0fce6adff091b2305db3154a9e920206eb510"
dependencies = [
"log",
"serde",
"thiserror 1.0.69",
"xml-rs",
]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.219" version = "1.0.219"

View file

@ -65,6 +65,7 @@ serde_json = { version = "1.0", features = ["std"], default-features = false }
serde = { version = "1.0", features = ["derive"], default-features = false } serde = { version = "1.0", features = ["derive"], default-features = false }
serde_json = { version = "1.0", features = ["std"], default-features = false } serde_json = { version = "1.0", features = ["std"], default-features = false }
serde_yaml_ng = { version = "0.10", default-features = false } serde_yaml_ng = { version = "0.10", default-features = false }
serde-xml-rs = { version = "0.8", default-features = false }
# Logging # Logging
tracing = { version = "0.1", default-features = false } tracing = { version = "0.1", default-features = false }

View file

@ -33,6 +33,7 @@ frontier.ffxiv.localhost:80 {
header { header {
Server nginx Server nginx
-Via -Via
Connection keep-alive
} }
} }

View file

@ -87,7 +87,10 @@ where
{ {
fn into_response(self) -> Response { fn into_response(self) -> Response {
( (
[(header::CONTENT_TYPE, HeaderValue::from_static("text/xml"))], [(
header::CONTENT_TYPE,
HeaderValue::from_static("application/xml"),
)],
self.0, self.0,
) )
.into_response() .into_response()
@ -100,36 +103,85 @@ impl<T> From<T> for Xml<T> {
} }
} }
async fn session_get_init() -> Xml<String> { async fn session_get_init(body: String) -> Xml<Vec<u8>> {
dbg!(body);
// TODO: just a guess // TODO: just a guess
Xml("<result> Xml(
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><result>
<return_code>OK</return_code> <return_code>OK</return_code>
<information/> <information/>
<inquiry_categoryList/> <inquiry_categoryList/>
<inquiry_itemList/> <inquiry_itemList/>
<report_itemList/> <report_itemList/>
</result>" </result>"
.to_string()) .as_bytes()
.to_vec(),
)
} }
async fn view_get_init() -> Xml<String> { async fn view_get_init() -> Xml<Vec<u8>> {
Xml("<result> Xml(
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><result>
<return_code>OK</return_code> <return_code>OK</return_code>
<information/> <information/>
<inquiry_categoryList/> <inquiry_categoryList/>
<inquiry_itemList/> <inquiry_itemList/>
<report_itemList/> <report_itemList/>
</result>" </result>"
.to_string()) .as_bytes()
.to_vec(),
)
} }
async fn get_headline_all() -> Xml<String> { #[derive(Serialize)]
Xml("<result> #[serde(rename = "item")]
<return_code>OK</return_code> struct Item {
<information> title: String,
</information> published: i64,
</result>" updated: i64,
.to_string()) lsb_id: String,
lsb_parentid: Option<String>,
lsb_tag: Option<String>,
#[serde(rename = "catId")]
cat_id: i32,
content: String,
}
#[derive(Serialize)]
#[serde(rename = "information")]
struct Information {
#[serde(rename = "#content")]
items: Vec<Item>,
}
#[derive(Serialize)]
#[serde(rename = "result")]
struct Result {
return_code: String,
information: Information,
}
async fn get_headline_all() -> Xml<Vec<u8>> {
let result = Result {
return_code: "OK".to_string(),
information: Information {
items: vec![Item {
title: "Test".to_string(),
published: 1752130800,
updated: 1752130800,
lsb_id: "c8819ec6f93f6c56d760b42c2ba2f43fe6598fc8".to_string(),
lsb_parentid: None,
lsb_tag: None,
cat_id: 1,
content: "Hello, world!".to_string(),
}],
},
};
Xml(serde_xml_rs::to_string(&result)
.unwrap()
.as_bytes()
.to_vec())
} }
#[tokio::main] #[tokio::main]