diff options
Diffstat (limited to 'src/mattermost/model.rs')
-rw-r--r-- | src/mattermost/model.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/mattermost/model.rs b/src/mattermost/model.rs index 9d4d78e..d928359 100644 --- a/src/mattermost/model.rs +++ b/src/mattermost/model.rs @@ -56,7 +56,7 @@ pub struct Posted { pub channel_display_name: String, pub channel_name: String, pub channel_type: String, - #[serde(deserialize_with = "deserialize_json_field")] + #[serde(deserialize_with = "deserialize_json_field", default)] pub mentions: Vec<String>, #[serde(deserialize_with = "deserialize_json_field")] pub post: Post, @@ -296,4 +296,10 @@ mod tests { } ); } + #[test] + fn parse_realexamples() { + let data = r#"{"event":"posted","data":{"channel_display_name":"a","channel_name":"a","channel_type":"O","post":"{\"id\":\"b\",\"create_at\":1,\"update_at\":2,\"edit_at\":0,\"delete_at\":0,\"is_pinned\":false,\"user_id\":\"b\",\"channel_id\":\"c\",\"root_id\":\"\",\"original_id\":\"\",\"message\":\"blah\",\"type\":\"\",\"props\":{\"disable_group_highlight\":true},\"hashtags\":\"\",\"pending_post_id\":\"d\",\"reply_count\":0,\"last_reply_at\":0,\"participants\":null,\"metadata\":{}}","sender_name":"@blah","set_online":true,"team_id":"e"},"broadcast":{"omit_users":null,"user_id":"","channel_id":"f","team_id":"","connection_id":"","omit_connection_id":""},"seq":3}"#; + + serde_json::from_str::<WebsocketUpdate>(data).unwrap(); + } } |