mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-12 04:53:38 +00:00
Fix call info expiry
This commit is contained in:
parent
03766d57ee
commit
6769789e9c
@ -383,6 +383,24 @@ public class SmsDatabase extends MessagingDatabase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected Optional<InsertResult> insertMessageInbox(IncomingTextMessage message, long type, long serverTimestamp, boolean runIncrement, boolean runThreadUpdate) {
|
protected Optional<InsertResult> insertMessageInbox(IncomingTextMessage message, long type, long serverTimestamp, boolean runIncrement, boolean runThreadUpdate) {
|
||||||
|
Recipient recipient = Recipient.from(context, message.getSender(), true);
|
||||||
|
|
||||||
|
Recipient groupRecipient;
|
||||||
|
|
||||||
|
if (message.getGroupId() == null) {
|
||||||
|
groupRecipient = null;
|
||||||
|
} else {
|
||||||
|
groupRecipient = Recipient.from(context, message.getGroupId(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean unread = (Util.isDefaultSmsProvider(context) ||
|
||||||
|
message.isSecureMessage() || message.isGroup() || message.isCallInfo());
|
||||||
|
|
||||||
|
long threadId;
|
||||||
|
|
||||||
|
if (groupRecipient == null) threadId = DatabaseComponent.get(context).threadDatabase().getOrCreateThreadIdFor(recipient);
|
||||||
|
else threadId = DatabaseComponent.get(context).threadDatabase().getOrCreateThreadIdFor(groupRecipient);
|
||||||
|
|
||||||
if (message.isSecureMessage()) {
|
if (message.isSecureMessage()) {
|
||||||
type |= Types.SECURE_MESSAGE_BIT;
|
type |= Types.SECURE_MESSAGE_BIT;
|
||||||
} else if (message.isGroup()) {
|
} else if (message.isGroup()) {
|
||||||
@ -396,40 +414,11 @@ public class SmsDatabase extends MessagingDatabase {
|
|||||||
|
|
||||||
CallMessageType callMessageType = message.getCallType();
|
CallMessageType callMessageType = message.getCallType();
|
||||||
if (callMessageType != null) {
|
if (callMessageType != null) {
|
||||||
switch (callMessageType) {
|
long callMessageTypeMask = getCallMessageTypeMask(callMessageType);
|
||||||
case CALL_OUTGOING:
|
type |= callMessageTypeMask;
|
||||||
type |= Types.OUTGOING_CALL_TYPE;
|
deleteInfoMessages(threadId, callMessageTypeMask);
|
||||||
break;
|
|
||||||
case CALL_INCOMING:
|
|
||||||
type |= Types.INCOMING_CALL_TYPE;
|
|
||||||
break;
|
|
||||||
case CALL_MISSED:
|
|
||||||
type |= Types.MISSED_CALL_TYPE;
|
|
||||||
break;
|
|
||||||
case CALL_FIRST_MISSED:
|
|
||||||
type |= Types.FIRST_MISSED_CALL_TYPE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Recipient recipient = Recipient.from(context, message.getSender(), true);
|
|
||||||
|
|
||||||
Recipient groupRecipient;
|
|
||||||
|
|
||||||
if (message.getGroupId() == null) {
|
|
||||||
groupRecipient = null;
|
|
||||||
} else {
|
|
||||||
groupRecipient = Recipient.from(context, message.getGroupId(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean unread = (Util.isDefaultSmsProvider(context) ||
|
|
||||||
message.isSecureMessage() || message.isGroup() || message.isCallInfo());
|
|
||||||
|
|
||||||
long threadId;
|
|
||||||
|
|
||||||
if (groupRecipient == null) threadId = DatabaseComponent.get(context).threadDatabase().getOrCreateThreadIdFor(recipient);
|
|
||||||
else threadId = DatabaseComponent.get(context).threadDatabase().getOrCreateThreadIdFor(groupRecipient);
|
|
||||||
|
|
||||||
ContentValues values = new ContentValues(6);
|
ContentValues values = new ContentValues(6);
|
||||||
values.put(ADDRESS, message.getSender().serialize());
|
values.put(ADDRESS, message.getSender().serialize());
|
||||||
values.put(ADDRESS_DEVICE_ID, message.getSenderDeviceId());
|
values.put(ADDRESS_DEVICE_ID, message.getSenderDeviceId());
|
||||||
@ -479,6 +468,25 @@ public class SmsDatabase extends MessagingDatabase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private long getCallMessageTypeMask(CallMessageType callMessageType) {
|
||||||
|
long typeMask = 0;
|
||||||
|
switch (callMessageType) {
|
||||||
|
case CALL_OUTGOING:
|
||||||
|
typeMask = Types.OUTGOING_CALL_TYPE;
|
||||||
|
break;
|
||||||
|
case CALL_INCOMING:
|
||||||
|
typeMask = Types.INCOMING_CALL_TYPE;
|
||||||
|
break;
|
||||||
|
case CALL_MISSED:
|
||||||
|
typeMask = Types.MISSED_CALL_TYPE;
|
||||||
|
break;
|
||||||
|
case CALL_FIRST_MISSED:
|
||||||
|
typeMask = Types.FIRST_MISSED_CALL_TYPE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return typeMask;
|
||||||
|
}
|
||||||
|
|
||||||
public Optional<InsertResult> insertMessageInbox(IncomingTextMessage message, boolean runIncrement, boolean runThreadUpdate) {
|
public Optional<InsertResult> insertMessageInbox(IncomingTextMessage message, boolean runIncrement, boolean runThreadUpdate) {
|
||||||
return insertMessageInbox(message, Types.BASE_INBOX_TYPE, 0, runIncrement, runThreadUpdate);
|
return insertMessageInbox(message, Types.BASE_INBOX_TYPE, 0, runIncrement, runThreadUpdate);
|
||||||
}
|
}
|
||||||
@ -618,6 +626,12 @@ public class SmsDatabase extends MessagingDatabase {
|
|||||||
return getMessage(messageId);
|
return getMessage(messageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deleteInfoMessages(long threadId, long type) {
|
||||||
|
String where = THREAD_ID + " = ? AND (" + TYPE + " & " + type + ") <> 0";
|
||||||
|
int updated = getWritableDatabase().delete(TABLE_NAME, where, new String[] {threadId+""});
|
||||||
|
notifyConversationListeners(threadId);
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isDuplicate(IncomingTextMessage message, long threadId) {
|
private boolean isDuplicate(IncomingTextMessage message, long threadId) {
|
||||||
SQLiteDatabase database = databaseHelper.getReadableDatabase();
|
SQLiteDatabase database = databaseHelper.getReadableDatabase();
|
||||||
Cursor cursor = database.query(TABLE_NAME, null, DATE_SENT + " = ? AND " + ADDRESS + " = ? AND " + THREAD_ID + " = ?",
|
Cursor cursor = database.query(TABLE_NAME, null, DATE_SENT + " = ? AND " + ADDRESS + " = ? AND " + THREAD_ID + " = ?",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user