diff options
author | Christian Schneppe <christian@pix-art.de> | 2016-09-17 11:32:34 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-09-17 11:32:34 +0200 |
commit | c422e960a48d8edfa560b01c17e043e90fe9c120 (patch) | |
tree | 8804ce666b706f9d8ce5accff5cea21451ebf1f8 /src/main/java/de/pixart/messenger/persistance | |
parent | 0aea51fc3da3b534b520511b437a7c435cab530b (diff) |
use history clear date as minimum date for mam
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java index ba426d49c..79eecd869 100644 --- a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java +++ b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java @@ -11,6 +11,8 @@ import android.util.Base64; import android.util.Log; import android.util.Pair; +import org.json.JSONException; +import org.json.JSONObject; import org.whispersystems.libaxolotl.AxolotlAddress; import org.whispersystems.libaxolotl.IdentityKey; import org.whispersystems.libaxolotl.IdentityKeyPair; @@ -31,7 +33,6 @@ import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; -import org.json.JSONException; import de.pixart.messenger.Config; import de.pixart.messenger.crypto.axolotl.AxolotlService; @@ -727,21 +728,37 @@ public class DatabaseBackend extends SQLiteOpenHelper { } } + public Pair<Long, String> getLastClearDate(Account account) { + SQLiteDatabase db = this.getReadableDatabase(); + String[] columns = {Conversation.ATTRIBUTES}; + String selection = Conversation.ACCOUNT + "=?"; + String[] args = {account.getUuid()}; + Cursor cursor = db.query(Conversation.TABLENAME, columns, selection, args, null, null, null); + long maxClearDate = 0; + while (cursor.moveToNext()) { + try { + final JSONObject jsonObject = new JSONObject(cursor.getString(0)); + maxClearDate = Math.max(maxClearDate, jsonObject.getLong(Conversation.ATTRIBUTE_LAST_CLEAR_HISTORY)); + } catch (Exception e) { + //ignored + } + } + cursor.close(); + return new Pair<>(maxClearDate, null); + } + private Cursor getCursorForSession(Account account, AxolotlAddress contact) { final SQLiteDatabase db = this.getReadableDatabase(); - String[] columns = null; String[] selectionArgs = {account.getUuid(), contact.getName(), Integer.toString(contact.getDeviceId())}; - Cursor cursor = db.query(SQLiteAxolotlStore.SESSION_TABLENAME, - columns, + return db.query(SQLiteAxolotlStore.SESSION_TABLENAME, + null, SQLiteAxolotlStore.ACCOUNT + " = ? AND " + SQLiteAxolotlStore.NAME + " = ? AND " + SQLiteAxolotlStore.DEVICE_ID + " = ? ", selectionArgs, null, null, null); - - return cursor; } public SessionRecord loadSession(Account account, AxolotlAddress contact) { |