-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: handle code update and delete events #1960
Merged
MohamadJaara
merged 21 commits into
feat/create-password-protected-invite-code/epic
from
feat/handle-code-update-and-delete-event
Aug 7, 2023
Merged
Changes from 17 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
450cd7e
CanCreatePasswordProtectedLinksUseCase
MohamadJaara 6de5bf0
docs
MohamadJaara 85e0067
detekt
MohamadJaara 71f615c
test
MohamadJaara bea3b98
feat: handle code update and delete event
MohamadJaara 291a3a1
test
MohamadJaara 8319d74
code delete code
MohamadJaara 2afac1a
Merge branch 'feat/create-password-protected-invite-code/epic' into f…
MohamadJaara 104e4b1
inject handler
MohamadJaara 7a652cc
detekt
MohamadJaara ed53d21
add fake value for is password protected
MohamadJaara b2c9208
add has password to event DTO
MohamadJaara 3965904
missing any
MohamadJaara 9edd777
fix test
MohamadJaara 8188474
detekt
MohamadJaara 3d3ce86
db migration
MohamadJaara 3388fbe
typo in db migration
MohamadJaara 40ea534
Update logic/src/commonTest/kotlin/com/wire/kalium/logic/sync/receive…
MohamadJaara 97fe18f
Update logic/src/commonTest/kotlin/com/wire/kalium/logic/sync/receive…
MohamadJaara c5c3795
file name
MohamadJaara 241f2bc
fix(tests): fix e2ei mock order timing
mchenani File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
39 changes: 39 additions & 0 deletions
39
...c/src/commonMain/kotlin/com/wire/kalium/logic/sync/receiver/handler/CodeDeletedHandler.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,39 @@ | ||
/* | ||
* 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.event.Event | ||
import com.wire.kalium.logic.data.id.toDao | ||
import com.wire.kalium.logic.functional.Either | ||
import com.wire.kalium.logic.wrapStorageRequest | ||
import com.wire.kalium.persistence.dao.conversation.ConversationDAO | ||
|
||
internal interface CodeDeletedHandler { | ||
suspend fun handle(event: Event.Conversation.CodeDeleted): Either<StorageFailure, Unit> | ||
} | ||
|
||
internal class CodeDeletedHandlerImpl internal constructor( | ||
private val conversationDAO: ConversationDAO | ||
) : CodeDeletedHandler { | ||
override suspend fun handle(event: Event.Conversation.CodeDeleted) = wrapStorageRequest { | ||
conversationDAO.updateGuestRoomLink( | ||
event.conversationId.toDao(), null, false | ||
) | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...c/src/commonMain/kotlin/com/wire/kalium/logic/sync/receiver/handler/CodeUpdatedHandler.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,39 @@ | ||
/* | ||
* 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.event.Event | ||
import com.wire.kalium.logic.data.id.toDao | ||
import com.wire.kalium.logic.functional.Either | ||
import com.wire.kalium.logic.wrapStorageRequest | ||
import com.wire.kalium.persistence.dao.conversation.ConversationDAO | ||
|
||
internal interface CodeUpdatedHandler { | ||
suspend fun handle(event: Event.Conversation.CodeUpdated): Either<StorageFailure, Unit> | ||
} | ||
|
||
internal class CodeUpdateHandlerImpl internal constructor( | ||
private val conversationDAO: ConversationDAO | ||
) : CodeUpdatedHandler { | ||
override suspend fun handle(event: Event.Conversation.CodeUpdated) = wrapStorageRequest { | ||
conversationDAO.updateGuestRoomLink( | ||
event.conversationId.toDao(), event.uri, event.isPasswordProtected | ||
) | ||
} | ||
} |
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
69 changes: 69 additions & 0 deletions
69
.../commonTest/kotlin/com/wire/kalium/logic/sync/receiver/conversation/CodeDeletedHandler.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,69 @@ | ||
/* | ||
* 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.conversation | ||
|
||
import com.wire.kalium.logic.data.event.Event | ||
import com.wire.kalium.logic.data.id.ConversationId | ||
import com.wire.kalium.logic.sync.receiver.handler.CodeDeletedHandler | ||
import com.wire.kalium.logic.sync.receiver.handler.CodeDeletedHandlerImpl | ||
import com.wire.kalium.logic.util.arrangement.dao.ConversionDAOArrangement | ||
import com.wire.kalium.logic.util.arrangement.dao.ConversionDAOArrangementImpl | ||
import com.wire.kalium.persistence.dao.ConversationIDEntity | ||
import io.mockative.eq | ||
import io.mockative.once | ||
import io.mockative.verify | ||
import kotlinx.coroutines.test.runTest | ||
import kotlin.test.Test | ||
|
||
class CodeDeletedHandlerTest { | ||
MohamadJaara marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@Test | ||
fun givenCodeUpdateEvent_whenhandlerIsInvoked_thenCodeIsUpdated() = runTest { | ||
MohamadJaara marked this conversation as resolved.
Show resolved
Hide resolved
|
||
val (arrangement, handler) = Arrangement().arrange { | ||
withUpdatedGuestRoomLink() | ||
} | ||
|
||
val event = Event.Conversation.CodeDeleted( | ||
conversationId = ConversationId("conversationId", "domain"), | ||
id = "event-id", | ||
transient = false | ||
) | ||
|
||
handler.handle(event) | ||
|
||
verify(arrangement.conversionDAO) | ||
.suspendFunction(arrangement.conversionDAO::updateGuestRoomLink) | ||
.with( | ||
eq(ConversationIDEntity( | ||
event.conversationId.value, | ||
event.conversationId.domain | ||
)), | ||
eq(null as String?), | ||
eq(false) | ||
).wasInvoked(exactly = once) | ||
} | ||
|
||
private class Arrangement : ConversionDAOArrangement by ConversionDAOArrangementImpl() { | ||
|
||
private val handler: CodeDeletedHandler = CodeDeletedHandlerImpl(conversionDAO) | ||
|
||
fun arrange(block: Arrangement.() -> Unit) = apply(block).run { | ||
this to handler | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The model returned from the remote request needs to be changed and will be part of the next PR