File tree Expand file tree Collapse file tree 5 files changed +48
-4
lines changed
vector/src/main/java/im/vector/app/features/roommemberprofile Expand file tree Collapse file tree 5 files changed +48
-4
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import im.vector.app.core.platform.VectorViewModelAction
22
22
sealed class RoomMemberProfileAction : VectorViewModelAction {
23
23
object RetryFetchingInfo : RoomMemberProfileAction()
24
24
object IgnoreUser : RoomMemberProfileAction()
25
+ object ReportUser : RoomMemberProfileAction()
25
26
data class BanOrUnbanUser (val reason : String? ) : RoomMemberProfileAction()
26
27
data class KickUser (val reason : String? ) : RoomMemberProfileAction()
27
28
object InviteUser : RoomMemberProfileAction()
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ class RoomMemberProfileController @Inject constructor(
39
39
40
40
interface Callback {
41
41
fun onIgnoreClicked ()
42
+ fun onReportClicked ()
42
43
fun onTapVerify ()
43
44
fun onShowDeviceList ()
44
45
fun onShowDeviceListNoCrossSigning ()
@@ -225,7 +226,7 @@ class RoomMemberProfileController @Inject constructor(
225
226
title = stringProvider.getString(R .string.room_participants_action_invite),
226
227
destructive = false ,
227
228
editable = false ,
228
- divider = ignoreActionTitle != null ,
229
+ divider = true ,
229
230
action = { callback?.onInviteClicked() }
230
231
)
231
232
}
@@ -235,10 +236,18 @@ class RoomMemberProfileController @Inject constructor(
235
236
title = ignoreActionTitle,
236
237
destructive = true ,
237
238
editable = false ,
238
- divider = false ,
239
+ divider = true ,
239
240
action = { callback?.onIgnoreClicked() }
240
241
)
241
242
}
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
+ )
242
251
}
243
252
}
244
253
@@ -314,9 +323,9 @@ class RoomMemberProfileController @Inject constructor(
314
323
private fun RoomMemberProfileViewState.buildIgnoreActionTitle (): String? {
315
324
val isIgnored = isIgnored() ? : return null
316
325
return if (isIgnored) {
317
- stringProvider.getString(R .string.unignore )
326
+ stringProvider.getString(R .string.room_participants_action_unignore_title )
318
327
} else {
319
- stringProvider.getString(R .string.action_ignore )
328
+ stringProvider.getString(R .string.room_participants_action_ignore_title )
320
329
}
321
330
}
322
331
}
Original file line number Diff line number Diff line change @@ -140,11 +140,20 @@ class RoomMemberProfileFragment :
140
140
is RoomMemberProfileViewEvents .OnIgnoreActionSuccess -> Unit
141
141
is RoomMemberProfileViewEvents .OnInviteActionSuccess -> Unit
142
142
RoomMemberProfileViewEvents .GoBack -> handleGoBack()
143
+ RoomMemberProfileViewEvents .OnReportActionSuccess -> handleReportSuccess()
143
144
}
144
145
}
145
146
setupLongClicks()
146
147
}
147
148
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
+
148
157
private fun setupLongClicks () {
149
158
headerViews.memberProfileNameView.copyOnLongClick()
150
159
headerViews.memberProfileIdView.copyOnLongClick()
@@ -301,6 +310,10 @@ class RoomMemberProfileFragment :
301
310
}
302
311
}
303
312
313
+ override fun onReportClicked () {
314
+ viewModel.handle(RoomMemberProfileAction .ReportUser )
315
+ }
316
+
304
317
override fun onTapVerify () {
305
318
viewModel.handle(RoomMemberProfileAction .VerifyUser )
306
319
}
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ sealed class RoomMemberProfileViewEvents : VectorViewEvents {
26
26
data class Failure (val throwable : Throwable ) : RoomMemberProfileViewEvents()
27
27
28
28
object OnIgnoreActionSuccess : RoomMemberProfileViewEvents()
29
+ object OnReportActionSuccess : RoomMemberProfileViewEvents()
29
30
object OnSetPowerLevelSuccess : RoomMemberProfileViewEvents()
30
31
object OnInviteActionSuccess : RoomMemberProfileViewEvents()
31
32
object OnKickActionSuccess : RoomMemberProfileViewEvents()
Original file line number Diff line number Diff line change @@ -161,6 +161,7 @@ class RoomMemberProfileViewModel @AssistedInject constructor(
161
161
when (action) {
162
162
is RoomMemberProfileAction .RetryFetchingInfo -> handleRetryFetchProfileInfo()
163
163
is RoomMemberProfileAction .IgnoreUser -> handleIgnoreAction()
164
+ is RoomMemberProfileAction .ReportUser -> handleReportAction()
164
165
is RoomMemberProfileAction .VerifyUser -> prepareVerification()
165
166
is RoomMemberProfileAction .ShareRoomMemberProfile -> handleShareRoomMemberProfile()
166
167
is RoomMemberProfileAction .SetPowerLevel -> handleSetPowerLevel(action)
@@ -172,6 +173,25 @@ class RoomMemberProfileViewModel @AssistedInject constructor(
172
173
}
173
174
}
174
175
176
+ private fun handleReportAction () {
177
+ viewModelScope.launch {
178
+ val event = try {
179
+ // The API need an Event, use the latest Event.
180
+ val latestEventId = room?.roomSummary()?.latestPreviewableEvent?.eventId ? : return @launch
181
+ room.reportingService()
182
+ .reportContent(
183
+ eventId = latestEventId,
184
+ score = - 100 ,
185
+ reason = " Reporting user ${initialState.userId} (eventId is not relevant)"
186
+ )
187
+ RoomMemberProfileViewEvents .OnReportActionSuccess
188
+ } catch (failure: Throwable ) {
189
+ RoomMemberProfileViewEvents .Failure (failure)
190
+ }
191
+ _viewEvents .post(event)
192
+ }
193
+ }
194
+
175
195
private fun handleOpenOrCreateDm (action : RoomMemberProfileAction .OpenOrCreateDm ) {
176
196
viewModelScope.launch {
177
197
_viewEvents .post(RoomMemberProfileViewEvents .Loading ())
You can’t perform that action at this time.
0 commit comments