summaryrefslogtreecommitdiff
path: root/src/ui/routes/ch
diff options
context:
space:
mode:
authorKit La Touche <kit@transneptune.net>2024-10-25 22:16:03 -0400
committerKit La Touche <kit@transneptune.net>2024-10-25 22:16:03 -0400
commita50911a03c8955e08c77b0f3764dbda963013971 (patch)
tree9f5319191438b85b860ba06c9a203d3f129072a1 /src/ui/routes/ch
parent4c49283553f4b18bb2a74de280b340a073e3253e (diff)
parentc87b5c53077c02bf21234e24bf976aa7a5f2bac8 (diff)
Merge branch 'main' into wip/mobile
Diffstat (limited to 'src/ui/routes/ch')
-rw-r--r--src/ui/routes/ch/channel.rs19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/ui/routes/ch/channel.rs b/src/ui/routes/ch/channel.rs
index a338f1f..a854f14 100644
--- a/src/ui/routes/ch/channel.rs
+++ b/src/ui/routes/ch/channel.rs
@@ -6,7 +6,7 @@ pub mod get {
use crate::{
app::App,
- channel,
+ channel::{self, app},
error::Internal,
token::extract::Identity,
ui::{
@@ -21,18 +21,14 @@ pub mod get {
Path(channel): Path<channel::Id>,
) -> Result<Asset, Error> {
let _ = identity.ok_or(Error::NotLoggedIn)?;
- app.channels()
- .get(&channel)
- .await
- .map_err(Error::internal)?
- .ok_or(Error::NotFound)?;
+ app.channels().get(&channel).await.map_err(Error::from)?;
Assets::index().map_err(Error::Internal)
}
#[derive(Debug, thiserror::Error)]
pub enum Error {
- #[error("requested channel not found")]
+ #[error("channel not found")]
NotFound,
#[error("not logged in")]
NotLoggedIn,
@@ -40,9 +36,12 @@ pub mod get {
Internal(Internal),
}
- impl Error {
- fn internal(err: impl Into<Internal>) -> Self {
- Self::Internal(err.into())
+ impl From<app::Error> for Error {
+ fn from(error: app::Error) -> Self {
+ match error {
+ app::Error::NotFound(_) | app::Error::Deleted(_) => Self::NotFound,
+ other => Self::Internal(other.into()),
+ }
}
}