Change invoice API to accept sender ID instead of acct

This commit is contained in:
silverpill 2022-09-06 15:44:30 +00:00
parent 44aebf989a
commit b0e79e26a4
3 changed files with 9 additions and 9 deletions

View file

@ -754,11 +754,11 @@ paths:
schema: schema:
type: object type: object
properties: properties:
sender: sender_id:
description: Sender actor address (webfinger account URI). description: Sender ID.
type: string type: string
example: user@example.org format: uuid
recipient: recipient_id:
description: Recipient ID. description: Recipient ID.
type: string type: string
format: uuid format: uuid

View file

@ -7,8 +7,8 @@ use crate::models::profiles::types::PaymentOption;
#[derive(Deserialize)] #[derive(Deserialize)]
pub struct InvoiceData { pub struct InvoiceData {
pub sender: String, // acct pub sender_id: Uuid,
pub recipient: Uuid, pub recipient_id: Uuid,
} }
#[derive(Serialize)] #[derive(Serialize)]

View file

@ -14,7 +14,7 @@ use crate::mastodon_api::accounts::types::Account;
use crate::mastodon_api::oauth::auth::get_current_user; use crate::mastodon_api::oauth::auth::get_current_user;
use crate::models::invoices::queries::create_invoice; use crate::models::invoices::queries::create_invoice;
use crate::models::profiles::queries::{ use crate::models::profiles::queries::{
get_profile_by_acct, get_profile_by_id,
update_profile, update_profile,
}; };
use crate::models::profiles::types::{ use crate::models::profiles::types::{
@ -177,8 +177,8 @@ async fn create_invoice_view(
.monero_config() .monero_config()
.ok_or(HttpError::NotSupported)?; .ok_or(HttpError::NotSupported)?;
let db_client = &**get_database_client(&db_pool).await?; let db_client = &**get_database_client(&db_pool).await?;
let sender = get_profile_by_acct(db_client, &invoice_data.sender).await?; let sender = get_profile_by_id(db_client, &invoice_data.sender_id).await?;
let recipient = get_user_by_id(db_client, &invoice_data.recipient).await?; let recipient = get_user_by_id(db_client, &invoice_data.recipient_id).await?;
let payment_address = create_monero_address(monero_config).await let payment_address = create_monero_address(monero_config).await
.map_err(|_| HttpError::InternalError)? .map_err(|_| HttpError::InternalError)?
.to_string(); .to_string();