Don't create invoice if recipient can't accept subscription payments

This commit is contained in:
silverpill 2023-02-04 17:07:38 +00:00
parent cc43adedcf
commit 09b16599d9
2 changed files with 6 additions and 0 deletions

View file

@ -24,6 +24,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixed ### Fixed
- Change max body size in nginx example config to match app limit. - Change max body size in nginx example config to match app limit.
- Don't create invoice if recipient can't accept subscription payments.
## [1.12.0] - 2023-01-26 ## [1.12.0] - 2023-01-26

View file

@ -195,6 +195,11 @@ async fn create_invoice_view(
let db_client = &**get_database_client(&db_pool).await?; let db_client = &**get_database_client(&db_pool).await?;
let sender = get_profile_by_id(db_client, &invoice_data.sender_id).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_id).await?; let recipient = get_user_by_id(db_client, &invoice_data.recipient_id).await?;
if !recipient.profile.payment_options.any(PaymentType::MoneroSubscription) {
let error_message = "recipient can't accept subscription payments";
return Err(ValidationError(error_message).into());
};
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();