2024-04-19 23:54:06 +02:00
|
|
|
use crate::database::{redis_conn, redis_key};
|
|
|
|
use crate::service::stream::{publish, Error, Stream};
|
|
|
|
use crate::util::id::get_timestamp;
|
|
|
|
use redis::{streams::StreamMaxlen, Commands};
|
|
|
|
|
|
|
|
#[crate::export]
|
2024-04-20 22:47:11 +02:00
|
|
|
pub fn add_note_to_antenna(antenna_id: &str, note_id: &str) -> Result<(), Error> {
|
2024-04-19 23:54:06 +02:00
|
|
|
redis_conn()?.xadd_maxlen(
|
|
|
|
redis_key(format!("antennaTimeline:{}", antenna_id)),
|
|
|
|
StreamMaxlen::Approx(200),
|
2024-04-20 22:47:11 +02:00
|
|
|
format!("{}-*", get_timestamp(¬e_id)),
|
|
|
|
&[("note", ¬e_id)],
|
2024-04-19 23:54:06 +02:00
|
|
|
)?;
|
|
|
|
|
|
|
|
let stream = Stream::Antenna {
|
|
|
|
id: antenna_id.to_string(),
|
|
|
|
};
|
2024-04-20 22:47:11 +02:00
|
|
|
publish(
|
|
|
|
&stream,
|
|
|
|
Some("note"),
|
|
|
|
Some(format!("{{ \"id\": \"{}\" }}", note_id)),
|
|
|
|
)
|
2024-04-19 23:54:06 +02:00
|
|
|
}
|