fix blocking lichess messengers
parent
7638923d1c
commit
6f5945cd8a
|
@ -15,6 +15,7 @@ import tube.threadTube
|
||||||
final class Api(
|
final class Api(
|
||||||
unreadCache: UnreadCache,
|
unreadCache: UnreadCache,
|
||||||
maxPerPage: Int,
|
maxPerPage: Int,
|
||||||
|
blocks: (String, String) => Fu[Boolean],
|
||||||
bus: lila.common.Bus) {
|
bus: lila.common.Bus) {
|
||||||
|
|
||||||
def inbox(me: User, page: Int): Fu[Paginator[Thread]] = Paginator(
|
def inbox(me: User, page: Int): Fu[Paginator[Thread]] = Paginator(
|
||||||
|
@ -50,17 +51,21 @@ final class Api(
|
||||||
val thread = (me.troll && !Granter(_.MarkTroll)(invited)).fold(
|
val thread = (me.troll && !Granter(_.MarkTroll)(invited)).fold(
|
||||||
t deleteFor invited,
|
t deleteFor invited,
|
||||||
t)
|
t)
|
||||||
$insert(thread) >>- updateUser(invited.id) inject thread
|
sendUnlessBlocked(thread) >>- updateUser(invited.id) inject thread
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def lichessThread(lt: LichessThread): Funit =
|
def lichessThread(lt: LichessThread): Funit = sendUnlessBlocked(Thread.make(
|
||||||
$insert(Thread.make(
|
name = lt.subject,
|
||||||
name = lt.subject,
|
text = lt.message,
|
||||||
text = lt.message,
|
creatorId = lt.from,
|
||||||
creatorId = lt.from,
|
invitedId = lt.to)) >> unreadCache.clear(lt.to)
|
||||||
invitedId = lt.to)) >> unreadCache.clear(lt.to)
|
|
||||||
|
private def sendUnlessBlocked(thread: Thread): Funit =
|
||||||
|
blocks(thread.invitedId, thread.creatorId) flatMap {
|
||||||
|
!_ ?? $insert(thread)
|
||||||
|
}
|
||||||
|
|
||||||
def makePost(thread: Thread, text: String, me: User) = {
|
def makePost(thread: Thread, text: String, me: User) = {
|
||||||
val post = Post.make(
|
val post = Post.make(
|
||||||
|
|
|
@ -24,6 +24,7 @@ final class Env(
|
||||||
lazy val api = new Api(
|
lazy val api = new Api(
|
||||||
unreadCache = unreadCache,
|
unreadCache = unreadCache,
|
||||||
maxPerPage = ThreadMaxPerPage,
|
maxPerPage = ThreadMaxPerPage,
|
||||||
|
blocks = blocks,
|
||||||
bus = system.lilaBus)
|
bus = system.lilaBus)
|
||||||
|
|
||||||
system.actorOf(Props(new Actor {
|
system.actorOf(Props(new Actor {
|
||||||
|
|
Loading…
Reference in New Issue