stop logging images
parent
ffe1da65e6
commit
6cea8d18a4
|
@ -15,8 +15,7 @@ final class CoachApi(
|
|||
userRepo: UserRepo,
|
||||
picfitApi: PicfitApi,
|
||||
cacheApi: lila.memo.CacheApi,
|
||||
notifyApi: NotifyApi,
|
||||
irc: lila.irc.IrcApi
|
||||
notifyApi: NotifyApi
|
||||
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||
|
||||
import BsonHandlers._
|
||||
|
@ -73,11 +72,7 @@ final class CoachApi(
|
|||
def uploadPicture(c: Coach.WithUser, picture: PicfitApi.FilePart): Funit =
|
||||
picfitApi
|
||||
.uploadFile(s"coach:${c.coach.id}", picture, userId = c.user.id) flatMap { pic =>
|
||||
coachColl.update.one($id(c.coach.id), $set("picture" -> pic.id)) >>
|
||||
irc.coachImage(
|
||||
c.user,
|
||||
imageUrl = picfitApi.url.thumbnail(pic.id, Coach.imageSize, Coach.imageSize)
|
||||
)
|
||||
coachColl.update.one($id(c.coach.id), $set("picture" -> pic.id)).void
|
||||
}
|
||||
|
||||
private val languagesCache = cacheApi.unit[Set[String]] {
|
||||
|
|
|
@ -21,8 +21,7 @@ final class Env(
|
|||
notifyApi: lila.notify.NotifyApi,
|
||||
cacheApi: lila.memo.CacheApi,
|
||||
db: lila.db.Db,
|
||||
picfitApi: lila.memo.PicfitApi,
|
||||
irc: lila.irc.IrcApi
|
||||
picfitApi: lila.memo.PicfitApi
|
||||
)(implicit ec: scala.concurrent.ExecutionContext, system: akka.actor.ActorSystem) {
|
||||
|
||||
private val config = appConfig.get[CoachConfig]("coach")(AutoConfig.loader)
|
||||
|
@ -35,7 +34,6 @@ final class Env(
|
|||
reviewColl = db(config.reviewColl),
|
||||
picfitApi = picfitApi,
|
||||
notifyApi = notifyApi,
|
||||
irc = irc,
|
||||
cacheApi = cacheApi
|
||||
)
|
||||
|
||||
|
|
|
@ -96,35 +96,6 @@ final class IrcApi(
|
|||
def broadcastError(id: String, name: String, error: String): Funit =
|
||||
zulip(_.broadcast, "lila error log")(s"${markdown.broadcastLink(id, name)} $error")
|
||||
|
||||
def ublogImage(
|
||||
user: User,
|
||||
id: String,
|
||||
slug: String,
|
||||
title: String,
|
||||
imageUrl: String
|
||||
): Funit =
|
||||
zulip(_.image, "blog")(
|
||||
s"[Blog image](${markdown.fixImageUrl(imageUrl)}) in ${markdown
|
||||
.lichessLink(s"/@/${user.username}/blog/$slug/$id", title)} by ${markdown
|
||||
.userLink(user)}"
|
||||
)
|
||||
|
||||
def coachImage(
|
||||
user: User,
|
||||
imageUrl: String
|
||||
): Funit =
|
||||
zulip(_.image, "coach")(
|
||||
s"[Coach image](${markdown.fixImageUrl(imageUrl)}) by ${markdown.userLink(user)}"
|
||||
)
|
||||
|
||||
def streamerImage(
|
||||
user: User,
|
||||
imageUrl: String
|
||||
): Funit =
|
||||
zulip(_.image, "streamer")(
|
||||
s"[Streamer image](${markdown.fixImageUrl(imageUrl)}) by ${markdown.userLink(user)}"
|
||||
)
|
||||
|
||||
def ublogPost(
|
||||
user: User,
|
||||
id: String,
|
||||
|
|
|
@ -92,7 +92,6 @@ private object ZulipClient {
|
|||
val general = "general"
|
||||
val broadcast = "content-broadcast"
|
||||
val blog = "content-blog"
|
||||
val image = "mod-comms-image"
|
||||
type Selector = ZulipClient.stream.type => String
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ final class Env(
|
|||
cacheApi: lila.memo.CacheApi,
|
||||
picfitApi: lila.memo.PicfitApi,
|
||||
notifyApi: lila.notify.NotifyApi,
|
||||
irc: lila.irc.IrcApi,
|
||||
userRepo: lila.user.UserRepo,
|
||||
timeline: lila.hub.actors.Timeline,
|
||||
db: lila.db.Db
|
||||
|
|
|
@ -14,8 +14,7 @@ final class StreamerApi(
|
|||
userRepo: UserRepo,
|
||||
cacheApi: lila.memo.CacheApi,
|
||||
picfitApi: PicfitApi,
|
||||
notifyApi: lila.notify.NotifyApi,
|
||||
irc: lila.irc.IrcApi
|
||||
notifyApi: lila.notify.NotifyApi
|
||||
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||
|
||||
import BsonHandlers._
|
||||
|
@ -120,11 +119,7 @@ final class StreamerApi(
|
|||
def uploadPicture(s: Streamer, picture: PicfitApi.FilePart, by: User): Funit =
|
||||
picfitApi
|
||||
.uploadFile(s"streamer:${s.id}", picture, userId = by.id) flatMap { pic =>
|
||||
coll.update.one($id(s.id), $set("picture" -> pic.id)) >>
|
||||
irc.streamerImage(
|
||||
by,
|
||||
imageUrl = picfitApi.url.thumbnail(pic.id, Streamer.imageSize, Streamer.imageSize)
|
||||
)
|
||||
coll.update.one($id(s.id), $set("picture" -> pic.id)).void
|
||||
}
|
||||
|
||||
// unapprove after a week if you never streamed
|
||||
|
|
|
@ -41,16 +41,15 @@ final class UblogApi(
|
|||
private def onFirstPublish(user: User, blog: UblogBlog, post: UblogPost): Funit =
|
||||
rank.computeRank(blog, post).?? { rank =>
|
||||
colls.post.updateField($id(post.id), "rank", rank).void
|
||||
} >>
|
||||
sendImageToZulip(user, post) >>- {
|
||||
lila.common.Bus.publish(UblogPost.Create(post), "ublogPost")
|
||||
if (blog.visible) {
|
||||
timeline ! Propagate(
|
||||
lila.hub.actorApi.timeline.UblogPost(user.id, post.id.value, post.slug, post.title)
|
||||
).toFollowersOf(user.id)
|
||||
if (blog.modTier.isEmpty) sendPostToZulip(user, blog, post).unit
|
||||
}
|
||||
} >>- {
|
||||
lila.common.Bus.publish(UblogPost.Create(post), "ublogPost")
|
||||
if (blog.visible) {
|
||||
timeline ! Propagate(
|
||||
lila.hub.actorApi.timeline.UblogPost(user.id, post.id.value, post.slug, post.title)
|
||||
).toFollowersOf(user.id)
|
||||
if (blog.modTier.isEmpty) sendPostToZulip(user, blog, post).unit
|
||||
}
|
||||
}
|
||||
|
||||
def getUserBlog(user: User, insertMissing: Boolean = false): Fu[UblogBlog] =
|
||||
getBlog(UblogBlog.Id.User(user.id)) getOrElse {
|
||||
|
@ -110,19 +109,7 @@ final class UblogApi(
|
|||
image <- picfitApi
|
||||
.uploadFile(imageRel(post), picture, userId = user.id)
|
||||
_ <- colls.post.update.one($id(post.id), $set("image" -> image.id))
|
||||
newPost = post.copy(image = image.id.some)
|
||||
_ <- sendImageToZulip(user, newPost)
|
||||
} yield newPost
|
||||
|
||||
private def sendImageToZulip(user: User, post: UblogPost): Funit = post.live ?? post.image ?? { imageId =>
|
||||
irc.ublogImage(
|
||||
user,
|
||||
id = post.id.value,
|
||||
slug = post.slug,
|
||||
title = post.title,
|
||||
imageUrl = UblogPost.thumbnail(picfitApi.url, imageId, _.Small)
|
||||
)
|
||||
}
|
||||
} yield post.copy(image = image.id.some)
|
||||
|
||||
private def sendPostToZulip(user: User, blog: UblogBlog, post: UblogPost): Funit =
|
||||
irc.ublogPost(
|
||||
|
|
Loading…
Reference in New Issue