Pretty URL for conversation link

Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
sowjanyakch 2024-05-06 16:17:09 +02:00 committed by Marcel Hibbe
parent 9f356a67aa
commit acd0b92b6c
No known key found for this signature in database
GPG key ID: C793F8B59F43CE7B
5 changed files with 38 additions and 10 deletions

View file

@ -206,12 +206,14 @@ class ConversationInfoActivity :
if (ConversationUtils.isNoteToSelfConversation(conversation)) { if (ConversationUtils.isNoteToSelfConversation(conversation)) {
binding.shareConversationButton.visibility = GONE binding.shareConversationButton.visibility = GONE
} }
val canGeneratePrettyURL = CapabilitiesUtil.canGeneratePrettyURL(conversationUser)
binding.shareConversationButton.setOnClickListener { binding.shareConversationButton.setOnClickListener {
ShareUtils.shareConversationLink( ShareUtils.shareConversationLink(
this, this,
conversationUser.baseUrl, conversationUser.baseUrl,
conversation?.token, conversation?.token,
conversation?.name conversation?.name,
canGeneratePrettyURL
) )
} }
} }

View file

@ -23,8 +23,10 @@ data class CoreCapability(
@JsonField(name = ["reference-api"]) @JsonField(name = ["reference-api"])
var referenceApi: String?, var referenceApi: String?,
@JsonField(name = ["reference-regex"]) @JsonField(name = ["reference-regex"])
var referenceRegex: String? var referenceRegex: String?,
@JsonField(name = ["mod-rewrite-working"])
var modRewriteWorking: Boolean?
) : Parcelable { ) : Parcelable {
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject' // This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
constructor() : this(null, null, null, null) constructor() : this(null, null, null, null, null)
} }

View file

@ -166,7 +166,14 @@ class ConversationsListBottomDialog(
} }
binding.conversationLinkShare.setOnClickListener { binding.conversationLinkShare.setOnClickListener {
ShareUtils.shareConversationLink(activity, currentUser.baseUrl, conversation.token, conversation.name) val canGeneratePrettyURL = CapabilitiesUtil.canGeneratePrettyURL(currentUser)
ShareUtils.shareConversationLink(
activity,
currentUser.baseUrl,
conversation.token,
conversation.name,
canGeneratePrettyURL
)
dismiss() dismiss()
} }

View file

@ -86,6 +86,10 @@ object CapabilitiesUtil {
user.capabilities?.coreCapability?.referenceApi == "true" user.capabilities?.coreCapability?.referenceApi == "true"
} }
fun canGeneratePrettyURL(user: User): Boolean {
return user.capabilities?.coreCapability?.modRewriteWorking == true
}
// endregion // endregion
//region SpreedCapabilities //region SpreedCapabilities

View file

@ -6,6 +6,7 @@
*/ */
package com.nextcloud.talk.utils package com.nextcloud.talk.utils
import android.annotation.SuppressLint
import android.app.Activity import android.app.Activity
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
@ -13,17 +14,29 @@ import com.nextcloud.talk.R
object ShareUtils { object ShareUtils {
fun shareConversationLink(context: Activity, baseUrl: String?, roomToken: String?, conversationName: String?) { @SuppressLint("StringFormatMatches")
fun shareConversationLink(
context: Activity,
baseUrl: String?,
roomToken: String?,
conversationName: String?,
canGeneratePrettyURL: Boolean
) {
if (baseUrl.isNullOrBlank() || roomToken.isNullOrBlank() || conversationName.isNullOrBlank()) { if (baseUrl.isNullOrBlank() || roomToken.isNullOrBlank() || conversationName.isNullOrBlank()) {
return return
} }
val uriToShareConversation = Uri.parse(baseUrl) val uriBuilder = Uri.parse(baseUrl)
.buildUpon() .buildUpon()
.appendPath("index.php")
.appendPath("call") if (!canGeneratePrettyURL) {
.appendPath(roomToken) uriBuilder.appendPath("index.php")
.build() }
uriBuilder.appendPath("call")
uriBuilder.appendPath(roomToken)
val uriToShareConversation = uriBuilder.build()
val shareConversationLink = String.format( val shareConversationLink = String.format(
context.getString( context.getString(