Skip to content

Commit 9aaf29d

Browse files
authored
Merge pull request #8797 from element-hq/feature/bma/reportUser
Report user
2 parents 0f3ff2e + 5ce0801 commit 9aaf29d

File tree

11 files changed

+80
-5
lines changed

11 files changed

+80
-5
lines changed

changelog.d/8796.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add a report user action in the message bottom sheet and on the user profile page.

library/ui-strings/src/main/res/values/strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,8 +1953,11 @@
19531953
<string name="content_reported_as_spam_content">"This content was reported as spam.\n\nIf you don't want to see any more content from this user, you can ignore them to hide their messages."</string>
19541954
<string name="content_reported_as_inappropriate_title">"Reported as inappropriate"</string>
19551955
<string name="content_reported_as_inappropriate_content">"This content was reported as inappropriate.\n\nIf you don't want to see any more content from this user, you can ignore them to hide their messages."</string>
1956+
<string name="user_reported_as_inappropriate_title">"Reported user"</string>
1957+
<string name="user_reported_as_inappropriate_content">"The user has been reported.\n\nIf you don't want to see any more content from this user, you can ignore them to hide their messages."</string>
19561958

19571959
<string name="message_ignore_user">Ignore user</string>
1960+
<string name="message_report_user">Report user</string>
19581961

19591962
<string name="room_list_quick_actions_notifications_all_noisy">"All messages (noisy)"</string>
19601963
<string name="room_list_quick_actions_notifications_all">"All messages"</string>

vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailAction.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ sealed class RoomDetailAction : VectorViewModelAction {
6161
val senderId: String?,
6262
val reason: String,
6363
val spam: Boolean = false,
64-
val inappropriate: Boolean = false
64+
val inappropriate: Boolean = false,
65+
val user: Boolean = false,
6566
) : RoomDetailAction()
6667

6768
data class IgnoreUser(val userId: String?) : RoomDetailAction()

vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,16 @@ class TimelineFragment :
13451345
}
13461346
.show()
13471347
}
1348+
data.user -> {
1349+
MaterialAlertDialogBuilder(requireActivity(), R.style.ThemeOverlay_Vector_MaterialAlertDialog_NegativeDestructive)
1350+
.setTitle(R.string.user_reported_as_inappropriate_title)
1351+
.setMessage(R.string.user_reported_as_inappropriate_content)
1352+
.setPositiveButton(R.string.ok, null)
1353+
.setNegativeButton(R.string.block_user) { _, _ ->
1354+
timelineViewModel.handle(RoomDetailAction.IgnoreUser(data.senderId))
1355+
}
1356+
.show()
1357+
}
13481358
else -> {
13491359
MaterialAlertDialogBuilder(requireActivity(), R.style.ThemeOverlay_Vector_MaterialAlertDialog_NegativeDestructive)
13501360
.setTitle(R.string.content_reported_title)
@@ -1857,6 +1867,13 @@ class TimelineFragment :
18571867
is EventSharedAction.IgnoreUser -> {
18581868
action.senderId?.let { askConfirmationToIgnoreUser(it) }
18591869
}
1870+
is EventSharedAction.ReportUser -> {
1871+
timelineViewModel.handle(
1872+
RoomDetailAction.ReportContent(
1873+
action.eventId, action.senderId, "Reporting user ${action.senderId}", user = true
1874+
)
1875+
)
1876+
}
18601877
is EventSharedAction.OnUrlClicked -> {
18611878
onUrlClicked(action.url, action.title)
18621879
}

vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/EventSharedAction.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ sealed class EventSharedAction(
9898
data class IgnoreUser(val senderId: String?) :
9999
EventSharedAction(R.string.message_ignore_user, R.drawable.ic_alert_triangle, true)
100100

101+
data class ReportUser(val eventId: String, val senderId: String?) :
102+
EventSharedAction(R.string.message_report_user, R.drawable.ic_flag, true)
103+
101104
data class QuickReact(val eventId: String, val clickedOn: String, val add: Boolean) :
102105
EventSharedAction(0, 0)
103106

vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,12 @@ class MessageActionsViewModel @AssistedInject constructor(
430430

431431
add(EventSharedAction.Separator)
432432
add(EventSharedAction.IgnoreUser(timelineEvent.root.senderId))
433+
add(
434+
EventSharedAction.ReportUser(
435+
eventId = eventId,
436+
senderId = timelineEvent.root.senderId,
437+
)
438+
)
433439
}
434440
}
435441

vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileAction.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import im.vector.app.core.platform.VectorViewModelAction
2222
sealed class RoomMemberProfileAction : VectorViewModelAction {
2323
object RetryFetchingInfo : RoomMemberProfileAction()
2424
object IgnoreUser : RoomMemberProfileAction()
25+
object ReportUser : RoomMemberProfileAction()
2526
data class BanOrUnbanUser(val reason: String?) : RoomMemberProfileAction()
2627
data class KickUser(val reason: String?) : RoomMemberProfileAction()
2728
object InviteUser : RoomMemberProfileAction()

vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileController.kt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class RoomMemberProfileController @Inject constructor(
3939

4040
interface Callback {
4141
fun onIgnoreClicked()
42+
fun onReportClicked()
4243
fun onTapVerify()
4344
fun onShowDeviceList()
4445
fun onShowDeviceListNoCrossSigning()
@@ -225,7 +226,7 @@ class RoomMemberProfileController @Inject constructor(
225226
title = stringProvider.getString(R.string.room_participants_action_invite),
226227
destructive = false,
227228
editable = false,
228-
divider = ignoreActionTitle != null,
229+
divider = true,
229230
action = { callback?.onInviteClicked() }
230231
)
231232
}
@@ -235,10 +236,18 @@ class RoomMemberProfileController @Inject constructor(
235236
title = ignoreActionTitle,
236237
destructive = true,
237238
editable = false,
238-
divider = false,
239+
divider = true,
239240
action = { callback?.onIgnoreClicked() }
240241
)
241242
}
243+
buildProfileAction(
244+
id = "report",
245+
title = stringProvider.getString(R.string.message_report_user),
246+
destructive = true,
247+
editable = false,
248+
divider = false,
249+
action = { callback?.onReportClicked() }
250+
)
242251
}
243252
}
244253

@@ -314,9 +323,9 @@ class RoomMemberProfileController @Inject constructor(
314323
private fun RoomMemberProfileViewState.buildIgnoreActionTitle(): String? {
315324
val isIgnored = isIgnored() ?: return null
316325
return if (isIgnored) {
317-
stringProvider.getString(R.string.unignore)
326+
stringProvider.getString(R.string.room_participants_action_unignore_title)
318327
} else {
319-
stringProvider.getString(R.string.action_ignore)
328+
stringProvider.getString(R.string.room_participants_action_ignore_title)
320329
}
321330
}
322331
}

vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileFragment.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,20 @@ class RoomMemberProfileFragment :
140140
is RoomMemberProfileViewEvents.OnIgnoreActionSuccess -> Unit
141141
is RoomMemberProfileViewEvents.OnInviteActionSuccess -> Unit
142142
RoomMemberProfileViewEvents.GoBack -> handleGoBack()
143+
RoomMemberProfileViewEvents.OnReportActionSuccess -> handleReportSuccess()
143144
}
144145
}
145146
setupLongClicks()
146147
}
147148

149+
private fun handleReportSuccess() {
150+
MaterialAlertDialogBuilder(requireContext())
151+
.setTitle(R.string.user_reported_as_inappropriate_title)
152+
.setMessage(R.string.user_reported_as_inappropriate_content)
153+
.setPositiveButton(R.string.ok, null)
154+
.show()
155+
}
156+
148157
private fun setupLongClicks() {
149158
headerViews.memberProfileNameView.copyOnLongClick()
150159
headerViews.memberProfileIdView.copyOnLongClick()
@@ -301,6 +310,10 @@ class RoomMemberProfileFragment :
301310
}
302311
}
303312

313+
override fun onReportClicked() {
314+
viewModel.handle(RoomMemberProfileAction.ReportUser)
315+
}
316+
304317
override fun onTapVerify() {
305318
viewModel.handle(RoomMemberProfileAction.VerifyUser)
306319
}

vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileViewEvents.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ sealed class RoomMemberProfileViewEvents : VectorViewEvents {
2626
data class Failure(val throwable: Throwable) : RoomMemberProfileViewEvents()
2727

2828
object OnIgnoreActionSuccess : RoomMemberProfileViewEvents()
29+
object OnReportActionSuccess : RoomMemberProfileViewEvents()
2930
object OnSetPowerLevelSuccess : RoomMemberProfileViewEvents()
3031
object OnInviteActionSuccess : RoomMemberProfileViewEvents()
3132
object OnKickActionSuccess : RoomMemberProfileViewEvents()

0 commit comments

Comments
 (0)