Create subscription relationship only if subscription is still active

This prevents spurious expiration notifications after withdrawals.
This commit is contained in:
silverpill 2022-09-08 09:53:09 +00:00
parent 79e161c131
commit 78b9fc7878

View file

@ -77,7 +77,9 @@ pub async fn update_subscription(
let row = maybe_row.ok_or(DatabaseError::NotFound("subscription"))?;
let sender_id: Uuid = row.try_get("sender_id")?;
let recipient_id: Uuid = row.try_get("recipient_id")?;
subscribe_opt(&transaction, &sender_id, &recipient_id).await?;
if *expires_at > Utc::now() {
subscribe_opt(&transaction, &sender_id, &recipient_id).await?;
};
transaction.commit().await?;
Ok(())
}