Skip to content

Commit

Permalink
fix(file): Removed unwrap on user because he is always set
Browse files Browse the repository at this point in the history
  • Loading branch information
SamTV12345 committed Dec 30, 2024
1 parent 55cabd4 commit b3804de
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/controllers/settings_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ tag="settings"
#[put("/settings")]
pub async fn update_settings(
settings: web::Json<Setting>,
requester: Option<ReqData<User>>,
requester: ReqData<User>,
) -> Result<HttpResponse, CustomError> {
if !requester.unwrap().is_admin() {
if !requester.is_admin() {
return Err(CustomError::Forbidden);
}
let settings = SettingsService::update_settings(settings.into_inner())?;
Expand Down Expand Up @@ -91,7 +91,7 @@ tag="podcasts"
)]
#[get("/settings/opml/{type_of}")]
pub async fn get_opml(
requester: Option<ReqData<User>>,
requester: ReqData<User>,
type_of: Path<Mode>,
) -> Result<HttpResponse, CustomError> {
let podcasts_found = Podcast::get_all_podcasts()?;
Expand Down Expand Up @@ -143,7 +143,7 @@ fn add_body() -> XMLElement {
fn add_podcasts(
podcasts_found: Vec<Podcast>,
type_of: Mode,
requester: Option<ReqData<User>>,
requester: ReqData<User>,
) -> XMLElement {
let mut body = add_body();
for podcast in podcasts_found {
Expand All @@ -161,11 +161,9 @@ fn add_podcasts(
podcast.id
);

if let Some(req) = requester.as_ref() {
if let Some(api_key) = req.api_key.as_ref() {
if let Some(api_key) = &requester.api_key {
local_url = format!("{}?apiKey={}", local_url, api_key);
}
}

outline.add_attribute("xmlUrl", &local_url)
}
Expand Down

0 comments on commit b3804de

Please sign in to comment.