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)) {
binding.shareConversationButton.visibility = GONE
}
val canGeneratePrettyURL = CapabilitiesUtil.canGeneratePrettyURL(conversationUser)
binding.shareConversationButton.setOnClickListener {
ShareUtils.shareConversationLink(
this,
conversationUser.baseUrl,
conversation?.token,
conversation?.name
conversation?.name,
canGeneratePrettyURL
)
}
}

View file

@ -23,8 +23,10 @@ data class CoreCapability(
@JsonField(name = ["reference-api"])
var referenceApi: String?,
@JsonField(name = ["reference-regex"])
var referenceRegex: String?
var referenceRegex: String?,
@JsonField(name = ["mod-rewrite-working"])
var modRewriteWorking: Boolean?
) : Parcelable {
// 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 {
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()
}

View file

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

View file

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