Handle events of type "m.room.server_acl" - details only in developer mode (#890)
This commit is contained in:
parent
413a55623e
commit
b99cdf7367
@ -72,15 +72,15 @@
|
||||
<string name="notice_room_update_by_you">You upgraded this room.</string>
|
||||
<string name="notice_direct_room_update">%s upgraded here.</string>
|
||||
<string name="notice_direct_room_update_by_you">You upgraded here.</string>
|
||||
<string name="notice_room_server_acl_set_title">%s set the server ACLs for this room:</string>
|
||||
<string name="notice_room_server_acl_set_title_by_you">You set the server ACLs for this room:</string>
|
||||
<string name="notice_room_server_acl_set_title">%s set the server ACLs for this room.</string>
|
||||
<string name="notice_room_server_acl_set_title_by_you">You set the server ACLs for this room.</string>
|
||||
<string name="notice_room_server_acl_set_banned">• Server matching %s are banned.</string>
|
||||
<string name="notice_room_server_acl_set_allowed">• Server matching %s are allowed.</string>
|
||||
<string name="notice_room_server_acl_set_ip_literals_allowed">• Server matching IP literals are allowed.</string>
|
||||
<string name="notice_room_server_acl_set_ip_literals_not_allowed">• Server matching IP literals are banned.</string>
|
||||
|
||||
<string name="notice_room_server_acl_updated_title">%s changed the server ACLs for this room:</string>
|
||||
<string name="notice_room_server_acl_updated_title_by_you">You changed the server ACLs for this room:</string>
|
||||
<string name="notice_room_server_acl_updated_title">%s changed the server ACLs for this room.</string>
|
||||
<string name="notice_room_server_acl_updated_title_by_you">You changed the server ACLs for this room.</string>
|
||||
<string name="notice_room_server_acl_updated_banned">• Server matching %s are now banned.</string>
|
||||
<string name="notice_room_server_acl_updated_was_banned">• Server matching %s were removed from the ban list.</string>
|
||||
<string name="notice_room_server_acl_updated_allowed">• Server matching %s are now allowed.</string>
|
||||
|
@ -19,6 +19,7 @@ package im.vector.app.features.home.room.detail.timeline.format
|
||||
import im.vector.app.ActiveSessionDataSource
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import im.vector.app.features.settings.VectorPreferences
|
||||
import org.matrix.android.sdk.api.extensions.appendNl
|
||||
import org.matrix.android.sdk.api.extensions.orFalse
|
||||
import org.matrix.android.sdk.api.session.events.model.Event
|
||||
@ -50,9 +51,12 @@ import org.matrix.android.sdk.internal.crypto.model.event.EncryptionEventContent
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
class NoticeEventFormatter @Inject constructor(private val activeSessionDataSource: ActiveSessionDataSource,
|
||||
class NoticeEventFormatter @Inject constructor(
|
||||
private val activeSessionDataSource: ActiveSessionDataSource,
|
||||
private val roomHistoryVisibilityFormatter: RoomHistoryVisibilityFormatter,
|
||||
private val sp: StringProvider) {
|
||||
private val vectorPreferences: VectorPreferences,
|
||||
private val sp: StringProvider
|
||||
) {
|
||||
|
||||
private val currentUserId: String?
|
||||
get() = activeSessionDataSource.currentValue?.orNull()?.myUserId
|
||||
@ -405,12 +409,17 @@ class NoticeEventFormatter @Inject constructor(private val activeSessionDataSour
|
||||
sp.getString(R.string.notice_room_server_acl_updated_title, senderName)
|
||||
}
|
||||
})
|
||||
// Details
|
||||
if (eventContent.allowList.isEmpty()) {
|
||||
// Special case for stuck room
|
||||
append("\n")
|
||||
append(sp.getString(R.string.notice_room_server_acl_allow_is_empty))
|
||||
} else {
|
||||
appendNl(sp.getString(R.string.notice_room_server_acl_allow_is_empty))
|
||||
} else if (vectorPreferences.developerMode()) {
|
||||
// Details, only in developer mode
|
||||
appendAclDetails(eventContent, prevEventContent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun StringBuilder.appendAclDetails(eventContent: RoomServerAclContent, prevEventContent: RoomServerAclContent?) {
|
||||
if (prevEventContent == null) {
|
||||
eventContent.allowList.forEach { appendNl(sp.getString(R.string.notice_room_server_acl_set_allowed, it)) }
|
||||
eventContent.denyList.forEach { appendNl(sp.getString(R.string.notice_room_server_acl_set_banned, it)) }
|
||||
@ -454,8 +463,6 @@ class NoticeEventFormatter @Inject constructor(private val activeSessionDataSour
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun formatRoomCanonicalAliasEvent(event: Event, senderName: String?): String? {
|
||||
val eventContent: RoomCanonicalAliasContent? = event.getClearContent().toModel()
|
||||
|
Loading…
Reference in New Issue
Block a user