diff options
author | Paweł Dybiec <pawel@dybiec.info> | 2022-12-27 16:01:09 +0000 |
---|---|---|
committer | Paweł Dybiec <pawel@dybiec.info> | 2022-12-27 16:01:09 +0000 |
commit | aa7be1ac8f958fd6d17834aaedd2eefbf1d60968 (patch) | |
tree | bd5243c94d3f631a6257fe8bcf2666655789da3d /src | |
parent | [CI] Add sqlite to docker and builds (diff) |
Treat missing mentions as empty list
Diffstat (limited to 'src')
-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(); + } } |