Add missing folder constraints to database query/update commands
This commit is contained in:
parent
a084e8e0db
commit
bc97920f70
1 changed files with 15 additions and 8 deletions
|
@ -117,7 +117,14 @@ class K9BackendFolder(
|
||||||
|
|
||||||
override fun isMessagePresent(messageServerId: String): Boolean {
|
override fun isMessagePresent(messageServerId: String): Boolean {
|
||||||
return database.execute(false) { db ->
|
return database.execute(false) { db ->
|
||||||
val cursor = db.query("messages", arrayOf("id"), "uid = ?", arrayOf(messageServerId), null, null, null)
|
val cursor = db.query(
|
||||||
|
"messages",
|
||||||
|
arrayOf("id"),
|
||||||
|
"folder_id = ? AND uid = ?",
|
||||||
|
arrayOf(databaseId, messageServerId),
|
||||||
|
null, null, null
|
||||||
|
)
|
||||||
|
|
||||||
cursor.use {
|
cursor.use {
|
||||||
cursor.moveToFirst()
|
cursor.moveToFirst()
|
||||||
}
|
}
|
||||||
|
@ -137,8 +144,8 @@ class K9BackendFolder(
|
||||||
val cursor = db.query(
|
val cursor = db.query(
|
||||||
"messages",
|
"messages",
|
||||||
arrayOf("deleted", "read", "flagged", "answered", "forwarded", "flags"),
|
arrayOf("deleted", "read", "flagged", "answered", "forwarded", "flags"),
|
||||||
"uid = ?",
|
"folder_id = ? AND uid = ?",
|
||||||
arrayOf(messageServerId),
|
arrayOf(databaseId, messageServerId),
|
||||||
null, null, null)
|
null, null, null)
|
||||||
|
|
||||||
cursor.use {
|
cursor.use {
|
||||||
|
@ -177,8 +184,8 @@ class K9BackendFolder(
|
||||||
val flagsColumnValue = database.getString(
|
val flagsColumnValue = database.getString(
|
||||||
table = "messages",
|
table = "messages",
|
||||||
column = "flags",
|
column = "flags",
|
||||||
selection = "uid = ?",
|
selection = "folder_id = ? AND uid = ?",
|
||||||
selectionArgs = *arrayOf(messageServerId)
|
selectionArgs = *arrayOf(databaseId, messageServerId)
|
||||||
) ?: ""
|
) ?: ""
|
||||||
|
|
||||||
val flags = flagsColumnValue.split(',').toMutableSet()
|
val flags = flagsColumnValue.split(',').toMutableSet()
|
||||||
|
@ -193,8 +200,8 @@ class K9BackendFolder(
|
||||||
database.setString(
|
database.setString(
|
||||||
table = "messages",
|
table = "messages",
|
||||||
column = "flags",
|
column = "flags",
|
||||||
selection = "uid = ?",
|
selection = "folder_id = ? AND uid = ?",
|
||||||
selectionArgs = *arrayOf(messageServerId),
|
selectionArgs = *arrayOf(databaseId, messageServerId),
|
||||||
value = serializedFlags
|
value = serializedFlags
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -336,7 +343,7 @@ class K9BackendFolder(
|
||||||
val contentValues = ContentValues().apply {
|
val contentValues = ContentValues().apply {
|
||||||
put(column, if (value) 1 else 0)
|
put(column, if (value) 1 else 0)
|
||||||
}
|
}
|
||||||
db.update("messages", contentValues, "uid = ?", arrayOf(messageServerId))
|
db.update("messages", contentValues, "folder_id = ? AND uid = ?", arrayOf(databaseId, messageServerId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue