-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: handle composite action confermation message [part-3] (#1901)
* receive composite messages * map composite to proto * detekt * detekt * db migration * db migration * sqm * map to composite entity * detekt * remove is pending state from the DB * Update logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/MessageContent.kt Co-authored-by: Vitor Hugo Schwaab <[email protected]> * Update logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/MessageContent.kt Co-authored-by: Vitor Hugo Schwaab <[email protected]> * address PR comments * detekt * remove composite message preview mapping * fix migration * feat: use case to execute composite message action * expose use case to message scope * missing param * rename use case * docs * map to proto * merge issues * address PR comments * address PR comments * detekt * handle ButtonActionConfirmation event * add unit test * detekt * detekt * sent the message only to the message original sender * detekt --------- Co-authored-by: Vitor Hugo Schwaab <[email protected]>
- Loading branch information
1 parent
709e72e
commit be085c9
Showing
20 changed files
with
313 additions
and
27 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
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
56 changes: 56 additions & 0 deletions
56
...ain/kotlin/com/wire/kalium/logic/sync/receiver/handler/ButtonActionConfirmationhandler.kt
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,56 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2023 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.kalium.logic.sync.receiver.handler | ||
|
||
import com.wire.kalium.logic.StorageFailure | ||
import com.wire.kalium.logic.data.id.ConversationId | ||
import com.wire.kalium.logic.data.message.CompositeMessageRepository | ||
import com.wire.kalium.logic.data.message.MessageContent | ||
import com.wire.kalium.logic.functional.Either | ||
|
||
internal interface ButtonActionConfirmationHandler { | ||
suspend fun handle( | ||
conversationId: ConversationId, | ||
messageContent: MessageContent.ButtonActionConfirmation | ||
): Either<StorageFailure, Unit> | ||
} | ||
|
||
internal class ButtonActionConfirmationHandlerImpl internal constructor( | ||
private val compositeMessageRepository: CompositeMessageRepository | ||
) : ButtonActionConfirmationHandler { | ||
|
||
override suspend fun handle( | ||
conversationId: ConversationId, | ||
messageContent: MessageContent.ButtonActionConfirmation | ||
): Either<StorageFailure, Unit> { | ||
val messageId = messageContent.referencedMessageId | ||
|
||
return if (messageContent.buttonId != null) { | ||
compositeMessageRepository.markSelected( | ||
messageId = messageId, | ||
conversationId = conversationId, | ||
buttonId = messageContent.buttonId | ||
) | ||
} else { | ||
compositeMessageRepository.resetSelection( | ||
messageId = messageId, | ||
conversationId = conversationId | ||
) | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.