mirror of
https://github.com/oxen-io/session-android.git
synced 2025-04-29 03:20:46 +00:00
fix: Disable typing and message requests in read-only open groups
This commit is contained in:
parent
fbd1721eaf
commit
ffa280bc1b
@ -466,6 +466,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
|
|
||||||
// called from onCreate
|
// called from onCreate
|
||||||
private fun setUpInputBar() {
|
private fun setUpInputBar() {
|
||||||
|
binding!!.inputBar.isVisible = viewModel.openGroup == null || viewModel.openGroup?.canWrite == true
|
||||||
binding!!.inputBar.delegate = this
|
binding!!.inputBar.delegate = this
|
||||||
binding!!.inputBarRecordingView.delegate = this
|
binding!!.inputBarRecordingView.delegate = this
|
||||||
// GIF button
|
// GIF button
|
||||||
|
@ -153,12 +153,13 @@ class VisibleMessageView : LinearLayout {
|
|||||||
|
|
||||||
if (isGroupThread && !message.isOutgoing) {
|
if (isGroupThread && !message.isOutgoing) {
|
||||||
if (isEndOfMessageCluster) {
|
if (isEndOfMessageCluster) {
|
||||||
|
val openGroup = lokiThreadDb.getOpenGroupChat(threadID)
|
||||||
binding.profilePictureView.root.publicKey = senderSessionID
|
binding.profilePictureView.root.publicKey = senderSessionID
|
||||||
binding.profilePictureView.root.glide = glide
|
binding.profilePictureView.root.glide = glide
|
||||||
binding.profilePictureView.root.update(message.individualRecipient)
|
binding.profilePictureView.root.update(message.individualRecipient)
|
||||||
binding.profilePictureView.root.setOnClickListener {
|
binding.profilePictureView.root.setOnClickListener {
|
||||||
if (thread.isOpenGroupRecipient) {
|
if (thread.isOpenGroupRecipient) {
|
||||||
if (IdPrefix.fromValue(senderSessionID) == IdPrefix.BLINDED) {
|
if (IdPrefix.fromValue(senderSessionID) == IdPrefix.BLINDED && openGroup?.canWrite == true) {
|
||||||
val intent = Intent(context, ConversationActivityV2::class.java)
|
val intent = Intent(context, ConversationActivityV2::class.java)
|
||||||
intent.putExtra(ConversationActivityV2.FROM_GROUP_THREAD_ID, threadID)
|
intent.putExtra(ConversationActivityV2.FROM_GROUP_THREAD_ID, threadID)
|
||||||
intent.putExtra(ConversationActivityV2.ADDRESS, Address.fromSerialized(senderSessionID))
|
intent.putExtra(ConversationActivityV2.ADDRESS, Address.fromSerialized(senderSessionID))
|
||||||
@ -169,7 +170,7 @@ class VisibleMessageView : LinearLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (thread.isOpenGroupRecipient) {
|
if (thread.isOpenGroupRecipient) {
|
||||||
val openGroup = lokiThreadDb.getOpenGroupChat(threadID) ?: return
|
openGroup ?: return
|
||||||
var standardPublicKey = ""
|
var standardPublicKey = ""
|
||||||
var blindedPublicKey: String? = null
|
var blindedPublicKey: String? = null
|
||||||
if (IdPrefix.fromValue(senderSessionID) == IdPrefix.BLINDED) {
|
if (IdPrefix.fromValue(senderSessionID) == IdPrefix.BLINDED) {
|
||||||
|
@ -83,7 +83,7 @@ object OpenGroupManager {
|
|||||||
if (threadID < 0) {
|
if (threadID < 0) {
|
||||||
threadID = GroupManager.createOpenGroup(openGroupID, context, null, info.name).threadId
|
threadID = GroupManager.createOpenGroup(openGroupID, context, null, info.name).threadId
|
||||||
}
|
}
|
||||||
val openGroup = OpenGroup(server, room, info.name, info.infoUpdates, publicKey)
|
val openGroup = OpenGroup(server, room, info.name, info.infoUpdates, publicKey, info.write)
|
||||||
threadDB.setOpenGroupChat(openGroup, threadID)
|
threadDB.setOpenGroupChat(openGroup, threadID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,15 +12,17 @@ data class OpenGroup(
|
|||||||
val name: String,
|
val name: String,
|
||||||
val publicKey: String,
|
val publicKey: String,
|
||||||
val infoUpdates: Int,
|
val infoUpdates: Int,
|
||||||
|
val canWrite: Boolean,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
constructor(server: String, room: String, name: String, infoUpdates: Int, publicKey: String) : this(
|
constructor(server: String, room: String, name: String, infoUpdates: Int, publicKey: String, canWrite: Boolean) : this(
|
||||||
server = server,
|
server = server,
|
||||||
room = room,
|
room = room,
|
||||||
id = "$server.$room",
|
id = "$server.$room",
|
||||||
name = name,
|
name = name,
|
||||||
publicKey = publicKey,
|
publicKey = publicKey,
|
||||||
infoUpdates = infoUpdates,
|
infoUpdates = infoUpdates,
|
||||||
|
canWrite = canWrite
|
||||||
)
|
)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@ -29,13 +31,13 @@ data class OpenGroup(
|
|||||||
return try {
|
return try {
|
||||||
val json = JsonUtil.fromJson(jsonAsString)
|
val json = JsonUtil.fromJson(jsonAsString)
|
||||||
if (!json.has("room")) return null
|
if (!json.has("room")) return null
|
||||||
val room = json.get("room").asText().toLowerCase(Locale.US)
|
val room = json.get("room").asText().lowercase(Locale.US)
|
||||||
val server = json.get("server").asText().toLowerCase(Locale.US)
|
val server = json.get("server").asText().lowercase(Locale.US)
|
||||||
val displayName = json.get("displayName").asText()
|
val displayName = json.get("displayName").asText()
|
||||||
val publicKey = json.get("publicKey").asText()
|
val publicKey = json.get("publicKey").asText()
|
||||||
val infoUpdates = json.get("infoUpdates")?.asText()?.toIntOrNull() ?: 0
|
val infoUpdates = json.get("infoUpdates")?.asText()?.toIntOrNull() ?: 0
|
||||||
val capabilities = json.get("capabilities")?.asText()?.split(",") ?: emptyList()
|
val canWrite = json.get("canWrite")?.asText()?.toBoolean() ?: true
|
||||||
OpenGroup(server, room, displayName, infoUpdates, publicKey)
|
OpenGroup(server, room, displayName, infoUpdates, publicKey, canWrite)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.w("Loki", "Couldn't parse open group from JSON: $jsonAsString.", e);
|
Log.w("Loki", "Couldn't parse open group from JSON: $jsonAsString.", e);
|
||||||
null
|
null
|
||||||
@ -59,6 +61,7 @@ data class OpenGroup(
|
|||||||
"displayName" to name,
|
"displayName" to name,
|
||||||
"publicKey" to publicKey,
|
"publicKey" to publicKey,
|
||||||
"infoUpdates" to infoUpdates.toString(),
|
"infoUpdates" to infoUpdates.toString(),
|
||||||
|
"canWrite" to canWrite.toString()
|
||||||
)
|
)
|
||||||
|
|
||||||
val joinURL: String get() = "$server/$room?public_key=$publicKey"
|
val joinURL: String get() = "$server/$room?public_key=$publicKey"
|
||||||
|
@ -126,6 +126,7 @@ class OpenGroupPoller(private val server: String, private val executorService: S
|
|||||||
name = pollInfo.details?.name ?: "",
|
name = pollInfo.details?.name ?: "",
|
||||||
infoUpdates = pollInfo.details?.infoUpdates ?: 0,
|
infoUpdates = pollInfo.details?.infoUpdates ?: 0,
|
||||||
publicKey = publicKey,
|
publicKey = publicKey,
|
||||||
|
canWrite = pollInfo.write
|
||||||
)
|
)
|
||||||
// - Open Group changes
|
// - Open Group changes
|
||||||
storage.updateOpenGroup(openGroup)
|
storage.updateOpenGroup(openGroup)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user