Fix patron gift when the receiver is already patron.
Previously nothing was changed for the receiver.deepcrayonfish^2
parent
d68fb2c5e7
commit
61eb1b5533
|
@ -282,9 +282,9 @@ final class PlanApi(
|
|||
.void >> setDbUserPlanOnCharge(user, levelUp = false)
|
||||
|
||||
def gift(from: User, to: User, money: Money): Funit =
|
||||
!to.isPatron ?? {
|
||||
for {
|
||||
isLifetime <- pricingApi isLifetime money
|
||||
toPatronOpt <- userPatron(to)
|
||||
isLifetime <- fuccess(~toPatronOpt.map(_.isLifetime)) >>| (pricingApi isLifetime money)
|
||||
_ <- patronColl.update
|
||||
.one(
|
||||
$id(to.id),
|
||||
|
@ -296,12 +296,11 @@ final class PlanApi(
|
|||
),
|
||||
upsert = true
|
||||
)
|
||||
newTo = to.mapPlan(_.incMonths)
|
||||
newTo = to.mapPlan(p => if (~toPatronOpt.map(_.canLevelUp)) p.incMonths else p.enable)
|
||||
_ <- setDbUserPlan(newTo)
|
||||
} yield {
|
||||
notifier.onGift(from, newTo, isLifetime)
|
||||
}
|
||||
}
|
||||
|
||||
def recentGiftFrom(from: User): Fu[Option[Patron]] =
|
||||
patronColl
|
||||
|
|
Loading…
Reference in New Issue