Include message id with spam report

Stephen Paul Weber created

If they didn't pick a specific message but report the whole chat as
spam, most recent message is spam.

Change summary

src/main/java/eu/siacs/conversations/ui/BlockContactDialog.java | 8 ++
1 file changed, 7 insertions(+), 1 deletion(-)

Detailed changes

src/main/java/eu/siacs/conversations/ui/BlockContactDialog.java 🔗

@@ -71,7 +71,13 @@ public final class BlockContactDialog {
 				xmppActivity.xmppConnectionService.sendUnblockRequest(blockable);
 			} else {
 				boolean toastShown = false;
-				if (xmppActivity.xmppConnectionService.sendBlockRequest(blockable, binding.reportSpam.isChecked(), serverMsgId)) {
+				var finalServerId = serverMsgId;
+				if (serverMsgId == null && binding.reportSpam.isChecked() && blockable instanceof Conversation) {
+					final var lastM = ((Conversation) blockable).getLatestMessage();
+					if (lastM != null) finalServerId = lastM.getServerMsgId();
+				}
+
+				if (xmppActivity.xmppConnectionService.sendBlockRequest(blockable, binding.reportSpam.isChecked(), finalServerId)) {
 					Toast.makeText(xmppActivity, R.string.corresponding_chats_closed, Toast.LENGTH_SHORT).show();
 					toastShown = true;
 				}