aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/entities
diff options
context:
space:
mode:
authorSam Whited <sam@samwhited.com>2015-01-11 10:22:29 -0500
committerSam Whited <sam@samwhited.com>2015-01-11 18:32:00 -0500
commit3c5224251c1590f57e23ae339cb65cc8bdb54170 (patch)
tree87c9afeef904b71293201b1b1ead000a5664998f /src/main/java/eu/siacs/conversations/entities
parent12d63f2612377fbbb01e885145e2366bf0835f47 (diff)
Add XEP-0245 (/me command) support
Diffstat (limited to 'src/main/java/eu/siacs/conversations/entities')
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Message.java47
1 files changed, 33 insertions, 14 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Message.java b/src/main/java/eu/siacs/conversations/entities/Message.java
index 8cb48635..e8e579ab 100644
--- a/src/main/java/eu/siacs/conversations/entities/Message.java
+++ b/src/main/java/eu/siacs/conversations/entities/Message.java
@@ -36,17 +36,18 @@ public class Message extends AbstractEntity {
public static final int TYPE_STATUS = 3;
public static final int TYPE_PRIVATE = 4;
- public static String CONVERSATION = "conversationUuid";
- public static String COUNTERPART = "counterpart";
- public static String TRUE_COUNTERPART = "trueCounterpart";
- public static String BODY = "body";
- public static String TIME_SENT = "timeSent";
- public static String ENCRYPTION = "encryption";
- public static String STATUS = "status";
- public static String TYPE = "type";
- public static String REMOTE_MSG_ID = "remoteMsgId";
- public static String SERVER_MSG_ID = "serverMsgId";
- public static String RELATIVE_FILE_PATH = "relativeFilePath";
+ public static final String CONVERSATION = "conversationUuid";
+ public static final String COUNTERPART = "counterpart";
+ public static final String TRUE_COUNTERPART = "trueCounterpart";
+ public static final String BODY = "body";
+ public static final String TIME_SENT = "timeSent";
+ public static final String ENCRYPTION = "encryption";
+ public static final String STATUS = "status";
+ public static final String TYPE = "type";
+ public static final String REMOTE_MSG_ID = "remoteMsgId";
+ public static final String SERVER_MSG_ID = "serverMsgId";
+ public static final String RELATIVE_FILE_PATH = "relativeFilePath";
+
public boolean markable = false;
protected String conversationUuid;
protected Jid counterpart;
@@ -348,17 +349,35 @@ public class Message extends AbstractEntity {
}
public boolean mergeable(final Message message) {
- return message != null && (message.getType() == Message.TYPE_TEXT && this.getDownloadable() == null && message.getDownloadable() == null && message.getEncryption() != Message.ENCRYPTION_PGP && this.getType() == message.getType() && this.getStatus() == message.getStatus() && this.getEncryption() == message.getEncryption() && this.getCounterpart() != null && this.getCounterpart().equals(message.getCounterpart()) && (message.getTimeSent() - this.getTimeSent()) <= (Config.MESSAGE_MERGE_WINDOW * 1000) && !message.bodyContainsDownloadable() && !this.bodyContainsDownloadable());
+ return message != null &&
+ (message.getType() == Message.TYPE_TEXT &&
+ this.getDownloadable() == null &&
+ message.getDownloadable() == null &&
+ message.getEncryption() != Message.ENCRYPTION_PGP &&
+ this.getType() == message.getType() &&
+ this.getStatus() == message.getStatus() &&
+ this.getEncryption() == message.getEncryption() &&
+ this.getCounterpart() != null &&
+ this.getCounterpart().equals(message.getCounterpart()) &&
+ (message.getTimeSent() - this.getTimeSent()) <= (Config.MESSAGE_MERGE_WINDOW * 1000) &&
+ !message.bodyContainsDownloadable() &&
+ !this.bodyContainsDownloadable() &&
+ !this.body.startsWith("/me ")
+ );
}
public String getMergedBody() {
- Message next = this.next();
+ final Message next = this.next();
if (this.mergeable(next)) {
- return body.trim() + '\n' + next.getMergedBody();
+ return getBody() + '\n' + next.getMergedBody();
}
return body.trim();
}
+ public boolean hasMeCommand() {
+ return getMergedBody().startsWith("/me ");
+ }
+
public int getMergedStatus() {
return getStatus();
}