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:
parent
eb73af03d6
commit
217ed2466c
4 changed files with 81 additions and 14 deletions
13
Cargo.lock
generated
13
Cargo.lock
generated
|
@ -2579,6 +2579,7 @@ dependencies = [
|
|||
"rkon",
|
||||
"rusqlite",
|
||||
"serde",
|
||||
"serde-xml-rs",
|
||||
"serde_json",
|
||||
"serde_yaml_ng",
|
||||
"sha1_smol",
|
||||
|
@ -3883,6 +3884,18 @@ dependencies = [
|
|||
"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]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.219"
|
||||
|
|
|
@ -65,6 +65,7 @@ serde_json = { version = "1.0", features = ["std"], default-features = false }
|
|||
serde = { version = "1.0", features = ["derive"], default-features = false }
|
||||
serde_json = { version = "1.0", features = ["std"], default-features = false }
|
||||
serde_yaml_ng = { version = "0.10", default-features = false }
|
||||
serde-xml-rs = { version = "0.8", default-features = false }
|
||||
|
||||
# Logging
|
||||
tracing = { version = "0.1", default-features = false }
|
||||
|
|
|
@ -33,6 +33,7 @@ frontier.ffxiv.localhost:80 {
|
|||
header {
|
||||
Server nginx
|
||||
-Via
|
||||
Connection keep-alive
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,10 @@ where
|
|||
{
|
||||
fn into_response(self) -> Response {
|
||||
(
|
||||
[(header::CONTENT_TYPE, HeaderValue::from_static("text/xml"))],
|
||||
[(
|
||||
header::CONTENT_TYPE,
|
||||
HeaderValue::from_static("application/xml"),
|
||||
)],
|
||||
self.0,
|
||||
)
|
||||
.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
|
||||
Xml("<result>
|
||||
Xml(
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><result>
|
||||
<return_code>OK</return_code>
|
||||
<information/>
|
||||
<inquiry_categoryList/>
|
||||
<inquiry_itemList/>
|
||||
<report_itemList/>
|
||||
</result>"
|
||||
.to_string())
|
||||
.as_bytes()
|
||||
.to_vec(),
|
||||
)
|
||||
}
|
||||
|
||||
async fn view_get_init() -> Xml<String> {
|
||||
Xml("<result>
|
||||
async fn view_get_init() -> Xml<Vec<u8>> {
|
||||
Xml(
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><result>
|
||||
<return_code>OK</return_code>
|
||||
<information/>
|
||||
<inquiry_categoryList/>
|
||||
<inquiry_itemList/>
|
||||
<report_itemList/>
|
||||
</result>"
|
||||
.to_string())
|
||||
.as_bytes()
|
||||
.to_vec(),
|
||||
)
|
||||
}
|
||||
|
||||
async fn get_headline_all() -> Xml<String> {
|
||||
Xml("<result>
|
||||
<return_code>OK</return_code>
|
||||
<information>
|
||||
</information>
|
||||
</result>"
|
||||
.to_string())
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename = "item")]
|
||||
struct Item {
|
||||
title: String,
|
||||
published: i64,
|
||||
updated: i64,
|
||||
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]
|
||||
|
|
Loading…
Add table
Reference in a new issue