complete autofollow
This commit is contained in:
parent
9fec5f1ea8
commit
8334580ddc
|
@ -5,10 +5,12 @@ import lila.user.User
|
|||
|
||||
private[relation] final class Autofollow(api: RelationApi) {
|
||||
|
||||
private val max = 5
|
||||
|
||||
def apply(user: User): Funit = api nbFollowing user.id flatMap { nb ⇒
|
||||
(nb == 0) ?? {
|
||||
BestOpponents(user.id, 5) flatMap { ops ⇒
|
||||
(ops map {
|
||||
BestOpponents(user.id, max * 2) flatMap { ops ⇒
|
||||
(ops take max map {
|
||||
case (op, _) ⇒ api.autofollow(user.id, op.id)
|
||||
}).sequenceFu.void
|
||||
}
|
||||
|
|
|
@ -41,13 +41,12 @@ final class RelationApi(
|
|||
if (u1 == u2) fufail("Cannot follow yourself")
|
||||
else relation(u1, u2) flatMap {
|
||||
case Some(Follow) ⇒ fufail("Already following")
|
||||
case _ ⇒ doFollow(u1, u2, false)
|
||||
case _ ⇒ doFollow(u1, u2)
|
||||
}
|
||||
|
||||
private[relation] def autofollow(u1: ID, u2: ID): Funit =
|
||||
doFollow(u1, u2, true)
|
||||
private[relation] def autofollow(u1: ID, u2: ID): Funit = doFollow(u1, u2)
|
||||
|
||||
private def doFollow(u1: ID, u2: ID, auto: Boolean) =
|
||||
private def doFollow(u1: ID, u2: ID) =
|
||||
RelationRepo.follow(u1, u2) >>
|
||||
refresh(u1, u2) >>-
|
||||
(timeline ! Propagate(
|
||||
|
|
Loading…
Reference in a new issue