chore (backend-rs): address nightly clippy warnings

This commit is contained in:
naskya 2024-08-02 02:51:42 +09:00
parent dc2b452e5a
commit 27f2a6b080
No known key found for this signature in database
GPG key ID: 712D413B3A9FED5C
3 changed files with 9 additions and 14 deletions

View file

@ -86,15 +86,14 @@ pub async fn set<V: for<'a> Deserialize<'a> + Serialize>(
value: &V,
ttl: Duration,
) -> Result<(), Error> {
redis_conn()
Ok(redis_conn()
.await?
.set_ex(
prefix_key(key),
rmp_serde::encode::to_vec(&value)?,
ttl.num_seconds().try_into().map_err(|_| Error::TTL)?,
)
.await?;
Ok(())
.await?)
}
/// Gets a Redis cache.

View file

@ -60,8 +60,11 @@ pub async fn update_antennas_on_new_note(
}
async fn add_note_to_antenna(antenna_id: &str, note: &Note) -> Result<(), Error> {
// for streaming API
stream::antenna::publish(antenna_id.to_owned(), note).await?;
// for timeline API
redis_conn()
Ok(redis_conn()
.await?
.xadd_maxlen(
redis_key(format!("antennaTimeline:{}", antenna_id)),
@ -69,10 +72,5 @@ async fn add_note_to_antenna(antenna_id: &str, note: &Note) -> Result<(), Error>
format!("{}-*", get_timestamp(&note.id)?),
&[("note", &note.id)],
)
.await?;
// for streaming API
stream::antenna::publish(antenna_id.to_owned(), note).await?;
Ok(())
.await?)
}

View file

@ -112,13 +112,11 @@ pub async fn publish_to_stream(
value.ok_or(Error::InvalidContent)?
};
redis_conn()
Ok(redis_conn()
.await?
.publish(
&CONFIG.host,
format!("{{\"channel\":\"{}\",\"message\":{}}}", channel, message),
)
.await?;
Ok(())
.await?)
}