@@ -16,10 +16,9 @@ import kotlinx.coroutines.sync.Mutex
1616import kotlinx.coroutines.sync.Semaphore
1717import kotlinx.coroutines.sync.withLock
1818import kotlinx.coroutines.sync.withPermit
19- import org.litote.kmongo.and
20- import org.litote.kmongo.eq
21- import org.litote.kmongo.`in`
22- import org.litote.kmongo.newId
19+ import kotlinx.serialization.encodeToString
20+ import kotlinx.serialization.json.Json
21+ import org.litote.kmongo.*
2322import kotlin.coroutines.CoroutineContext
2423import kotlin.time.Duration.Companion.seconds
2524
@@ -42,12 +41,12 @@ class RailTrackPresence(private val kord: Kord, database: Database) : CoroutineS
4241 kord.editPresence {
4342 watching(" ${trip.displayName} to ${trip.destinationStation} " )
4443 }
45- checkNotifications()
4644 } else {
4745 kord.editPresence {
4846 listening(" Einfahrtgeräusche" )
4947 }
5048 }
49+ checkNotifications()
5150 delay(30 .seconds)
5251 }
5352 }
@@ -63,13 +62,8 @@ class RailTrackPresence(private val kord: Kord, database: Database) : CoroutineS
6362 semaphore.withPermit {
6463 val (days, embeds) = buildNotificationMessage(user, notifications)
6564 ? : return @launch
66- val existingNotification =
67- sentNotifications.findOne(
68- and (
69- SentNotification ::user eq user,
70- SentNotification ::days `in ` days,
71- )
72- )
65+ val query = """ {"${' $' } and": [{"user": ${user.value} }, {"days": {"${' $' } in": ${Json .encodeToString(days)} }}]}""" .trimIndent()
66+ val existingNotification = sentNotifications.findOne(query)
7367 runCatching {
7468 val channel = kord.getUser(user)?.getDmChannelOrNull() ? : return @launch
7569 if (existingNotification != null ) {
0 commit comments