Skip to content

Commit 63e7382

Browse files
committed
undoc_api: allow for null topic as well
We really can't do much with an entry that is null'd out like this, but we should at least allow parsing that data without error. refs: #352
1 parent 588ee30 commit 63e7382

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

src/__k9_snapshots__/undoc_api/undoc_api_test_get_one_click.snap

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ OneClickResponse {
5959
sku: Some(
6060
"H6072",
6161
),
62-
topic: REDACTED,
62+
topic: Some(
63+
REDACTED,
64+
),
6365
ble_address: Some(
6466
"",
6567
),

src/__k9_snapshots__/undoc_api/undoc_api_test_issue36.snap

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ OneClickResponse {
5959
sku: Some(
6060
"H6199",
6161
),
62-
topic: REDACTED,
62+
topic: Some(
63+
REDACTED,
64+
),
6365
ble_address: Some(
6466
"XX:XX:XX",
6567
),
@@ -165,7 +167,9 @@ OneClickResponse {
165167
sku: Some(
166168
"H6199",
167169
),
168-
topic: REDACTED,
170+
topic: Some(
171+
REDACTED,
172+
),
169173
ble_address: Some(
170174
"XX:XX:XX",
171175
),

src/undoc_api.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -464,11 +464,10 @@ impl GoveeUndocumentedApi {
464464

465465
let mut entries = vec![];
466466
for rule in oc.iot_rules {
467-
let msgs = rule.rule.into_iter().map(|r| r.iot_msg).collect();
468-
entries.push(ParsedOneClickEntry {
469-
topic: rule.device_obj.topic,
470-
msgs,
471-
});
467+
if let Some(topic) = rule.device_obj.topic {
468+
let msgs = rule.rule.into_iter().map(|r| r.iot_msg).collect();
469+
entries.push(ParsedOneClickEntry { topic, msgs });
470+
}
472471
}
473472

474473
result.push(ParsedOneClick { name, entries });
@@ -673,7 +672,7 @@ pub struct OneClickIotRuleDevice {
673672
pub device: Option<String>,
674673
pub sku: Option<String>,
675674

676-
pub topic: Redacted<String>,
675+
pub topic: Option<Redacted<String>>,
677676

678677
pub ble_address: Option<String>,
679678
pub ble_name: Option<String>,

0 commit comments

Comments
 (0)