only propagate staff forum events to staff members
This commit is contained in:
parent
abc2de6c3c
commit
4099f1eec3
|
@ -42,7 +42,9 @@ final class PostApi(
|
|||
(indexer ! InsertPost(post)) >>
|
||||
(env.recent.invalidate inject post) >>-
|
||||
((ctx.userId ifFalse post.troll) ?? { userId ⇒
|
||||
timeline ! Propagate(ForumPost(userId, topic.name, post.id)).toFriendsOf(userId)
|
||||
timeline ! Propagate(ForumPost(userId, topic.name, post.id)).|>(prop ⇒
|
||||
post.isStaff.fold(prop.toStaffFriendsOf(userId), prop.toFriendsOf(userId))
|
||||
)
|
||||
}) inject post
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,9 @@ private[forum] final class TopicApi(
|
|||
(indexer ! InsertPost(post)) >>
|
||||
env.recent.invalidate >>-
|
||||
((ctx.userId ifFalse post.troll) ?? { userId ⇒
|
||||
timeline ! Propagate(ForumPost(userId, topic.name, post.id)).toFriendsOf(userId)
|
||||
timeline ! Propagate(ForumPost(userId, topic.name, post.id)).|>(prop ⇒
|
||||
post.isStaff.fold(prop.toStaffFriendsOf(userId), prop.toFriendsOf(userId))
|
||||
)
|
||||
}) inject topic
|
||||
}
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ package timeline {
|
|||
sealed trait Propagation
|
||||
case class Users(users: List[String]) extends Propagation
|
||||
case class Friends(user: String) extends Propagation
|
||||
case class StaffFriends(user: String) extends Propagation
|
||||
}
|
||||
|
||||
import propagation._
|
||||
|
@ -74,6 +75,7 @@ package timeline {
|
|||
case class Propagate(data: Atom, propagations: List[Propagation] = Nil) {
|
||||
def toUsers(ids: List[String]) = copy(propagations = Users(ids) :: propagations)
|
||||
def toFriendsOf(id: String) = copy(propagations = Friends(id) :: propagations)
|
||||
def toStaffFriendsOf(id: String) = copy(propagations = StaffFriends(id) :: propagations)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@ import lila.db.api._
|
|||
import lila.hub.actorApi.timeline.propagation._
|
||||
import lila.hub.actorApi.timeline.{ Propagate, Atom, ReloadTimeline }
|
||||
import lila.hub.ActorLazyRef
|
||||
import lila.security.Granter
|
||||
import lila.user.UserRepo
|
||||
import makeTimeout.short
|
||||
import tube.entryTube
|
||||
|
||||
|
@ -33,6 +35,9 @@ private[timeline] final class Push(
|
|||
(propagations map {
|
||||
case Users(ids) ⇒ fuccess(ids)
|
||||
case Friends(id) ⇒ getFriendIds(id) map (_.toList)
|
||||
case StaffFriends(id) ⇒ getFriendIds(id) flatMap UserRepo.byIds map {
|
||||
_ filter Granter(_.StaffForum) map (_.id)
|
||||
}
|
||||
}).sequence map (_.flatten.distinct)
|
||||
|
||||
private def makeEntry(users: List[String], data: Atom): Fu[Entry] =
|
||||
|
|
|
@ -55,7 +55,7 @@ object ApplicationBuild extends Build {
|
|||
libraryDependencies ++= provided(play.api, scalastic)
|
||||
)
|
||||
|
||||
lazy val timeline = project("timeline", Seq(common, db, game, user, hub, relation)).settings(
|
||||
lazy val timeline = project("timeline", Seq(common, db, game, user, hub, security, relation)).settings(
|
||||
libraryDependencies ++= provided(
|
||||
play.api, play.test, reactivemongo, playReactivemongo)
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue