File tree Expand file tree Collapse file tree 2 files changed +26
-6
lines changed
vector/src/main/java/im/vector/app/features Expand file tree Collapse file tree 2 files changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -766,7 +766,7 @@ class TimelineViewModel @AssistedInject constructor(
766
766
}
767
767
768
768
fun getRoom (roomId : String ): RoomSummary ? =
769
- session.roomService().getRoomSummary(roomId)
769
+ session.roomService().getRoomSummary(roomId)
770
770
771
771
private fun handleComposerFocusChange (action : RoomDetailAction .ComposerFocusChange ) {
772
772
if (room == null ) return
@@ -1147,7 +1147,22 @@ class TimelineViewModel @AssistedInject constructor(
1147
1147
if (room == null ) return
1148
1148
viewModelScope.launch {
1149
1149
val event = try {
1150
- room.reportingService().reportContent(action.eventId, - 100 , action.reason)
1150
+ if (action.user && action.senderId != null ) {
1151
+ // When reporting a user, use the user state event if available (it should always be available)
1152
+ val userStateEventId = room.stateService()
1153
+ .getStateEvent(EventType .STATE_ROOM_MEMBER , QueryStringValue .Equals (action.senderId))
1154
+ ?.eventId
1155
+ // If not found fallback to the provided event
1156
+ val eventId = userStateEventId ? : action.eventId
1157
+ room.reportingService()
1158
+ .reportContent(
1159
+ eventId = eventId,
1160
+ score = - 100 ,
1161
+ reason = action.reason
1162
+ )
1163
+ } else {
1164
+ room.reportingService().reportContent(action.eventId, - 100 , action.reason)
1165
+ }
1151
1166
RoomDetailViewEvents .ActionSuccess (action)
1152
1167
} catch (failure: Throwable ) {
1153
1168
RoomDetailViewEvents .ActionFailure (action, failure)
Original file line number Diff line number Diff line change @@ -174,15 +174,20 @@ class RoomMemberProfileViewModel @AssistedInject constructor(
174
174
}
175
175
176
176
private fun handleReportAction () {
177
+ room ? : return
177
178
viewModelScope.launch {
178
179
val event = try {
179
- // The API need an Event, use the latest Event.
180
- val latestEventId = room?.roomSummary()?.latestPreviewableEvent?.eventId ? : return @launch
180
+ // The API needs an Event, use user state event if available (it should always be available)
181
+ val userStateEventId = room.stateService()
182
+ .getStateEvent(EventType .STATE_ROOM_MEMBER , QueryStringValue .Equals (initialState.userId))
183
+ ?.eventId
184
+ // If not found fallback to the latest event
185
+ val eventId = (userStateEventId ? : room.roomSummary()?.latestPreviewableEvent?.eventId) ? : return @launch
181
186
room.reportingService()
182
187
.reportContent(
183
- eventId = latestEventId ,
188
+ eventId = eventId ,
184
189
score = - 100 ,
185
- reason = " Reporting user ${initialState.userId} (eventId is not relevant) "
190
+ reason = " Reporting user ${initialState.userId} "
186
191
)
187
192
RoomMemberProfileViewEvents .OnReportActionSuccess
188
193
} catch (failure: Throwable ) {
You can’t perform that action at this time.
0 commit comments