forked from lichess-org/lila
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
751 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package lila.db | ||
|
||
import reactivemongo.bson._ | ||
|
||
import Types.Coll | ||
|
||
object Util { | ||
|
||
def findNextId(coll: Coll): Fu[Int] = | ||
coll.find(BSONDocument(), BSONDocument("_id" -> true)) | ||
.sort(BSONDocument("_id" -> -1)) | ||
.one[BSONDocument] map { | ||
_ flatMap { doc => doc.getAs[Int]("_id") map (1+) } getOrElse 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package lila.qa | ||
|
||
import play.api.data._ | ||
import play.api.data.Forms._ | ||
|
||
object Forms { | ||
|
||
lazy val question = Form( | ||
mapping( | ||
"title" -> nonEmptyText(minLength = 10, maxLength = 150), | ||
"body" -> nonEmptyText(minLength = 10, maxLength = 10000), | ||
"hidden-tags" -> text | ||
)(QuestionData.apply)(QuestionData.unapply) | ||
) | ||
|
||
def editQuestion(q: Question) = question fill QuestionData( | ||
title = q.title, | ||
body = q.body, | ||
`hidden-tags` = q.tags mkString ",") | ||
|
||
case class QuestionData(title: String, body: String, `hidden-tags`: String) { | ||
|
||
def tags = `hidden-tags`.split(',').toList.map(_.trim).filter(_.nonEmpty) | ||
} | ||
|
||
lazy val answer = Form( | ||
mapping( | ||
"body" -> nonEmptyText(minLength = 30) | ||
)(AnswerData.apply)(AnswerData.unapply) | ||
) | ||
|
||
case class AnswerData(body: String) | ||
|
||
lazy val comment = Form( | ||
mapping( | ||
"body" -> nonEmptyText(minLength = 20) | ||
)(CommentData.apply)(CommentData.unapply) | ||
) | ||
|
||
case class CommentData(body: String) | ||
|
||
val vote = Form(single( | ||
"vote" -> number | ||
)) | ||
|
||
val favorite = Form(single( | ||
"favorite" -> number | ||
)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package lila.qa | ||
|
||
import com.typesafe.config.Config | ||
import lila.common.PimpedConfig._ | ||
|
||
final class Env( | ||
config: Config, | ||
db: lila.db.Env) { | ||
|
||
private val CollectionQuestion = config getString "collection.question" | ||
|
||
// def forms = DataForm | ||
|
||
// lazy val api = new qaApi(db(Collectionqa), MonthlyGoal) | ||
} | ||
|
||
object Env { | ||
|
||
lazy val current = "[boot] donation" describes new Env( | ||
config = lila.common.PlayApp loadConfig "donation", | ||
db = lila.db.Env.current) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package lila.qa | ||
|
||
import lila.common.String._ | ||
import lila.user.User | ||
|
||
private[qa] final class Mailer(sender: String) { | ||
|
||
private[qa] def createAnswer(q: Question, a: Answer, u: User, favoriters: List[User]): Funit = ??? | ||
// send( | ||
// to = (rudyEmail :: user.email :: favoriters.map(_.email)) filterNot (u.email.==), | ||
// subject = s"""${u.displaynameOrFullname} answered your question""", | ||
// content = s"""New answer on prismic.io Q&A: ${questionUrl(q)}#answer-${a.id} | ||
|
||
|
||
// By ${u.displaynameOrFullname} | ||
// On question <b>${q.title}</b> | ||
|
||
// ${a.body} | ||
|
||
// URL: ${questionUrl(q)}#answer-${a.id}""") | ||
|
||
private[qa] def createQuestionComment(q: Question, c: Comment, u: User): Funit = ??? | ||
// send( | ||
// to = List(rudyEmail, questionAuthor.email) filterNot (u.email.==), | ||
// subject = s"""${u.displaynameOrFullname} commented your question""", | ||
// content = s"""New comment on prismic.io Q&A: ${questionUrl(question)}#comment-${c.id} | ||
|
||
|
||
// By ${u.displaynameOrFullname} | ||
// On question <b>${question.title}</b> | ||
|
||
// ${c.body} | ||
|
||
// URL: ${questionUrl(question)}#comment-${c.id}""") | ||
// case _ => Future successful () | ||
|
||
private[qa] def createAnswerComment(q: Question, a: Answer, c: Comment, u: User): Funit = | ||
??? | ||
// QaApi.answer.withUser(a) flatMap { | ||
// case Some(AnswerWithUser(answer, answerAuthor)) => send( | ||
// to = List(rudyEmail, answerAuthor.email) filterNot (u.email.==), | ||
// subject = s"""${u.displaynameOrFullname} commented your answer""", | ||
// content = s"""New comment on prismic.io Q&A: ${questionUrl(q)}#comment-${c.id} | ||
|
||
|
||
// By ${u.displaynameOrFullname} | ||
// On question <b>${q.title}</b> | ||
|
||
// ${c.body} | ||
|
||
// URL: ${questionUrl(q)}#comment-${c.id}""") | ||
|
||
private def questionUrl(q: Question) = | ||
s"http:https://lichess.org/qa/${q.id}/${q.slug}" | ||
|
||
private def send(to: List[String], subject: String, content: String) = { | ||
to foreach { recipient => | ||
// common.utils.Mailer.send( | ||
// to = recipient, | ||
// from = Some(sender), | ||
// fromname = Some(common.Wroom.domain), | ||
// subject = s"[Q&A] $subject", | ||
// content = Html(nl2br(content))) | ||
} | ||
fuccess(()) | ||
} | ||
} | ||
|
Oops, something went wrong.