Skip to content

Commit

Permalink
Merge branch 'develop' into fix/focus-input-after-rich-text-option
Browse files Browse the repository at this point in the history
  • Loading branch information
Garzas committed Dec 22, 2023
2 parents 29adc32 + 8a9969a commit c4fefad
Show file tree
Hide file tree
Showing 81 changed files with 1,554 additions and 747 deletions.
30 changes: 30 additions & 0 deletions .github/labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
XS:
name: size/XS
lines: 10
color: 3CBF00
S:
name: size/S
lines: 100
color: 5D9801
M:
name: size/M
lines: 300
color: 7F7203
L:
name: size/L
lines: 500
color: A14C05
XL:
name: size/XL
lines: 1000
color: C32607
comment: |
# Ups 🫰🟨
This PR is too big. Please try to break it up into smaller PRs.
XXL:
name: size/XXL
lines: 100000
color: E50009
comment: |
# Ups 🫰🟥
This PR is too big. Please break it up into smaller PRs.
63 changes: 0 additions & 63 deletions .github/workflows/create-playtest-branch.yml

This file was deleted.

7 changes: 4 additions & 3 deletions .github/workflows/gradle-run-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:

# Uploads test results as GitHub artifacts, so publish-test-results can find them later.
- name: Upload Test Results
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: always()
with:
# This name is referenced in the publish-test-results workflow.
Expand All @@ -61,16 +61,17 @@ jobs:
**/build/outputs/androidTest-results/**/*.xml
- name: Generate report
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: report
path: app/build/reports/jacoco

- name: Download Test Reports Folder
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: report
path: app/build/reports/jacoco
merge-multiple: true

- name: Upload Test Report
uses: codecov/codecov-action@v3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ import com.wire.kalium.logic.feature.conversation.ObserveConversationListDetails
import com.wire.kalium.logic.feature.conversation.ObserveConversationMembersUseCase
import com.wire.kalium.logic.feature.conversation.ObserveDegradedConversationNotifiedUseCase
import com.wire.kalium.logic.feature.conversation.ObserveIsSelfUserMemberUseCase
import com.wire.kalium.logic.feature.conversation.ObserveConversationUnderLegalHoldNotifiedUseCase
import com.wire.kalium.logic.feature.conversation.ObserveUserListByIdUseCase
import com.wire.kalium.logic.feature.conversation.ObserveUsersTypingUseCase
import com.wire.kalium.logic.feature.conversation.RefreshConversationsWithoutMetadataUseCase
import com.wire.kalium.logic.feature.conversation.RemoveMemberFromConversationUseCase
import com.wire.kalium.logic.feature.conversation.RenameConversationUseCase
import com.wire.kalium.logic.feature.conversation.SendTypingEventUseCase
import com.wire.kalium.logic.feature.conversation.SetNotifiedAboutConversationUnderLegalHoldUseCase
import com.wire.kalium.logic.feature.conversation.SetUserInformedAboutVerificationUseCase
import com.wire.kalium.logic.feature.conversation.UpdateConversationAccessRoleUseCase
import com.wire.kalium.logic.feature.conversation.UpdateConversationArchivedStatusUseCase
Expand Down Expand Up @@ -274,4 +276,16 @@ class ConversationModule {
conversationScope: ConversationScope
): ObserveDegradedConversationNotifiedUseCase =
conversationScope.observeInformAboutVerificationBeforeMessagingFlagUseCase

@ViewModelScoped
@Provides
fun provideSetUserNotifiedAboutConversationUnderLegalHoldUseCase(
conversationScope: ConversationScope,
): SetNotifiedAboutConversationUnderLegalHoldUseCase = conversationScope.setNotifiedAboutConversationUnderLegalHold

@ViewModelScoped
@Provides
fun provideObserveLegalHoldWithChangeNotifiedForConversationUseCase(
conversationScope: ConversationScope,
): ObserveConversationUnderLegalHoldNotifiedUseCase = conversationScope.observeConversationUnderLegalHoldNotified
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class GetE2EICertificateUseCase @Inject constructor(
}, {
if (it is E2EIEnrollmentResult.Initialized) {
initialEnrollmentResult = it
OAuthUseCase(context, it.target).launch(
OAuthUseCase(context, it.target, it.oAuthState).launch(
context.getActivity()!!.activityResultRegistry,
::oAuthResultHandler
)
Expand All @@ -61,10 +61,13 @@ class GetE2EICertificateUseCase @Inject constructor(
scope.launch {
when (oAuthResult) {
is OAuthUseCase.OAuthResult.Success -> {
enrollmentResultHandler(enrollE2EI.finalizeEnrollment(
oAuthResult.idToken,
initialEnrollmentResult
))
enrollmentResultHandler(
enrollE2EI.finalizeEnrollment(
oAuthResult.idToken,
oAuthResult.authState,
initialEnrollmentResult
)
)
}

is OAuthUseCase.OAuthResult.Failed -> {
Expand Down
39 changes: 30 additions & 9 deletions app/src/main/kotlin/com/wire/android/feature/e2ei/OAuthUseCase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import android.content.Context
import android.content.Intent
import android.net.Uri
import android.util.Base64
import android.util.Log
import androidx.activity.result.ActivityResult
import androidx.activity.result.ActivityResultRegistry
import androidx.activity.result.contract.ActivityResultContracts
Expand Down Expand Up @@ -51,8 +52,11 @@ import javax.net.ssl.SSLContext
import javax.net.ssl.TrustManager
import javax.net.ssl.X509TrustManager

class OAuthUseCase(context: Context, private val authUrl: String) {
private var authState: AuthState = AuthState()
class OAuthUseCase(context: Context, private val authUrl: String, oAuthState: String?) {
private var authState: AuthState = oAuthState?.let {
AuthState.jsonDeserialize(it)
} ?: AuthState()

private var authorizationService: AuthorizationService
private lateinit var authServiceConfig: AuthorizationServiceConfiguration

Expand Down Expand Up @@ -96,6 +100,17 @@ class OAuthUseCase(context: Context, private val authUrl: String) {
private fun getAuthorizationRequestIntent(): Intent = authorizationService.getAuthorizationRequestIntent(getAuthorizationRequest())

fun launch(activityResultRegistry: ActivityResultRegistry, resultHandler: (OAuthResult) -> Unit) {
authState.performActionWithFreshTokens(authorizationService) { _, idToken, exception ->
if (exception != null) {
Log.e("OAuthTokenRefreshManager", "Error refreshing tokens, continue with login!", exception)
launchLoginFlow(activityResultRegistry, resultHandler)
} else {
resultHandler(OAuthResult.Success(idToken.toString(), authState.jsonSerializeString()))
}
}
}

private fun launchLoginFlow(activityResultRegistry: ActivityResultRegistry, resultHandler: (OAuthResult) -> Unit) {
val resultLauncher = activityResultRegistry.register(
OAUTH_ACTIVITY_RESULT_KEY, ActivityResultContracts.StartActivityForResult()
) { result ->
Expand Down Expand Up @@ -141,7 +156,12 @@ class OAuthUseCase(context: Context, private val authUrl: String) {
if (response != null) {
authState.update(response, exception)
appLogger.i("OAuth idToken: ${response.idToken}")
resultHandler(OAuthResult.Success(response.idToken.toString()))
resultHandler(
OAuthResult.Success(
response.idToken.toString(),
authState.jsonSerializeString()
)
)
} else {
resultHandler(OAuthResult.Failed.EmptyResponse)
}
Expand All @@ -152,7 +172,12 @@ class OAuthUseCase(context: Context, private val authUrl: String) {

private fun getAuthorizationRequest() = AuthorizationRequest.Builder(
authServiceConfig, CLIENT_ID, ResponseTypeValues.CODE, URL_AUTH_REDIRECT
).setCodeVerifier().setScopes(SCOPE_OPENID, SCOPE_EMAIL, SCOPE_PROFILE).build()
).setCodeVerifier().setScopes(
AuthorizationRequest.Scope.OPENID,
AuthorizationRequest.Scope.EMAIL,
AuthorizationRequest.Scope.PROFILE,
AuthorizationRequest.Scope.OFFLINE_ACCESS
).build()

private fun AuthorizationRequest.Builder.setCodeVerifier(): AuthorizationRequest.Builder {
val codeVerifier = getCodeVerifier()
Expand All @@ -176,7 +201,7 @@ class OAuthUseCase(context: Context, private val authUrl: String) {
}

sealed class OAuthResult {
data class Success(val idToken: String) : OAuthResult()
data class Success(val idToken: String, val authState: String) : OAuthResult()
open class Failed(val reason: String) : OAuthResult() {
object Unknown : Failed("Unknown")
class InvalidActivityResult(reason: String) : Failed(reason)
Expand All @@ -187,10 +212,6 @@ class OAuthUseCase(context: Context, private val authUrl: String) {
companion object {
const val OAUTH_ACTIVITY_RESULT_KEY = "OAuthActivityResult"

const val SCOPE_PROFILE = "profile"
const val SCOPE_EMAIL = "email"
const val SCOPE_OPENID = "openid"

// todo: clientId and the clientSecret will be replaced with the values from the BE once the BE provides them
const val CLIENT_ID = "wireapp"
const val CLIENT_SECRET = "dUpVSGx2dVdFdGQ0dmsxWGhDalQ0SldU"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ fun MessagePreview.uiLastMessageContent(): UILastMessageContent {
UILastMessageContent.TextMessage(MessageBody(previewMessageContent))
}

is WithUser.MembersRemoved -> {
val membersRemovedContent = (content as WithUser.MembersRemoved)
val isSelfRemoved = membersRemovedContent.isSelfUserRemoved
val otherUsersSize = membersRemovedContent.otherUserIdList.size
is WithUser.ConversationMembersRemoved -> {
val conversationMembersRemovedContent = (content as WithUser.ConversationMembersRemoved)
val isSelfRemoved = conversationMembersRemovedContent.isSelfUserRemoved
val otherUsersSize = conversationMembersRemovedContent.otherUserIdList.size

val previewMessageContent = when {
isSelfMessage && otherUsersSize > 0 -> {
Expand All @@ -234,6 +234,14 @@ fun MessagePreview.uiLastMessageContent(): UILastMessageContent {
UILastMessageContent.TextMessage(MessageBody(previewMessageContent))
}

is WithUser.TeamMembersRemoved -> {
val teamMembersRemovedContent = (content as WithUser.TeamMembersRemoved)
val previewMessageContent =
UIText.PluralResource(R.plurals.last_message_team_member_removed, teamMembersRemovedContent.otherUserIdList.size)

UILastMessageContent.TextMessage(MessageBody(previewMessageContent))
}

is WithUser.MentionedSelf -> UILastMessageContent.SenderWithMessage(
userUIText,
UIText.StringResource(R.string.last_message_mentioned)
Expand All @@ -244,7 +252,7 @@ fun MessagePreview.uiLastMessageContent(): UILastMessageContent {
UIText.StringResource(R.string.last_message_replied)
)

is WithUser.TeamMemberRemoved -> UILastMessageContent.None // TODO
is WithUser.TeamMemberRemoved -> UILastMessageContent.None
is WithUser.Text -> UILastMessageContent.SenderWithMessage(
sender = userUIText,
message = (content as WithUser.Text).messageBody.let { UIText.DynamicString(it) },
Expand Down Expand Up @@ -319,12 +327,16 @@ fun MessagePreview.uiLastMessageContent(): UILastMessageContent {
MessagePreviewContent.CryptoSessionReset -> UILastMessageContent.None
MessagePreviewContent.VerificationChanged.VerifiedMls ->
UILastMessageContent.VerificationChanged(R.string.last_message_verified_conversation_mls)

MessagePreviewContent.VerificationChanged.VerifiedProteus ->
UILastMessageContent.VerificationChanged(R.string.last_message_verified_conversation_proteus)

MessagePreviewContent.VerificationChanged.DegradedMls ->
UILastMessageContent.VerificationChanged(R.string.last_message_conversations_verification_degraded_mls)

MessagePreviewContent.VerificationChanged.DegradedProteus ->
UILastMessageContent.VerificationChanged(R.string.last_message_conversations_verification_degraded_proteus)

Unknown -> UILastMessageContent.None
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ class RegularMessageMapper @Inject constructor(
}

is MessageContent.QuotedMessageDetails.Text -> UIQuotedMessage.UIQuotedData.Text(quotedContent.value)
is MessageContent.QuotedMessageDetails.Location -> UIQuotedMessage.UIQuotedData.Location(quotedContent.locationName.orEmpty())
MessageContent.QuotedMessageDetails.Deleted -> UIQuotedMessage.UIQuotedData.Deleted
MessageContent.QuotedMessageDetails.Invalid -> UIQuotedMessage.UIQuotedData.Invalid
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class SystemMessageContentMapper @Inject constructor(
is MessageContent.ConversationVerifiedProteus -> mapConversationVerified(Conversation.Protocol.PROTEUS)
is MessageContent.FederationStopped -> mapFederationMessage(content)
is MessageContent.ConversationProtocolChanged -> mapConversationProtocolChanged(content)
is MessageContent.ConversationProtocolChangedDuringACall -> mapConversationProtocolChangedDuringACall()
is MessageContent.ConversationStartedUnverifiedWarning -> mapConversationCreatedUnverifiedWarning()
is MessageContent.LegalHold -> mapLegalHoldMessage(content, message.senderUserId, members)
}
Expand Down Expand Up @@ -118,9 +119,11 @@ class SystemMessageContentMapper @Inject constructor(

private fun mapConversationProtocolChanged(
content: MessageContent.ConversationProtocolChanged
): UIMessageContent.SystemMessage {
return UIMessageContent.SystemMessage.ConversationProtocolChanged(content.protocol)
}
): UIMessageContent.SystemMessage =
UIMessageContent.SystemMessage.ConversationProtocolChanged(content.protocol)

private fun mapConversationProtocolChangedDuringACall(): UIMessageContent.SystemMessage =
UIMessageContent.SystemMessage.ConversationProtocolChangedWithCallOngoing

private fun mapResetSession(
senderUserId: UserId,
Expand Down Expand Up @@ -180,7 +183,7 @@ class SystemMessageContentMapper @Inject constructor(

private fun mapTeamMemberRemovedMessage(
content: MessageContent.TeamMemberRemoved
): UIMessageContent.SystemMessage = UIMessageContent.SystemMessage.TeamMemberRemoved(content)
): UIMessageContent.SystemMessage = UIMessageContent.SystemMessage.TeamMemberRemoved_Legacy(content)

private fun mapConversationRenamedMessage(
senderUserId: UserId,
Expand Down Expand Up @@ -242,6 +245,11 @@ class SystemMessageContentMapper @Inject constructor(
is MemberChange.FederationRemoved -> UIMessageContent.SystemMessage.FederationMemberRemoved(
memberNames = memberNameList
)

is MemberChange.RemovedFromTeam -> UIMessageContent.SystemMessage.TeamMemberRemoved(
author = authorName,
memberNames = memberNameList
)
}
}

Expand Down

0 comments on commit c4fefad

Please sign in to comment.