mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-25 00:49:32 +00:00
Make 'push' status a type bit on both incoming and outgoing msgs.
This commit is contained in:
@@ -308,6 +308,10 @@ public class MmsDatabase extends Database implements MmsSmsColumns {
|
||||
updateMailboxBitmask(messageId, 0, Types.SECURE_MESSAGE_BIT);
|
||||
}
|
||||
|
||||
public void markAsPush(long messageId) {
|
||||
updateMailboxBitmask(messageId, 0, Types.PUSH_MESSAGE_BIT);
|
||||
}
|
||||
|
||||
public void markAsDecryptFailed(long messageId, long threadId) {
|
||||
updateMailboxBitmask(messageId, Types.ENCRYPTION_MASK, Types.ENCRYPTION_REMOTE_FAILED_BIT);
|
||||
notifyConversationListeners(threadId);
|
||||
@@ -448,7 +452,8 @@ public class MmsDatabase extends Database implements MmsSmsColumns {
|
||||
throws MmsException
|
||||
{
|
||||
return insertMessageInbox(masterSecret, retrieved, contentLocation, threadId,
|
||||
Types.BASE_INBOX_TYPE | Types.ENCRYPTION_SYMMETRIC_BIT);
|
||||
Types.BASE_INBOX_TYPE | Types.ENCRYPTION_SYMMETRIC_BIT |
|
||||
(retrieved.isPushMessage() ? Types.PUSH_MESSAGE_BIT : 0));
|
||||
}
|
||||
|
||||
public Pair<Long, Long> insertSecureMessageInbox(MasterSecret masterSecret,
|
||||
@@ -457,7 +462,8 @@ public class MmsDatabase extends Database implements MmsSmsColumns {
|
||||
throws MmsException
|
||||
{
|
||||
return insertMessageInbox(masterSecret, retrieved, contentLocation, threadId,
|
||||
Types.BASE_INBOX_TYPE | Types.SECURE_MESSAGE_BIT | Types.ENCRYPTION_REMOTE_BIT);
|
||||
Types.BASE_INBOX_TYPE | Types.SECURE_MESSAGE_BIT |
|
||||
Types.ENCRYPTION_REMOTE_BIT);
|
||||
}
|
||||
|
||||
public Pair<Long, Long> insertSecureDecryptedMessageInbox(MasterSecret masterSecret,
|
||||
@@ -466,7 +472,9 @@ public class MmsDatabase extends Database implements MmsSmsColumns {
|
||||
throws MmsException
|
||||
{
|
||||
return insertMessageInbox(masterSecret, retrieved, "", threadId,
|
||||
Types.BASE_INBOX_TYPE | Types.SECURE_MESSAGE_BIT | Types.ENCRYPTION_SYMMETRIC_BIT);
|
||||
Types.BASE_INBOX_TYPE | Types.SECURE_MESSAGE_BIT |
|
||||
Types.ENCRYPTION_SYMMETRIC_BIT |
|
||||
(retrieved.isPushMessage() ? Types.PUSH_MESSAGE_BIT : 0));
|
||||
}
|
||||
|
||||
public Pair<Long, Long> insertMessageInbox(NotificationInd notification) {
|
||||
@@ -870,7 +878,6 @@ public class MmsDatabase extends Database implements MmsSmsColumns {
|
||||
long threadId = cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.THREAD_ID));
|
||||
String address = cursor.getString(cursor.getColumnIndexOrThrow(MmsDatabase.ADDRESS));
|
||||
int addressDeviceId = cursor.getInt(cursor.getColumnIndexOrThrow(MmsDatabase.ADDRESS_DEVICE_ID));
|
||||
int status = cursor.getInt(cursor.getColumnIndexOrThrow(MmsDatabase.STATUS));
|
||||
DisplayRecord.Body body = getBody(cursor);
|
||||
int partCount = cursor.getInt(cursor.getColumnIndexOrThrow(MmsDatabase.PART_COUNT));
|
||||
Recipients recipients = getRecipientsFor(address);
|
||||
@@ -879,7 +886,7 @@ public class MmsDatabase extends Database implements MmsSmsColumns {
|
||||
|
||||
return new MediaMmsMessageRecord(context, id, recipients, recipients.getPrimaryRecipient(),
|
||||
addressDeviceId, dateSent, dateReceived, threadId, body,
|
||||
slideDeck, partCount, status, box);
|
||||
slideDeck, partCount, box);
|
||||
}
|
||||
|
||||
private Recipients getRecipientsFor(String address) {
|
||||
|
||||
@@ -38,6 +38,7 @@ public interface MmsSmsColumns {
|
||||
// Secure Message Information
|
||||
protected static final long SECURE_MESSAGE_BIT = 0x800000;
|
||||
protected static final long END_SESSION_BIT = 0x400000;
|
||||
protected static final long PUSH_MESSAGE_BIT = 0x200000;
|
||||
|
||||
// Group Message Information
|
||||
protected static final long GROUP_ADD_MEMBERS_BIT = 0x10000;
|
||||
@@ -79,6 +80,10 @@ public interface MmsSmsColumns {
|
||||
return (type & SECURE_MESSAGE_BIT) != 0;
|
||||
}
|
||||
|
||||
public static boolean isPushType(long type) {
|
||||
return (type & PUSH_MESSAGE_BIT) != 0;
|
||||
}
|
||||
|
||||
public static boolean isEndSessionType(long type) {
|
||||
return (type & END_SESSION_BIT) != 0;
|
||||
}
|
||||
|
||||
@@ -174,6 +174,10 @@ public class SmsDatabase extends Database implements MmsSmsColumns {
|
||||
updateTypeBitmask(id, 0, Types.SECURE_MESSAGE_BIT);
|
||||
}
|
||||
|
||||
public void markAsPush(long id) {
|
||||
updateTypeBitmask(id, 0, Types.PUSH_MESSAGE_BIT);
|
||||
}
|
||||
|
||||
public void markAsDecryptFailed(long id) {
|
||||
updateTypeBitmask(id, Types.ENCRYPTION_MASK, Types.ENCRYPTION_REMOTE_FAILED_BIT);
|
||||
}
|
||||
@@ -267,6 +271,8 @@ public class SmsDatabase extends Database implements MmsSmsColumns {
|
||||
type |= Types.ENCRYPTION_REMOTE_BIT;
|
||||
}
|
||||
|
||||
if (message.isPush()) type |= Types.PUSH_MESSAGE_BIT;
|
||||
|
||||
Recipients recipients;
|
||||
|
||||
try {
|
||||
@@ -470,7 +476,6 @@ public class SmsDatabase extends Database implements MmsSmsColumns {
|
||||
public static final int STATUS_COMPLETE = 0;
|
||||
public static final int STATUS_PENDING = 0x20;
|
||||
public static final int STATUS_FAILED = 0x40;
|
||||
public static final int STATUS_SENT_PUSH = 0x8000;
|
||||
}
|
||||
|
||||
public Reader readerFor(Cursor cursor) {
|
||||
|
||||
@@ -45,10 +45,10 @@ public class MediaMmsMessageRecord extends MessageRecord {
|
||||
Recipient individualRecipient, int recipientDeviceId,
|
||||
long dateSent, long dateReceived, long threadId, Body body,
|
||||
ListenableFutureTask<SlideDeck> slideDeck,
|
||||
int partCount, int deliveryStatus, long mailbox)
|
||||
int partCount, long mailbox)
|
||||
{
|
||||
super(context, id, body, recipients, individualRecipient, recipientDeviceId,
|
||||
dateSent, dateReceived, threadId, getGenericDeliveryStatus(deliveryStatus), mailbox);
|
||||
dateSent, dateReceived, threadId, DELIVERY_STATUS_NONE, mailbox);
|
||||
|
||||
this.context = context.getApplicationContext();
|
||||
this.partCount = partCount;
|
||||
@@ -82,8 +82,4 @@ public class MediaMmsMessageRecord extends MessageRecord {
|
||||
|
||||
return super.getDisplayBody();
|
||||
}
|
||||
|
||||
private static int getGenericDeliveryStatus(int status) {
|
||||
return status == SmsDatabase.Status.STATUS_SENT_PUSH ? DELVIERY_STATUS_PUSH : DELIVERY_STATUS_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,6 @@ public abstract class MessageRecord extends DisplayRecord {
|
||||
public static final int DELIVERY_STATUS_RECEIVED = 1;
|
||||
public static final int DELIVERY_STATUS_PENDING = 2;
|
||||
public static final int DELIVERY_STATUS_FAILED = 3;
|
||||
public static final int DELVIERY_STATUS_PUSH = 4;
|
||||
|
||||
private final Recipient individualRecipient;
|
||||
private final int recipientDeviceId;
|
||||
@@ -108,8 +107,8 @@ public abstract class MessageRecord extends DisplayRecord {
|
||||
return getDeliveryStatus() == DELIVERY_STATUS_RECEIVED;
|
||||
}
|
||||
|
||||
public boolean isPushSent() {
|
||||
return getDeliveryStatus() == DELVIERY_STATUS_PUSH;
|
||||
public boolean isPush() {
|
||||
return SmsDatabase.Types.isPushType(type);
|
||||
}
|
||||
|
||||
public boolean isStaleKeyExchange() {
|
||||
|
||||
@@ -97,8 +97,6 @@ public class SmsMessageRecord extends MessageRecord {
|
||||
private static int getGenericDeliveryStatus(int status) {
|
||||
if (status == SmsDatabase.Status.STATUS_NONE) {
|
||||
return MessageRecord.DELIVERY_STATUS_NONE;
|
||||
} else if (status >= SmsDatabase.Status.STATUS_SENT_PUSH) {
|
||||
return MessageRecord.DELVIERY_STATUS_PUSH;
|
||||
} else if (status >= SmsDatabase.Status.STATUS_FAILED) {
|
||||
return MessageRecord.DELIVERY_STATUS_FAILED;
|
||||
} else if (status >= SmsDatabase.Status.STATUS_PENDING) {
|
||||
|
||||
Reference in New Issue
Block a user