diff --git a/docs/XEPs.md b/docs/XEPs.md
index 0c33546af6e559cd8a6ca5c15f577b9fa52386d7..f88686e97a3fac35bea9551f1147431657945d60 100644
--- a/docs/XEPs.md
+++ b/docs/XEPs.md
@@ -28,3 +28,4 @@
* XEP-0357: Push Notifications
* XEP-0363: HTTP File Upload
* XEP-0368: SRV records for XMPP over TLS
+* XEP-0377: Spam Reporting
diff --git a/src/main/java/eu/siacs/conversations/generator/IqGenerator.java b/src/main/java/eu/siacs/conversations/generator/IqGenerator.java
index 884bc4affde42a9328d8d1e87cdddf495f3f3a9c..cb9ffd96fd20d52908913974d0f516609a7b4ea8 100644
--- a/src/main/java/eu/siacs/conversations/generator/IqGenerator.java
+++ b/src/main/java/eu/siacs/conversations/generator/IqGenerator.java
@@ -254,10 +254,14 @@ public class IqGenerator extends AbstractGenerator {
return iq;
}
- public IqPacket generateSetBlockRequest(final Jid jid) {
+ public IqPacket generateSetBlockRequest(final Jid jid, boolean reportSpam) {
final IqPacket iq = new IqPacket(IqPacket.TYPE.SET);
final Element block = iq.addChild("block", Xmlns.BLOCKING);
- block.addChild("item").setAttribute("jid", jid.toBareJid().toString());
+ final Element item = block.addChild("item").setAttribute("jid", jid.toBareJid().toString());
+ if (reportSpam) {
+ item.addChild("report", "urn:xmpp:reporting:0").addChild("spam");
+ }
+ Log.d(Config.LOGTAG,iq.toString());
return iq;
}
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
index 3bf1e7451b20ea1d80d355c3b680afa36c712951..3c48a308ec37904a052f9567cbc530d6f9c1d83b 100644
--- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
@@ -3346,10 +3346,10 @@ public class XmppConnectionService extends Service {
mDatabaseExecutor.execute(runnable);
}
- public void sendBlockRequest(final Blockable blockable) {
+ public void sendBlockRequest(final Blockable blockable, boolean reportSpam) {
if (blockable != null && blockable.getBlockedJid() != null) {
final Jid jid = blockable.getBlockedJid();
- this.sendIqPacket(blockable.getAccount(), getIqGenerator().generateSetBlockRequest(jid), new OnIqPacketReceived() {
+ this.sendIqPacket(blockable.getAccount(), getIqGenerator().generateSetBlockRequest(jid, reportSpam), new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(final Account account, final IqPacket packet) {
diff --git a/src/main/java/eu/siacs/conversations/ui/BlockContactDialog.java b/src/main/java/eu/siacs/conversations/ui/BlockContactDialog.java
index 9cf7e9f8576c2800878f4d2828f6dc6fe51d7d7e..b55a701f0440aef28d811ddec801f8a6b32f82d4 100644
--- a/src/main/java/eu/siacs/conversations/ui/BlockContactDialog.java
+++ b/src/main/java/eu/siacs/conversations/ui/BlockContactDialog.java
@@ -3,6 +3,11 @@ package eu.siacs.conversations.ui;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.CheckBox;
+import android.widget.LinearLayout;
+import android.widget.TextView;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Blockable;
@@ -15,14 +20,21 @@ public final class BlockContactDialog {
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
final boolean isBlocked = blockable.isBlocked();
builder.setNegativeButton(R.string.cancel, null);
+ LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ LinearLayout view = (LinearLayout) inflater.inflate(R.layout.dialog_block_contact,null);
+ TextView message = (TextView) view.findViewById(R.id.text);
+ final CheckBox report = (CheckBox) view.findViewById(R.id.report_spam);
+ final boolean reporting = blockable.getAccount().getXmppConnection().getFeatures().spamReporting();
+ report.setVisibility(!isBlocked && reporting ? View.VISIBLE : View.GONE);
+ builder.setView(view);
if (blockable.getJid().isDomainJid() || blockable.getAccount().isBlocked(blockable.getJid().toDomainJid())) {
builder.setTitle(isBlocked ? R.string.action_unblock_domain : R.string.action_block_domain);
- builder.setMessage(context.getResources().getString(isBlocked ? R.string.unblock_domain_text : R.string.block_domain_text,
+ message.setText(context.getResources().getString(isBlocked ? R.string.unblock_domain_text : R.string.block_domain_text,
blockable.getJid().toDomainJid()));
} else {
builder.setTitle(isBlocked ? R.string.action_unblock_contact : R.string.action_block_contact);
- builder.setMessage(context.getResources().getString(isBlocked ? R.string.unblock_contact_text : R.string.block_contact_text,
+ message.setText(context.getResources().getString(isBlocked ? R.string.unblock_contact_text : R.string.block_contact_text,
blockable.getJid().toBareJid()));
}
builder.setPositiveButton(isBlocked ? R.string.unblock : R.string.block, new DialogInterface.OnClickListener() {
@@ -32,7 +44,7 @@ public final class BlockContactDialog {
if (isBlocked) {
xmppConnectionService.sendUnblockRequest(blockable);
} else {
- xmppConnectionService.sendBlockRequest(blockable);
+ xmppConnectionService.sendBlockRequest(blockable, report.isChecked());
}
}
});
diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
index e3af48e3a717a11c412be17617d887546ce6d50d..2d934053db523bd42a67ae9f86a5e0e42912584f 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -1600,6 +1600,10 @@ public class XmppConnection implements Runnable {
return hasDiscoFeature(account.getServer(), Xmlns.BLOCKING);
}
+ public boolean spamReporting() {
+ return hasDiscoFeature(account.getServer(), "urn:xmpp:reporting:reason:spam:0");
+ }
+
public boolean register() {
return hasDiscoFeature(account.getServer(), Xmlns.REGISTER);
}
diff --git a/src/main/res/layout/dialog_block_contact.xml b/src/main/res/layout/dialog_block_contact.xml
new file mode 100644
index 0000000000000000000000000000000000000000..b3615533c4f4849577d585f13d26de1c4abfcfaf
--- /dev/null
+++ b/src/main/res/layout/dialog_block_contact.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 22d89a8122808ef160a196d73b0df87ae9446848..e53742e902afaed74ba7ac95fa923b2b55193fa9 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -686,4 +686,5 @@
Missing OMEMO keys from %s.
This is not a private, non-anonymous conference.
There are no members in this conference.
+ Report this JID as sending unwanted messages.