-
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: Ask user about messaging in Degraded conversation (WPB-1771) (#…
…2220) * feat: Ask user about messaging in Degraded conversation * Review fixes
- Loading branch information
1 parent
785e56e
commit b0c7e37
Showing
8 changed files
with
165 additions
and
1 deletion.
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
41 changes: 41 additions & 0 deletions
41
.../com/wire/kalium/logic/feature/conversation/ObserveDegradedConversationNotifiedUseCase.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,41 @@ | ||
/* | ||
* 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.feature.conversation | ||
|
||
import com.wire.kalium.logic.data.conversation.ConversationRepository | ||
import com.wire.kalium.logic.data.id.ConversationId | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
/** | ||
* UseCase for observing if User was notified about verification degrading of conversation | ||
*/ | ||
interface ObserveDegradedConversationNotifiedUseCase { | ||
/** | ||
* @return [Flow] of [Boolean], false means conversation's verification degraded and user needs to be notified | ||
* true in other cases. | ||
*/ | ||
suspend operator fun invoke(conversationId: ConversationId): Flow<Boolean> | ||
} | ||
|
||
class ObserveDegradedConversationNotifiedUseCaseImpl internal constructor( | ||
private val conversationRepository: ConversationRepository | ||
) : ObserveDegradedConversationNotifiedUseCase { | ||
|
||
override suspend fun invoke(conversationId: ConversationId): Flow<Boolean> = | ||
conversationRepository.observeDegradedConversationNotified(conversationId) | ||
} |
39 changes: 39 additions & 0 deletions
39
...lin/com/wire/kalium/logic/feature/conversation/SetUserInformedAboutVerificationUseCase.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.feature.conversation | ||
|
||
import com.wire.kalium.logic.data.conversation.ConversationRepository | ||
import com.wire.kalium.logic.data.id.ConversationId | ||
|
||
/** | ||
* UseCase for setting DegradedConversationNotified flag to true, | ||
* means user was notified about verification changes and no need to do it again. | ||
*/ | ||
interface SetUserInformedAboutVerificationUseCase { | ||
suspend operator fun invoke(conversationId: ConversationId) | ||
} | ||
|
||
class SetUserInformedAboutVerificationUseCaseImpl internal constructor( | ||
private val conversationRepository: ConversationRepository | ||
) : SetUserInformedAboutVerificationUseCase { | ||
|
||
override suspend fun invoke(conversationId: ConversationId) { | ||
conversationRepository.setDegradedConversationNotifiedFlag(conversationId, true) | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import kotlin.Boolean; | ||
|
||
ALTER TABLE Conversation | ||
ADD COLUMN degraded_conversation_notified INTEGER AS Boolean NOT NULL DEFAULT 1; | ||
|
||
DROP TRIGGER IF EXISTS addMessageAfterProteusVerificationStatusChange; | ||
|
||
CREATE TRIGGER addMessageAfterProteusVerificationStatusChange | ||
AFTER UPDATE ON Conversation | ||
WHEN new.proteus_verification_status != old.proteus_verification_status | ||
AND (new.proteus_verification_status = "VERIFIED" OR old.proteus_verification_status = "VERIFIED") | ||
BEGIN | ||
INSERT OR IGNORE INTO Message(id, content_type, conversation_id, creation_date, sender_user_id, sender_client_id, status, visibility) | ||
VALUES( | ||
(SELECT lower(hex(randomblob(4)) || '-' || lower(hex(randomblob(2))) || '-4' || | ||
substr(lower(hex(randomblob(2))),2) || '-a' || substr(lower(hex(randomblob(2))),2) | ||
|| '-' || lower(hex(randomblob(6))))), | ||
(CASE (new.proteus_verification_status) | ||
WHEN "VERIFIED" THEN "CONVERSATION_VERIFIED_PROTEUS" | ||
ELSE "CONVERSATION_DEGRADED_PROTEUS" END | ||
), | ||
new.qualified_id, | ||
(SELECT CAST((julianday('now') - 2440587.5) * 86400 * 1000 AS INTEGER)), | ||
(SELECT SelfUser.id FROM SelfUser LIMIT 1), | ||
(SELECT Client.id FROM Client WHERE Client.user_id = (SELECT SelfUser.id FROM SelfUser LIMIT 1) LIMIT 1), | ||
"SENT", | ||
"VISIBLE" | ||
); | ||
|
||
UPDATE Conversation | ||
SET degraded_conversation_notified = (new.proteus_verification_status != "DEGRADED") | ||
WHERE qualified_id = new.qualified_id; | ||
END; |
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