fix: do not unwrap() Option before checking that it holds a value
This commit is contained in:
parent
303060fe84
commit
6c449466a5
1 changed files with 10 additions and 9 deletions
|
@ -1,7 +1,7 @@
|
||||||
use crate::database::db_conn;
|
use crate::database::db_conn;
|
||||||
use crate::misc::get_note_summary::{get_note_summary, NoteLike};
|
use crate::misc::get_note_summary::{get_note_summary, NoteLike};
|
||||||
use crate::misc::meta::fetch_meta;
|
use crate::misc::meta::fetch_meta;
|
||||||
use crate::model::entity::{app, access_token, sw_subscription};
|
use crate::model::entity::{access_token, app, sw_subscription};
|
||||||
use crate::util::http_client;
|
use crate::util::http_client;
|
||||||
use crate::util::id::get_timestamp;
|
use crate::util::id::get_timestamp;
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
|
@ -118,16 +118,17 @@ async fn encode_mastodon_payload(
|
||||||
.one(db)
|
.one(db)
|
||||||
.await?
|
.await?
|
||||||
.ok_or(Error::InvalidContent("access token not found".to_string()))?;
|
.ok_or(Error::InvalidContent("access token not found".to_string()))?;
|
||||||
|
|
||||||
|
let app_id = token
|
||||||
|
.app_id
|
||||||
|
.ok_or(Error::InvalidContent("no app ID".to_string()))?;
|
||||||
|
|
||||||
let client = app::Entity::find()
|
let client = app::Entity::find()
|
||||||
.filter(app::Column::Id.eq(token.app_id.as_ref().unwrap()))
|
.filter(app::Column::Id.eq(app_id))
|
||||||
.one(db)
|
.one(db)
|
||||||
.await?
|
.await?
|
||||||
.ok_or(Error::InvalidContent("app not found".to_string()))?;
|
.ok_or(Error::InvalidContent("app not found".to_string()))?;
|
||||||
|
|
||||||
if token.app_id.is_none() {
|
|
||||||
return Err(Error::InvalidContent("no app ID".to_string()));
|
|
||||||
}
|
|
||||||
|
|
||||||
object.insert(
|
object.insert(
|
||||||
"access_token".to_string(),
|
"access_token".to_string(),
|
||||||
serde_json::to_value(token.token)?,
|
serde_json::to_value(token.token)?,
|
||||||
|
|
Loading…
Reference in a new issue