Skip to content

Commit

Permalink
fix: double wrapped feature section
Browse files Browse the repository at this point in the history
  • Loading branch information
ctron committed Feb 21, 2022
1 parent 9ac4793 commit c22c3e7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions doppelgaenger-input/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl Processor {
}

async fn process(&self, event: TwinEvent) -> Result<(), TwinEventError> {
log::info!("Processing twin event: {event:?}");
log::debug!("Processing twin event: {event:?}");

let collection = self.db.collection::<ThingState>(&event.application);

Expand Down Expand Up @@ -157,7 +157,7 @@ impl Processor {
"$set": update,
};

log::info!("Request update: {:#?}", update);
log::debug!("Request update: {:#?}", update);

collection
.update_one(
Expand Down Expand Up @@ -219,7 +219,7 @@ impl TryFrom<Event> for TwinEvent {
type Error = TwinEventError;

fn try_from(event: Event) -> Result<Self, Self::Error> {
let (application, device, payload) = match (
let (application, device, mut payload) = match (
event.extension("application").cloned(),
event.extension("device").cloned(),
payload(event),
Expand All @@ -229,15 +229,15 @@ impl TryFrom<Event> for TwinEvent {
Some(ExtensionValue::String(device)),
Some(payload),
) => {
log::trace!("Payload: {:#?}", payload);
log::debug!("Payload: {:#?}", payload);
(application, device, payload)
}
_ => {
return Err(TwinEventError::Conversion("Unknown event".into()));
}
};

let features: Map<String, Value> = serde_json::from_value(payload)
let features: Map<String, Value> = serde_json::from_value(payload["features"].take())
.map_err(|err| TwinEventError::Conversion(format!("Failed to convert: {err}")))?;

Ok(TwinEvent {
Expand Down

0 comments on commit c22c3e7

Please sign in to comment.