mirror of
https://github.com/InsanusMokrassar/PlaguPoster.git
synced 2024-11-25 08:58:45 +00:00
fixes
This commit is contained in:
parent
7549286c84
commit
4c9b6e485f
@ -97,7 +97,9 @@ class ExposedPostsRepo(
|
||||
}
|
||||
}
|
||||
|
||||
override fun insert(value: NewPost, it: InsertStatement<Number>) {}
|
||||
override fun insert(value: NewPost, it: InsertStatement<Number>) {
|
||||
it[createdColumn] = DateTime.now().unixMillis
|
||||
}
|
||||
|
||||
override suspend fun deleteById(ids: List<PostId>) {
|
||||
onBeforeDelete(ids)
|
||||
|
@ -6,8 +6,7 @@ import dev.inmo.krontab.KrontabTemplate
|
||||
import dev.inmo.krontab.toSchedule
|
||||
import dev.inmo.krontab.utils.asFlow
|
||||
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
|
||||
import dev.inmo.micro_utils.repos.deleteById
|
||||
import dev.inmo.micro_utils.repos.id
|
||||
import dev.inmo.micro_utils.repos.*
|
||||
import dev.inmo.plagubot.Plugin
|
||||
import dev.inmo.plaguposter.posts.repo.PostsRepo
|
||||
import dev.inmo.plaguposter.ratings.models.Rating
|
||||
@ -45,9 +44,11 @@ object Plugin : Plugin {
|
||||
|
||||
config.immediateDrop ?.let { toDrop ->
|
||||
ratingsRepo.onNewValue.subscribeSafelyWithoutExceptions(this) {
|
||||
if (it.value <= toDrop) {
|
||||
postsRepo.deleteById(it.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
config.autoclear ?.let { autoclear ->
|
||||
autoclear.autoClearKrontab.toSchedule().asFlow().subscribeSafelyWithoutExceptions(scope) {
|
||||
val dropCreatedBefore = it - (autoclear.skipPostAge ?: 0).seconds
|
||||
|
@ -21,9 +21,9 @@ import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
@Serializable
|
||||
data class RatingConfig(
|
||||
val min: Rating?,
|
||||
val max: Rating?,
|
||||
val prefer: Prefer,
|
||||
val min: Rating? = null,
|
||||
val max: Rating? = null,
|
||||
val prefer: Prefer = Prefer.Random,
|
||||
val otherwise: RatingConfig? = null,
|
||||
val postAge: Seconds? = null
|
||||
) {
|
||||
|
Loading…
Reference in New Issue
Block a user