merge messages with related status (unsend, send, send_received)
This commit is contained in:
parent
4beb954da5
commit
d318af098d
|
@ -362,7 +362,8 @@ public class Message extends AbstractEntity {
|
||||||
message.getDownloadable() == null &&
|
message.getDownloadable() == null &&
|
||||||
message.getEncryption() != Message.ENCRYPTION_PGP &&
|
message.getEncryption() != Message.ENCRYPTION_PGP &&
|
||||||
this.getType() == message.getType() &&
|
this.getType() == message.getType() &&
|
||||||
this.getStatus() == message.getStatus() &&
|
//this.getStatus() == message.getStatus() &&
|
||||||
|
isStatusMergeable(this.getStatus(),message.getStatus()) &&
|
||||||
this.getEncryption() == message.getEncryption() &&
|
this.getEncryption() == message.getEncryption() &&
|
||||||
this.getCounterpart() != null &&
|
this.getCounterpart() != null &&
|
||||||
this.getCounterpart().equals(message.getCounterpart()) &&
|
this.getCounterpart().equals(message.getCounterpart()) &&
|
||||||
|
@ -374,6 +375,17 @@ public class Message extends AbstractEntity {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isStatusMergeable(int a, int b) {
|
||||||
|
return a == b || (
|
||||||
|
( a == Message.STATUS_SEND_RECEIVED && b == Message.STATUS_UNSEND)
|
||||||
|
|| (a == Message.STATUS_SEND_RECEIVED && b == Message.STATUS_SEND)
|
||||||
|
|| (a == Message.STATUS_UNSEND && b == Message.STATUS_SEND)
|
||||||
|
|| (a == Message.STATUS_UNSEND && b == Message.STATUS_SEND_RECEIVED)
|
||||||
|
|| (a == Message.STATUS_SEND && b == Message.STATUS_UNSEND)
|
||||||
|
|| (a == Message.STATUS_SEND && b == Message.STATUS_SEND_RECEIVED)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public String getMergedBody() {
|
public String getMergedBody() {
|
||||||
final Message next = this.next();
|
final Message next = this.next();
|
||||||
if (this.mergeable(next)) {
|
if (this.mergeable(next)) {
|
||||||
|
@ -387,6 +399,10 @@ public class Message extends AbstractEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMergedStatus() {
|
public int getMergedStatus() {
|
||||||
|
final Message next = this.next();
|
||||||
|
if (this.mergeable(next)) {
|
||||||
|
return next.getStatus();
|
||||||
|
}
|
||||||
return getStatus();
|
return getStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue