Skip to content

Commit

Permalink
Update to new API
Browse files Browse the repository at this point in the history
  • Loading branch information
dfuchss committed Oct 28, 2024
1 parent e93d0b4 commit 82d42d7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<dependency>
<groupId>org.fuchss</groupId>
<artifactId>matrix-bot-base</artifactId>
<version>0.11.13</version>
<version>0.11.14-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
Expand Down
9 changes: 6 additions & 3 deletions src/main/kotlin/org/fuchss/matrix/yarb/Helper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ package org.fuchss.matrix.yarb

import net.folivo.trixnity.client.room.RoomService
import net.folivo.trixnity.core.model.EventId
import net.folivo.trixnity.core.model.RoomId
import org.fuchss.matrix.bots.firstWithTimeout

suspend fun RoomService.getMessageId(transactionId: String): EventId? {
val outboxWithTransaction = this.getOutbox().firstWithTimeout { it[transactionId] != null } ?: return null
val transaction = outboxWithTransaction[transactionId] ?: return null
suspend fun RoomService.getMessageId(
roomId: RoomId,
transactionId: String
): EventId? {
val transaction = this.getOutbox(roomId, transactionId)
return transaction.firstWithTimeout { it?.eventId != null }?.eventId
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class ReminderCommand(
text("I'll remind all people at $time with '${timeXmessage[1]}'. If you want to receive a message please click on $EMOJI")
}
logger.debug("Bot Message TransactionId: {}", botMessageTransactionId)
val botMessageId = matrixBot.room().getMessageId(botMessageTransactionId)
val botMessageId = matrixBot.room().getMessageId(roomId, botMessageTransactionId)
if (botMessageId == null) {
logger.error("Could not send bot message :( -- TransactionId: {}", botMessageTransactionId)
return
Expand All @@ -96,7 +96,7 @@ class ReminderCommand(
react(botMessageId, EMOJI)
}
logger.debug("Bot Reaction Message TransactionId: {}", botReactionMessageTransactionId)
val botReactionMessageId = matrixBot.room().getMessageId(botReactionMessageTransactionId)
val botReactionMessageId = matrixBot.room().getMessageId(roomId, botReactionMessageTransactionId)
if (botReactionMessageId == null) {
logger.error("Could not send bot reaction message :( -- TransactionId: {}", botReactionMessageTransactionId)
return
Expand Down

0 comments on commit 82d42d7

Please sign in to comment.