Fix incorrect snippet generation by ignoring profile name change messages.
This commit is contained in:
parent
6e6105af05
commit
02508512d5
4 changed files with 13 additions and 16 deletions
|
@ -185,7 +185,7 @@ public class MmsSmsDatabase extends Database {
|
||||||
|
|
||||||
public Cursor getConversationSnippet(long threadId) {
|
public Cursor getConversationSnippet(long threadId) {
|
||||||
String order = MmsSmsColumns.NORMALIZED_DATE_RECEIVED + " DESC";
|
String order = MmsSmsColumns.NORMALIZED_DATE_RECEIVED + " DESC";
|
||||||
String selection = MmsSmsColumns.THREAD_ID + " = " + threadId;
|
String selection = MmsSmsColumns.THREAD_ID + " = " + threadId + " AND (" + SmsDatabase.TYPE + " IS NULL OR " + SmsDatabase.TYPE + " != " + SmsDatabase.Types.PROFILE_CHANGE_TYPE + ")";
|
||||||
|
|
||||||
return queryTables(PROJECTION, selection, order, "1");
|
return queryTables(PROJECTION, selection, order, "1");
|
||||||
}
|
}
|
||||||
|
|
|
@ -2351,7 +2351,7 @@ public class RecipientDatabase extends Database {
|
||||||
Log.w(TAG, "Had no sessions. No action necessary.");
|
Log.w(TAG, "Had no sessions. No action necessary.");
|
||||||
}
|
}
|
||||||
|
|
||||||
DatabaseFactory.getThreadDatabase(context).update(threadMerge.threadId, false, false, false);
|
DatabaseFactory.getThreadDatabase(context).update(threadMerge.threadId, false, false);
|
||||||
|
|
||||||
return byUuid;
|
return byUuid;
|
||||||
}
|
}
|
||||||
|
|
|
@ -898,7 +898,7 @@ public class SmsDatabase extends MessagingDatabase {
|
||||||
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
||||||
long threadId = getThreadIdForMessage(messageId);
|
long threadId = getThreadIdForMessage(messageId);
|
||||||
db.delete(TABLE_NAME, ID_WHERE, new String[] {messageId+""});
|
db.delete(TABLE_NAME, ID_WHERE, new String[] {messageId+""});
|
||||||
boolean threadDeleted = DatabaseFactory.getThreadDatabase(context).update(threadId, false, true, true);
|
boolean threadDeleted = DatabaseFactory.getThreadDatabase(context).update(threadId, false, true);
|
||||||
notifyConversationListeners(threadId);
|
notifyConversationListeners(threadId);
|
||||||
return threadDeleted;
|
return threadDeleted;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.MergeCursor;
|
import android.database.MergeCursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.util.SparseArray;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
@ -167,7 +166,7 @@ public class ThreadDatabase extends Database {
|
||||||
private void updateThread(long threadId, long count, String body, @Nullable Uri attachment,
|
private void updateThread(long threadId, long count, String body, @Nullable Uri attachment,
|
||||||
@Nullable String contentType, @Nullable Extra extra,
|
@Nullable String contentType, @Nullable Extra extra,
|
||||||
long date, int status, int deliveryReceiptCount, long type, boolean unarchive,
|
long date, int status, int deliveryReceiptCount, long type, boolean unarchive,
|
||||||
long expiresIn, int readReceiptCount, boolean causedByDeletion)
|
long expiresIn, int readReceiptCount)
|
||||||
{
|
{
|
||||||
String extraSerialized = null;
|
String extraSerialized = null;
|
||||||
|
|
||||||
|
@ -180,14 +179,12 @@ public class ThreadDatabase extends Database {
|
||||||
}
|
}
|
||||||
|
|
||||||
ContentValues contentValues = new ContentValues();
|
ContentValues contentValues = new ContentValues();
|
||||||
if (!MmsSmsColumns.Types.isProfileChange(type) || causedByDeletion) {
|
contentValues.put(DATE, date - date % 1000);
|
||||||
contentValues.put(DATE, date - date % 1000);
|
contentValues.put(SNIPPET, body);
|
||||||
contentValues.put(SNIPPET, body);
|
contentValues.put(SNIPPET_URI, attachment == null ? null : attachment.toString());
|
||||||
contentValues.put(SNIPPET_URI, attachment == null ? null : attachment.toString());
|
contentValues.put(SNIPPET_TYPE, type);
|
||||||
contentValues.put(SNIPPET_TYPE, type);
|
contentValues.put(SNIPPET_CONTENT_TYPE, contentType);
|
||||||
contentValues.put(SNIPPET_CONTENT_TYPE, contentType);
|
contentValues.put(SNIPPET_EXTRAS, extraSerialized);
|
||||||
contentValues.put(SNIPPET_EXTRAS, extraSerialized);
|
|
||||||
}
|
|
||||||
contentValues.put(MESSAGE_COUNT, count);
|
contentValues.put(MESSAGE_COUNT, count);
|
||||||
contentValues.put(STATUS, status);
|
contentValues.put(STATUS, status);
|
||||||
contentValues.put(DELIVERY_RECEIPT_COUNT, deliveryReceiptCount);
|
contentValues.put(DELIVERY_RECEIPT_COUNT, deliveryReceiptCount);
|
||||||
|
@ -827,10 +824,10 @@ public class ThreadDatabase extends Database {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean update(long threadId, boolean unarchive) {
|
public boolean update(long threadId, boolean unarchive) {
|
||||||
return update(threadId, unarchive, true, false);
|
return update(threadId, unarchive, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean update(long threadId, boolean unarchive, boolean allowDeletion, boolean causedByDeletion) {
|
public boolean update(long threadId, boolean unarchive, boolean allowDeletion) {
|
||||||
MmsSmsDatabase mmsSmsDatabase = DatabaseFactory.getMmsSmsDatabase(context);
|
MmsSmsDatabase mmsSmsDatabase = DatabaseFactory.getMmsSmsDatabase(context);
|
||||||
long count = mmsSmsDatabase.getConversationCount(threadId);
|
long count = mmsSmsDatabase.getConversationCount(threadId);
|
||||||
|
|
||||||
|
@ -852,7 +849,7 @@ public class ThreadDatabase extends Database {
|
||||||
updateThread(threadId, count, ThreadBodyUtil.getFormattedBodyFor(context, record), getAttachmentUriFor(record),
|
updateThread(threadId, count, ThreadBodyUtil.getFormattedBodyFor(context, record), getAttachmentUriFor(record),
|
||||||
getContentTypeFor(record), getExtrasFor(record),
|
getContentTypeFor(record), getExtrasFor(record),
|
||||||
record.getTimestamp(), record.getDeliveryStatus(), record.getDeliveryReceiptCount(),
|
record.getTimestamp(), record.getDeliveryStatus(), record.getDeliveryReceiptCount(),
|
||||||
record.getType(), unarchive, record.getExpiresIn(), record.getReadReceiptCount(), causedByDeletion);
|
record.getType(), unarchive, record.getExpiresIn(), record.getReadReceiptCount());
|
||||||
notifyConversationListListeners();
|
notifyConversationListListeners();
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue