Skip to content

Commit 9e20690

Browse files
authored
Merge pull request #127 from rust-lang/fix-zulip-api
Fix Zulip API request
2 parents 9b527db + 8d596e3 commit 9e20690

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

sync-team/src/zulip/api.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -248,16 +248,17 @@ impl ZulipApi {
248248
};
249249

250250
if !add_ids.is_empty() {
251-
let subscriptions = serde_json::to_string(&serde_json::json!({
251+
let subscriptions = serde_json::to_string(&serde_json::json!([{
252252
"name": stream_name,
253-
"description": ""
254-
}))?;
253+
}]))?;
255254
let add_ids = serialize_as_array(add_ids);
256255
submit(reqwest::Method::POST, subscriptions, add_ids)?;
257256
}
258257

259258
if !remove_ids.is_empty() {
260-
let subscriptions = serde_json::to_string(&serde_json::json!([stream_name]))?;
259+
let subscriptions = serde_json::to_string(&serde_json::json!([{
260+
"name": stream_name,
261+
}]))?;
261262
let remove_ids = serialize_as_array(remove_ids);
262263
submit(reqwest::Method::DELETE, subscriptions, remove_ids)?;
263264
}
@@ -286,12 +287,7 @@ impl ZulipApi {
286287

287288
/// Serialize a slice of numbers as a JSON array
288289
fn serialize_as_array(items: &[u64]) -> String {
289-
let items = items
290-
.iter()
291-
.map(|id| id.to_string())
292-
.collect::<Vec<_>>()
293-
.join(",");
294-
format!("[{items}]")
290+
serde_json::to_string(&items).expect("cannot serialize JSON array")
295291
}
296292

297293
/// A collection of Zulip users

0 commit comments

Comments
 (0)