replace /me when quoting messages. fixes #3669

This commit is contained in:
Daniel Gultsch 2020-05-24 10:52:34 +02:00
parent 88cc097732
commit 7ca543e42f
3 changed files with 31 additions and 3 deletions

View File

@ -143,6 +143,16 @@ public class Contact implements ListItem, Blockable {
}
}
public String getPublicDisplayName() {
if (!TextUtils.isEmpty(this.presenceName)) {
return this.presenceName;
} else if (jid.getLocal() != null) {
return JidHelper.localPartOrFallback(jid);
} else {
return jid.getDomain().toEscapedString();
}
}
public String getProfilePhoto() {
return this.photoUri;
}

View File

@ -643,8 +643,8 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
!this.isOOb() &&
!message.treatAsDownloadable() &&
!this.treatAsDownloadable() &&
!message.getBody().startsWith(ME_COMMAND) &&
!this.getBody().startsWith(ME_COMMAND) &&
!message.hasMeCommand() &&
!this.hasMeCommand() &&
!this.bodyIsOnlyEmojis() &&
!message.bodyIsOnlyEmojis() &&
((this.axolotlFingerprint == null && message.axolotlFingerprint == null) || this.axolotlFingerprint.equals(message.getFingerprint())) &&

View File

@ -29,10 +29,13 @@
package eu.siacs.conversations.utils;
import com.google.common.base.Strings;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.regex.Pattern;
import eu.siacs.conversations.entities.Conversational;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.http.AesGcmURLStreamHandler;
import eu.siacs.conversations.http.P1S3UrlStreamHandler;
@ -45,7 +48,22 @@ public class MessageUtils {
public static String prepareQuote(Message message) {
final StringBuilder builder = new StringBuilder();
final String body = message.getMergedBody().toString();
final String body;
if (message.hasMeCommand()) {
final String nick;
if (message.getStatus() == Message.STATUS_RECEIVED) {
if (message.getConversation().getMode() == Conversational.MODE_MULTI) {
nick = Strings.nullToEmpty(message.getCounterpart().getResource());
} else {
nick = message.getContact().getPublicDisplayName();
}
} else {
nick = UIHelper.getMessageDisplayName(message);
}
body = nick + " " + message.getBody().substring(Message.ME_COMMAND.length());
} else {
body = message.getMergedBody().toString();;
}
for (String line : body.split("\n")) {
if (line.length() <= 0) {
continue;