diff --git a/src/main/java/eu/siacs/conversations/entities/MucOptions.java b/src/main/java/eu/siacs/conversations/entities/MucOptions.java
index 0ea3a2883..98eb444c3 100644
--- a/src/main/java/eu/siacs/conversations/entities/MucOptions.java
+++ b/src/main/java/eu/siacs/conversations/entities/MucOptions.java
@@ -397,6 +397,11 @@ public class MucOptions {
return self.getRole().ranks(Role.MODERATOR) || (field != null && "1".equals(field.getValue()));
}
+ public boolean allowPm() {
+ Field field = this.form.getFieldByName("muc#roomconfig_allowpm");
+ return field == null || "1".equals(field.getValue());
+ }
+
public boolean participating() {
return !online()
|| self.getRole().ranks(Role.PARTICIPANT)
diff --git a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
index c17c59611..f4cf3182d 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
@@ -462,7 +462,11 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
}
return true;
case R.id.send_private_message:
- privateMsgInMuc(mConversation,mSelectedUser.getName());
+ if (mConversation.getMucOptions().allowPm()) {
+ privateMsgInMuc(mConversation,mSelectedUser.getName());
+ } else {
+ Toast.makeText(this, R.string.private_messages_are_disabled, Toast.LENGTH_SHORT).show();
+ }
return true;
case R.id.invite:
xmppConnectionService.directInvite(mConversation, jid);
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
index 11142082e..7ec358900 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
@@ -609,34 +609,28 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
}
}
});
- messageListAdapter
- .setOnContactPictureLongClicked(new OnContactPictureLongClicked() {
-
- @Override
- public void onContactPictureLongClicked(Message message) {
- if (message.getStatus() <= Message.STATUS_RECEIVED) {
- if (message.getConversation().getMode() == Conversation.MODE_MULTI) {
- Jid user = message.getCounterpart();
- if (user != null && !user.isBareJid()) {
- if (message.getConversation().getMucOptions().isUserInRoom(user)) {
- privateMessageWith(user);
- } else {
- Toast.makeText(activity, activity.getString(R.string.user_has_left_conference, user.getResourcepart()), Toast.LENGTH_SHORT).show();
- }
- }
- }
+ messageListAdapter.setOnContactPictureLongClicked(message -> {
+ if (message.getStatus() <= Message.STATUS_RECEIVED) {
+ if (message.getConversation().getMode() == Conversation.MODE_MULTI) {
+ final MucOptions mucOptions = conversation.getMucOptions();
+ if (!mucOptions.allowPm()) {
+ Toast.makeText(activity, R.string.private_messages_are_disabled, Toast.LENGTH_SHORT).show();
+ return;
+ }
+ Jid user = message.getCounterpart();
+ if (user != null && !user.isBareJid()) {
+ if (mucOptions.isUserInRoom(user)) {
+ privateMessageWith(user);
} else {
- activity.showQrCode();
+ Toast.makeText(activity, activity.getString(R.string.user_has_left_conference, user.getResourcepart()), Toast.LENGTH_SHORT).show();
}
}
- });
- messageListAdapter.setOnQuoteListener(new MessageAdapter.OnQuoteListener() {
-
- @Override
- public void onQuote(String text) {
- quoteText(text);
+ }
+ } else {
+ activity.showQrCode();
}
});
+ messageListAdapter.setOnQuoteListener(text -> quoteText(text));
messagesView.setAdapter(messageListAdapter);
registerForContextMenu(messagesView);
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index d0a1f85ba..557dd4daa 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -729,4 +729,5 @@
Copy to clipboard
Message copied to clipboard
Message
+ Private messages are disabled