use Option.exists - after #10134

deepcrayonfish^2
Thibault Duplessis 2021-11-19 09:45:57 +01:00
parent e874a80bcb
commit edbf998c60
1 changed files with 2 additions and 2 deletions

View File

@ -284,7 +284,7 @@ final class PlanApi(
def gift(from: User, to: User, money: Money): Funit =
for {
toPatronOpt <- userPatron(to)
isLifetime <- fuccess(~toPatronOpt.map(_.isLifetime)) >>| (pricingApi isLifetime money)
isLifetime <- fuccess(toPatronOpt.exists(_.isLifetime)) >>| (pricingApi isLifetime money)
_ <- patronColl.update
.one(
$id(to.id),
@ -296,7 +296,7 @@ final class PlanApi(
),
upsert = true
)
newTo = to.mapPlan(p => if (~toPatronOpt.map(_.canLevelUp)) p.incMonths else p.enable)
newTo = to.mapPlan(p => if (toPatronOpt.exists(_.canLevelUp)) p.incMonths else p.enable)
_ <- setDbUserPlan(newTo)
} yield {
notifier.onGift(from, newTo, isLifetime)