Skip to content

Commit

Permalink
Added ThreadEntity.| #74
Browse files Browse the repository at this point in the history
  • Loading branch information
DenBond7 committed Jul 31, 2024
1 parent 705ab4c commit dafc75a
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import com.flowcrypt.email.database.entity.LabelEntity
import com.flowcrypt.email.database.entity.MessageEntity
import com.flowcrypt.email.database.entity.PublicKeyEntity
import com.flowcrypt.email.database.entity.RecipientEntity
import com.flowcrypt.email.database.entity.ThreadEntity
import com.flowcrypt.email.extensions.kotlin.toInputStream
import com.flowcrypt.email.security.KeyStoreCryptoManager
import com.flowcrypt.email.security.pgp.PgpKey
Expand Down Expand Up @@ -70,6 +71,7 @@ import java.util.UUID
MessageEntity::class,
PublicKeyEntity::class,
AccountSettingsEntity::class,
ThreadEntity::class,
],
version = FlowCryptRoomDatabase.DB_VERSION
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* © 2016-present FlowCrypt a.s. Limitations apply. Contact [email protected]
* Contributors: denbond7
*/

package com.flowcrypt.email.database.entity

import android.provider.BaseColumns
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Index
import androidx.room.PrimaryKey

/**
* @author Denys Bondarenko
*/
@Entity(
tableName = ThreadEntity.TABLE_NAME,
indices = [
Index(
name = "account_account_type_in_threads",
value = ["account", "account_type"]
),
Index(
name = "threadId_account_account_type_in_threads",
value = ["thread_id", "account", "account_type"],
unique = true
)
],
foreignKeys = [
ForeignKey(
entity = AccountEntity::class,
parentColumns = ["email", "account_type"],
childColumns = ["account", "account_type"],
onDelete = ForeignKey.CASCADE
)
]
)
data class ThreadEntity(
@PrimaryKey(autoGenerate = true) @ColumnInfo(name = BaseColumns._ID) val id: Long? = null,
val account: String,
@ColumnInfo(name = "account_type", defaultValue = "NULL") val accountType: String? = null,
val folder: String,
@ColumnInfo(name = "thread_id", defaultValue = "NULL") val threadId: String? = null,
@ColumnInfo(name = "history_id", defaultValue = "NULL") val historyId: String? = null,
@ColumnInfo(defaultValue = "NULL") val subject: String? = null,
@ColumnInfo(defaultValue = "NULL") val addresses: String? = null,
@ColumnInfo(name = "date", defaultValue = "NULL") val date: Long? = null,
@ColumnInfo(name = "label_ids", defaultValue = "NULL") val labelIds: String? = null,
@ColumnInfo(name = "messages_count", defaultValue = "0") val messagesCount: Int = 0,
@ColumnInfo(name = "has_attachments", defaultValue = "0") val hasAttachments: Boolean = false,
@ColumnInfo(name = "has_pgp", defaultValue = "0") val hasPgp: Boolean = false,
) {
companion object {
const val TABLE_NAME = "threads"
}
}

0 comments on commit dafc75a

Please sign in to comment.