fn read_from_channel(channel: &str, topic: &str) -> Vec<String> {
	let payload = to_string(&json!({
		"method": "read",
		"params": {
			"options": {
				"channel": {
						"name": channel, "topic_type": "dev", "topic_name": topic
					},
					"unread_only": true, "peek": false
				},
			}
		}
	))
	.unwrap();

	let response = api_send(&payload);
	let mut unread: Vec<String> = Vec::new();
	for msg in response["result"]["messages"]
		.as_array()
		.unwrap_or(&vec![json!({})])
		.iter()
	{
		if (msg["msg"]["content"]["type"] == "text") && (msg["msg"]["unread"] == true) {
			let message = msg["msg"]["content"]["text"]["body"].as_str().unwrap_or("");
			unread.push(message.to_owned());
		}
	}
	unread
}
/// Get all unread messages from a specific channel/topic and mark as read.
Get all unread messages from a specific channel/topic and mark as read.
Get all unread messages from a specific channel / topic and mark as read .
fn read_from_channel(channel: &str, topic: &str) -> Vec<String> {
	let payload = to_string(&json!({
		"method": "read",
		"params": {
			"options": {
				"channel": {
						"name": channel, "topic_type": "dev", "topic_name": topic
					},
					"unread_only": true, "peek": false
				},
			}
		}
	))
	.unwrap();
	let response = api_send(&payload);
	let mut unread: Vec<String> = Vec::new();
	for msg in response["result"]["messages"]
		.as_array()
		.unwrap_or(&vec![json!({})])
		.iter()
	{
		if (msg["msg"]["content"]["type"] == "text") && (msg["msg"]["unread"] == true) {
			let message = msg["msg"]["content"]["text"]["body"].as_str().unwrap_or("");
			unread.push(message.to_owned());
		}
	}
	unread
}
fn read_from_channel ( channel : & str , topic : & str ) -> Vec < String > { let payload = to_string ( & json ! ( { " " " " " " { " " { " " { " " channel " " " " " " topic } " " true " " false } } } ) ) . unwrap ( ) ; let response = api_send ( & payload ) ; let mut unread : Vec < String > = Vec :: new ( ) ; for msg in response [ " " ] [ " " ] . as_array ( ) . unwrap_or ( & vec ! [ json ( { } ) ] ) . iter ( ) { if ( msg [ " " ] [ " " ] [ " " ] == " " ) && ( msg [ " " ] [ " " ] == true ) { let message = msg [ " " ] [ " " ] [ " " ] [ " " ] . as_str ( ) . unwrap_or ( " " ) ; unread . push ( message . to_owned ( ) ) ; } } unread }
Get all unread messages from a specific channel/topic and mark as read.
Get all unread messages from a specific channel / topic and mark as read .
channel
&str
topic
&str