Skip to content

Commit

Permalink
уведомление "Некорректная группа или раздел"
Browse files Browse the repository at this point in the history
  • Loading branch information
maxcom committed Nov 6, 2024
1 parent 2f0c3f9 commit 266dd34
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
6 changes: 6 additions & 0 deletions sql/updates/2024-10-26-warnings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,10 @@
<column name="warning_id"/>
</createIndex>
</changeSet>

<changeSet id="2024110601" author="Maxim Valyanskiy">
<sql>
alter type warning_type add value if not exists 'group'
</sql>
</changeSet>
</databaseChangeLog>
7 changes: 6 additions & 1 deletion src/main/scala/ru/org/linux/warning/Warning.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ sealed trait WarningType {
}

object WarningType {
private val AllTypes = Seq(RuleWarning, TagsWarning, SpellingWarning)
private val AllTypes = Seq(RuleWarning, TagsWarning, SpellingWarning, GroupWarning)
val idToType: Map[String, WarningType] = AllTypes.map(t => t.id -> t).toMap
}

Expand All @@ -51,6 +51,11 @@ object SpellingWarning extends WarningType {
override def name: String = "Опечатка или форматирование"
}

object GroupWarning extends WarningType {
override def id: String = "group"
override def name: String = "Некорректная группа или раздел"
}

case class Warning(id: Int, topicId: Int, commentId: Option[Int], postdate: Instant, authorId: Int, message: String,
warningType: WarningType, closedBy: Option[Int], closedWhen: Option[Instant])

Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/ru/org/linux/warning/WarningController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ class WarningController(warningService: WarningService, topicDao: TopicDao, comm
Seq(RuleWarning)
} else {
if (group.isPremoderated) {
Seq(RuleWarning, SpellingWarning, TagsWarning)
Seq(RuleWarning, SpellingWarning, TagsWarning, GroupWarning)
} else {
Seq(RuleWarning, TagsWarning)
Seq(RuleWarning, TagsWarning, GroupWarning)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/ru/org/linux/warning/WarningService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class WarningService(warningDao: WarningDao, eventService: UserEventService, use
def postWarning(topic: Topic, comment: Option[Comment], author: User, message: String,
warningType: WarningType): Unit = transactional() { _ =>
val notifyList = warningType match {
case RuleWarning =>
case RuleWarning | GroupWarning =>
userService.getModerators.filter(_._2).map(_._1)
case TagsWarning | SpellingWarning =>
(userService.getModerators.filter(_._2).map(_._1) ++ userService.getCorrectors.filter(_._2).map(_._1)).distinct
Expand Down

0 comments on commit 266dd34

Please sign in to comment.