Packages: from one analysis to unlimited, admin can give them
A fixed catalog (packages.rs, reasoning in docs/csomagok.md): Egy elemzés
2 990 Ft, Páros 6 990 Ft, Család 11 990 Ft (featured), Korlátlan 17 990 Ft
for a year, and two top-ups. Every grant is a package_orders row; units are
credit_ledger rows with reason 'package' and never expire. The unlimited
package is a time-limited 'unlimited' entitlement: analyses use no unit and
persons have no limit, with a daily fair-use cap (UNLIMITED_DAILY_LIMIT, 5);
buying it again extends it by a year.
- GET /v1/packages, mock payment by package id, /v1/me unlimited_until
- POST /v1/admin/users/{id}/packages: give a package as a gift
- /csomagok page; the paid step of an analysis offers three packages with
the bigger one featured; person packs use the catalog; admin user list
has a package column
- PERSON_PACK_SIZE is replaced by the catalog's +5 személy top-up
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -28,6 +28,7 @@ use crate::AppState;
|
||||
use crate::auth::AuthUser;
|
||||
use crate::credits::{self, Unit};
|
||||
use crate::error::{ApiError, ApiResult};
|
||||
use crate::packages;
|
||||
use crate::views::{rfc3339, rfc3339_opt, sha256_hex};
|
||||
use db::Role;
|
||||
|
||||
@@ -118,9 +119,18 @@ async fn request(
|
||||
req: AnalysisRequest,
|
||||
) -> ApiResult<(StatusCode, Json<Value>)> {
|
||||
let language = validate_locale(state, Some(req.language.as_deref().unwrap_or(&auth.user.locale)))?;
|
||||
// Admins get detailed analyses free of charge.
|
||||
// Admins and a running unlimited package (within its daily cap) use no unit.
|
||||
let admin = auth.user.has_role(Role::Admin);
|
||||
let unlimited = !admin && {
|
||||
let mut conn = state.db.acquire().await?;
|
||||
let until = packages::unlimited_until(&mut conn, auth.id()).await?;
|
||||
if until.is_some() {
|
||||
packages::check_fair_use(&mut conn, auth.id(), state.config.unlimited_daily_limit).await?;
|
||||
}
|
||||
until.is_some()
|
||||
};
|
||||
let unit = match target {
|
||||
_ if auth.user.has_role(Role::Admin) => None,
|
||||
_ if admin || unlimited => None,
|
||||
Target::Synastry { .. } => Some(Unit::Synastry),
|
||||
_ => Some(Unit::Natal),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user