Add back set_json. No idea when it disappeared?

This commit is contained in:
bitfl0wer 2023-08-15 22:19:47 +02:00
parent 9dc86615a4
commit 7fdbe38843
No known key found for this signature in database
GPG Key ID: 0ACD574FCF5226CF
1 changed files with 6 additions and 3 deletions

View File

@ -1,7 +1,8 @@
use crate::errors::GatewayError; use crate::errors::GatewayError;
use crate::gateway::events::Events; use crate::gateway::events::Events;
use crate::types::{self, Channel, ChannelUpdate, Composite, Snowflake}; use crate::types::{
use crate::types::{UpdateMessage, WebSocketEvent}; self, Channel, ChannelUpdate, Composite, JsonField, Snowflake, UpdateMessage, WebSocketEvent,
};
use async_trait::async_trait; use async_trait::async_trait;
use std::any::Any; use std::any::Any;
use std::collections::HashMap; use std::collections::HashMap;
@ -496,7 +497,8 @@ impl Gateway {
match event_name.as_str() { match event_name.as_str() {
$($name => { $($name => {
let event = &mut self.events.lock().await.$($path).+; let event = &mut self.events.lock().await.$($path).+;
match serde_json::from_str(gateway_payload.event_data.unwrap().get()) { let json = gateway_payload.event_data.unwrap().get();
match serde_json::from_str(json) {
Err(err) => warn!("Failed to parse gateway event {event_name} ({err})"), Err(err) => warn!("Failed to parse gateway event {event_name} ({err})"),
Ok(message) => { Ok(message) => {
$( $(
@ -506,6 +508,7 @@ impl Gateway {
// `object` is the current value of the `watch::channel`. It's being passed into `message.update()` to be modified // `object` is the current value of the `watch::channel`. It's being passed into `message.update()` to be modified
// within the closure function. Then, this closure is passed to the `tx.send_modify()` method which applies the // within the closure function. Then, this closure is passed to the `tx.send_modify()` method which applies the
// modification to the current value of the watch channel. // modification to the current value of the watch channel.
message.set_json(json.to_string());
tx.send_modify(|object| message.update(object.clone())); tx.send_modify(|object| message.update(object.clone()));
} else { } else {
warn!("Received {} for {}, but it has been observed to be a different type!", $name, message.id()) warn!("Received {} for {}, but it has been observed to be a different type!", $name, message.id())