patron renew timeline entry - for lichess-org/tavern#90
will probably require better computing the number of months and fixing what's already in DBchatPatron
parent
20f5732af1
commit
38921b8dc1
|
@ -101,6 +101,11 @@ object timeline {
|
|||
a(href := routes.Plan.index)(
|
||||
trans.patron.xBecamePatron(userIdLink(userId.some, withOnline = true))
|
||||
)
|
||||
case PlanRenew(userId, months) =>
|
||||
a(href := routes.Plan.index)(
|
||||
trans.patron.xIsPatronForNbMonths
|
||||
.plural(months, userIdLink(userId.some, withOnline = true), months)
|
||||
)
|
||||
case BlogPost(id, slug, title) =>
|
||||
a(cls := "text", dataIcon := "6", href := routes.Blog.show(id, slug))(title)
|
||||
case StreamStart(id, name) =>
|
||||
|
|
|
@ -168,6 +168,9 @@ package timeline {
|
|||
case class PlanStart(userId: String) extends Atom("planStart", true) {
|
||||
def userIds = List(userId)
|
||||
}
|
||||
case class PlanRenew(userId: String, months: Int) extends Atom("planRenew", true) {
|
||||
def userIds = List(userId)
|
||||
}
|
||||
case class BlogPost(id: String, slug: String, title: String) extends Atom("blogPost", true) {
|
||||
def userIds = Nil
|
||||
}
|
||||
|
|
|
@ -1378,6 +1378,7 @@ val `checkOutProfile` = new I18nKey("patron:checkOutProfile")
|
|||
val `nowLifetime` = new I18nKey("patron:nowLifetime")
|
||||
val `nowOneMonth` = new I18nKey("patron:nowOneMonth")
|
||||
val `downgradeNextMonth` = new I18nKey("patron:downgradeNextMonth")
|
||||
val `xIsPatronForNbMonths` = new I18nKey("patron:xIsPatronForNbMonths")
|
||||
val `patronForMonths` = new I18nKey("patron:patronForMonths")
|
||||
}
|
||||
|
||||
|
|
|
@ -142,7 +142,8 @@ final class PlanApi(
|
|||
.levelUpIfPossible
|
||||
.expireInOneMonth
|
||||
patronColl.update.one($id(patron.id), p2) >>
|
||||
setDbUserPlanOnCharge(user, patron.canLevelUp)
|
||||
setDbUserPlanOnCharge(user, patron.canLevelUp) >>-
|
||||
notifier.onRenew(user)
|
||||
} >> {
|
||||
charge.lifetimeWorthy ?? setLifetime(user)
|
||||
} >>- logger.info(s"Charged ${user.username} with paypal: $cents")
|
||||
|
|
|
@ -21,6 +21,11 @@ final private[plan] class PlanNotifier(
|
|||
timeline ! (msg toFollowersOf user.id)
|
||||
}
|
||||
|
||||
def onRenew(user: User): Unit = {
|
||||
val msg = Propagate(lila.hub.actorApi.timeline.PlanRenew(user.id, user.plan.months))
|
||||
timeline ! (msg toFollowersOf user.id)
|
||||
}
|
||||
|
||||
def onExpire(user: User): Unit =
|
||||
lila.common.Bus.publish(lila.hub.actorApi.plan.PlanExpire(user.id), "planExpire")
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ case class Entry(
|
|||
case "simul-join" => simulJoinHandler.readTry(data).get
|
||||
case "study-like" => studyLikeHandler.readTry(data).get
|
||||
case "plan-start" => planStartHandler.readTry(data).get
|
||||
case "plan-renew" => planRenewHandler.readTry(data).get
|
||||
case "blog-post" => blogPostHandler.readTry(data).get
|
||||
case "stream-start" => streamStartHandler.readTry(data).get
|
||||
case _ => sys error s"Unhandled atom type: $typ"
|
||||
|
@ -72,6 +73,7 @@ object Entry {
|
|||
case d: SimulJoin => "simul-join" -> toBson(d)
|
||||
case d: StudyLike => "study-like" -> toBson(d)(studyLikeHandler)
|
||||
case d: PlanStart => "plan-start" -> toBson(d)(planStartHandler)
|
||||
case d: PlanRenew => "plan-renew" -> toBson(d)(planRenewHandler)
|
||||
case d: BlogPost => "blog-post" -> toBson(d)(blogPostHandler)
|
||||
case d: StreamStart => "stream-start" -> toBson(d)(streamStartHandler)
|
||||
}
|
||||
|
@ -91,6 +93,7 @@ object Entry {
|
|||
implicit val simulJoinHandler = Macros.handler[SimulJoin]
|
||||
implicit val studyLikeHandler = Macros.handler[StudyLike]
|
||||
implicit val planStartHandler = Macros.handler[PlanStart]
|
||||
implicit val planRenewHandler = Macros.handler[PlanRenew]
|
||||
implicit val blogPostHandler = Macros.handler[BlogPost]
|
||||
implicit val streamStartHandler = Macros.handler[StreamStart]
|
||||
}
|
||||
|
@ -106,6 +109,7 @@ object Entry {
|
|||
implicit val simulJoinWrite = Json.writes[SimulJoin]
|
||||
implicit val studyLikeWrite = Json.writes[StudyLike]
|
||||
implicit val planStartWrite = Json.writes[PlanStart]
|
||||
implicit val planRenewWrite = Json.writes[PlanRenew]
|
||||
implicit val blogPostWrite = Json.writes[BlogPost]
|
||||
implicit val streamStartWrite = Json.writes[StreamStart]
|
||||
implicit val atomWrite = Writes[Atom] {
|
||||
|
@ -119,6 +123,7 @@ object Entry {
|
|||
case d: SimulJoin => simulJoinWrite writes d
|
||||
case d: StudyLike => studyLikeWrite writes d
|
||||
case d: PlanStart => planStartWrite writes d
|
||||
case d: PlanRenew => planRenewWrite writes d
|
||||
case d: BlogPost => blogPostWrite writes d
|
||||
case d: StreamStart => streamStartWrite writes d
|
||||
}
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
<string name="freeAccount">Free account</string>
|
||||
<string name="becomePatron">Become a Lichess Patron</string>
|
||||
<string name="xBecamePatron">%s became a Lichess Patron</string>
|
||||
<plurals name="xIsPatronForNbMonths">
|
||||
<item quantity="one">%1$s is a Lichess Patron for %2$s month</item>
|
||||
<item quantity="other">%1$s is a Lichess Patron for %2$s months</item>
|
||||
</plurals>
|
||||
<string name="newPatrons">New Patrons</string>
|
||||
<string name="freeChess">Free chess for everyone, forever!</string>
|
||||
<string name="noAdsNoSubs">No ads, no subscriptions; but open-source and passion.</string>
|
||||
|
|
Loading…
Reference in New Issue