Refactor torch to mantra
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
package at.torch.compose
|
||||
|
||||
interface Platform {
|
||||
val name: String
|
||||
}
|
||||
|
||||
expect fun getPlatform(): Platform
|
||||
@@ -1,3 +0,0 @@
|
||||
package at.torch.compose
|
||||
|
||||
expect class PlatformContext
|
||||
@@ -1,5 +0,0 @@
|
||||
package at.torch.compose
|
||||
|
||||
class TorchGlobal(
|
||||
val platformContext: PlatformContext
|
||||
)
|
||||
@@ -1,209 +0,0 @@
|
||||
package at.torch.compose.database
|
||||
|
||||
import androidx.room3.Database
|
||||
import androidx.room3.RoomDatabase
|
||||
import androidx.room3.TypeConverters
|
||||
import androidx.room3.immediateTransaction
|
||||
import androidx.room3.useWriterConnection
|
||||
import at.torch.compose.database.converters.TorchConverters
|
||||
import at.torch.compose.database.dao.BroadcastNostrEventReceiptDao
|
||||
import at.torch.compose.database.dao.BroadcastNostrEventRequestDao
|
||||
import at.torch.compose.database.dao.ChatMessageBroadcastNostrEventReceiptRelationDao
|
||||
import at.torch.compose.database.dao.ChatMessageBroadcastNostrEventRequestRelationDao
|
||||
import at.torch.compose.database.dao.ChatMessageDao
|
||||
import at.torch.compose.database.dao.ChatMessageNostrEventRelationDao
|
||||
import at.torch.compose.database.dao.ChatRoomDao
|
||||
import at.torch.compose.database.dao.ConnectionDao
|
||||
import at.torch.compose.database.dao.GiftWrapMessageDao
|
||||
import at.torch.compose.database.dao.GiftWrapPayloadDao
|
||||
import at.torch.compose.database.dao.GiftWrapSealDao
|
||||
import at.torch.compose.database.dao.InReplyToRelationDao
|
||||
import at.torch.compose.database.dao.MarmotCommitResultDao
|
||||
import at.torch.compose.database.dao.MarmotOutboundDao
|
||||
import at.torch.compose.database.dao.MarmotGroupEventDao
|
||||
import at.torch.compose.database.dao.MarmotInnerEventDao
|
||||
import at.torch.compose.database.dao.MarmotKeyPackageBundleDao
|
||||
import at.torch.compose.database.dao.MarmotKeyPackageDao
|
||||
import at.torch.compose.database.dao.MarmotRetainedEpochSecretDao
|
||||
import at.torch.compose.database.dao.MentionDao
|
||||
import at.torch.compose.database.dao.NegentropySynchronizeRequestDao
|
||||
import at.torch.compose.database.dao.NegentropySynchronizeResultDao
|
||||
import at.torch.compose.database.dao.NostrDao
|
||||
import at.torch.compose.database.dao.NostrEventDao
|
||||
import at.torch.compose.database.dao.NostrEventRelayDao
|
||||
import at.torch.compose.database.dao.NostrNip17Dao
|
||||
import at.torch.compose.database.dao.ParticipantDao
|
||||
import at.torch.compose.database.dao.PostDao
|
||||
import at.torch.compose.database.dao.ProfileDao
|
||||
import at.torch.compose.database.dao.QuotedRelationDao
|
||||
import at.torch.compose.database.dao.ReactionDao
|
||||
import at.torch.compose.database.dao.RecentSearchDao
|
||||
import at.torch.compose.database.dao.RelayDao
|
||||
import at.torch.compose.database.dao.RepostedRelationDao
|
||||
import at.torch.compose.database.dao.SynchronizeNostrEventRequestDao
|
||||
import at.torch.compose.database.dao.SynchronizeNostrEventResultDao
|
||||
import at.torch.compose.database.dao.UnsignedNostrEventDao
|
||||
import at.torch.compose.database.dao.ZapDao
|
||||
import at.torch.compose.database.model.BroadcastNostrEventReceipt
|
||||
import at.torch.compose.database.model.BroadcastNostrEventRequest
|
||||
import at.torch.compose.database.model.ChatMessage
|
||||
import at.torch.compose.database.model.ChatMessageBroadcastNostrEventReceiptRelation
|
||||
import at.torch.compose.database.model.ChatMessageBroadcastNostrEventRequestRelation
|
||||
import at.torch.compose.database.model.ChatMessageNostrEventRelation
|
||||
import at.torch.compose.database.model.ChatRoom
|
||||
import at.torch.compose.database.model.Connection
|
||||
import at.torch.compose.database.model.GiftWrapMessage
|
||||
import at.torch.compose.database.model.GiftWrapPayload
|
||||
import at.torch.compose.database.model.GiftWrapSeal
|
||||
import at.torch.compose.database.model.InReplyToRelation
|
||||
import at.torch.compose.database.model.MarmotCommitResult
|
||||
import at.torch.compose.database.model.MarmotGroupEvent
|
||||
import at.torch.compose.database.model.MarmotInnerEvent
|
||||
import at.torch.compose.database.model.MarmotKeyPackage
|
||||
import at.torch.compose.database.model.MarmotKeyPackageBundle
|
||||
import at.torch.compose.database.model.MarmotRetainedEpochSecret
|
||||
import at.torch.compose.database.model.Mention
|
||||
import at.torch.compose.database.model.NegentropySynchronizeRequest
|
||||
import at.torch.compose.database.model.NegentropySynchronizeResult
|
||||
import at.torch.compose.database.model.NostrEvent
|
||||
import at.torch.compose.database.model.NostrEventRelay
|
||||
import at.torch.compose.database.model.Participant
|
||||
import at.torch.compose.database.model.Post
|
||||
import at.torch.compose.database.model.Profile
|
||||
import at.torch.compose.database.model.QuotedRelation
|
||||
import at.torch.compose.database.model.Reaction
|
||||
import at.torch.compose.database.model.RecentSearch
|
||||
import at.torch.compose.database.model.Relay
|
||||
import at.torch.compose.database.model.RepostedRelation
|
||||
import at.torch.compose.database.model.SynchronizeNostrEventRequest
|
||||
import at.torch.compose.database.model.SynchronizeNostrEventResult
|
||||
import at.torch.compose.database.model.UnsignedNostrEvent
|
||||
import at.torch.compose.database.model.Zap
|
||||
import kotlin.time.Instant
|
||||
|
||||
val GENESIS_AT = Instant.fromEpochMilliseconds(1231006505000L)
|
||||
|
||||
@Database(
|
||||
entities = [
|
||||
BroadcastNostrEventReceipt::class,
|
||||
BroadcastNostrEventRequest::class,
|
||||
Connection::class,
|
||||
ChatMessage::class,
|
||||
ChatMessageBroadcastNostrEventRequestRelation::class,
|
||||
ChatMessageBroadcastNostrEventReceiptRelation::class,
|
||||
ChatMessageNostrEventRelation::class,
|
||||
ChatRoom::class,
|
||||
GiftWrapMessage::class,
|
||||
GiftWrapSeal::class,
|
||||
GiftWrapPayload::class,
|
||||
InReplyToRelation::class,
|
||||
MarmotCommitResult::class,
|
||||
MarmotGroupEvent::class,
|
||||
MarmotInnerEvent::class,
|
||||
MarmotKeyPackage::class,
|
||||
MarmotKeyPackageBundle::class,
|
||||
MarmotRetainedEpochSecret::class,
|
||||
Mention::class,
|
||||
NegentropySynchronizeRequest::class,
|
||||
NegentropySynchronizeResult::class,
|
||||
NostrEvent::class,
|
||||
NostrEventRelay::class,
|
||||
Participant::class,
|
||||
Post::class,
|
||||
Profile::class,
|
||||
QuotedRelation::class,
|
||||
Reaction::class,
|
||||
RecentSearch::class,
|
||||
Relay::class,
|
||||
RepostedRelation::class,
|
||||
SynchronizeNostrEventRequest::class,
|
||||
SynchronizeNostrEventResult::class,
|
||||
UnsignedNostrEvent::class,
|
||||
Zap::class
|
||||
],
|
||||
version = 1
|
||||
)
|
||||
@TypeConverters(TorchConverters::class)
|
||||
abstract class TorchDatabase: RoomDatabase() {
|
||||
abstract fun broadcastNostrEventReceiptDao(): BroadcastNostrEventReceiptDao
|
||||
abstract fun broadcastNostrEventRequestDao(): BroadcastNostrEventRequestDao
|
||||
|
||||
abstract fun chatMessageDao(): ChatMessageDao
|
||||
|
||||
abstract fun chatMessageBroadcastNostrEventRequestRelationDao(): ChatMessageBroadcastNostrEventRequestRelationDao
|
||||
|
||||
abstract fun chatMessageBroadcastNostrEventReceiptRelationDao(): ChatMessageBroadcastNostrEventReceiptRelationDao
|
||||
|
||||
abstract fun chatMessageNostrEventRelationDao(): ChatMessageNostrEventRelationDao
|
||||
|
||||
abstract fun chatRoomDao(): ChatRoomDao
|
||||
|
||||
abstract fun connectionDao(): ConnectionDao
|
||||
|
||||
abstract fun giftWrapMessageDao(): GiftWrapMessageDao
|
||||
|
||||
abstract fun giftWrapSealDao(): GiftWrapSealDao
|
||||
|
||||
abstract fun giftWrapPayloadDao(): GiftWrapPayloadDao
|
||||
|
||||
abstract fun inReplyToRelationDao(): InReplyToRelationDao
|
||||
|
||||
abstract fun marmotCommitResultDao(): MarmotCommitResultDao
|
||||
|
||||
abstract fun marmotGroupEventDao(): MarmotGroupEventDao
|
||||
|
||||
abstract fun marmotInnerEventDao(): MarmotInnerEventDao
|
||||
|
||||
abstract fun marmotKeyPackageBundleDao(): MarmotKeyPackageBundleDao
|
||||
|
||||
abstract fun marmotKeyPackageDao(): MarmotKeyPackageDao
|
||||
|
||||
abstract fun marmotOutboundDao(): MarmotOutboundDao
|
||||
|
||||
abstract fun marmotRetainedEpochSecretDao(): MarmotRetainedEpochSecretDao
|
||||
|
||||
abstract fun mentionDao(): MentionDao
|
||||
|
||||
abstract fun negentropySynchronizeRequestDao(): NegentropySynchronizeRequestDao
|
||||
|
||||
abstract fun negentropySynchronizeResultDao(): NegentropySynchronizeResultDao
|
||||
|
||||
abstract fun nostrDao(): NostrDao
|
||||
|
||||
abstract fun nostrEventDao(): NostrEventDao
|
||||
|
||||
abstract fun nostrEventRelayDao(): NostrEventRelayDao
|
||||
|
||||
abstract fun nostrNip17Dao(): NostrNip17Dao
|
||||
|
||||
abstract fun participantDao(): ParticipantDao
|
||||
|
||||
abstract fun postDao(): PostDao
|
||||
|
||||
abstract fun profileDao(): ProfileDao
|
||||
|
||||
abstract fun quotedRelationDao(): QuotedRelationDao
|
||||
|
||||
abstract fun reactionDao(): ReactionDao
|
||||
|
||||
abstract fun recentSearchDao(): RecentSearchDao
|
||||
|
||||
abstract fun relayDao(): RelayDao
|
||||
|
||||
abstract fun repostedRelationDao(): RepostedRelationDao
|
||||
|
||||
abstract fun synchronizeNostrEventRequestDao(): SynchronizeNostrEventRequestDao
|
||||
|
||||
abstract fun synchronizeNostrEventResultDao(): SynchronizeNostrEventResultDao
|
||||
|
||||
abstract fun unsignedNostrEventDao(): UnsignedNostrEventDao
|
||||
abstract fun zapDao(): ZapDao
|
||||
|
||||
suspend fun wipeData() {
|
||||
useWriterConnection { transactor ->
|
||||
transactor.immediateTransaction {
|
||||
// TODO: Actually delete the data...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package at.torch.compose.database.builder
|
||||
|
||||
import androidx.room3.RoomDatabase
|
||||
import androidx.sqlite.driver.bundled.BundledSQLiteDriver
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.IO
|
||||
|
||||
expect object PlatformDatabaseBuilder {
|
||||
fun getDatabaseBuilder(platformContext: at.torch.compose.PlatformContext): RoomDatabase.Builder<at.torch.compose.database.TorchDatabase>
|
||||
|
||||
fun getInMemoryDatabaseBuilder(platform: at.torch.compose.PlatformContext): RoomDatabase.Builder<at.torch.compose.database.TorchDatabase>
|
||||
}
|
||||
|
||||
fun getRoomDatabase(
|
||||
builder: RoomDatabase.Builder<at.torch.compose.database.TorchDatabase>
|
||||
): at.torch.compose.database.TorchDatabase {
|
||||
return builder
|
||||
.setDriver(BundledSQLiteDriver())
|
||||
.setQueryCoroutineContext(Dispatchers.IO)
|
||||
.build()
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package at.torch.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Dao
|
||||
interface BroadcastNostrEventReceiptDao {
|
||||
@Query("SELECT * FROM BroadcastNostrEventReceipt")
|
||||
fun getAllBroadcastNostrEventReceipts(): List<at.torch.compose.database.model.BroadcastNostrEventReceipt>
|
||||
|
||||
@Query("SELECT * FROM BroadcastNostrEventReceipt WHERE id = :id")
|
||||
fun getBroadcastNostrEventReceiptById(id: Long): Flow<at.torch.compose.database.model.BroadcastNostrEventReceipt?>
|
||||
|
||||
@Query("SELECT * FROM BroadcastNostrEventReceipt WHERE nostrEventId = :nostrEventId")
|
||||
fun getBroadcastNostrEventReceiptByNostrEventId(nostrEventId: String): Flow<at.torch.compose.database.model.BroadcastNostrEventReceipt?>
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(broadcastNostrEventReceipt: at.torch.compose.database.model.BroadcastNostrEventReceipt): Long
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package at.torch.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Upsert
|
||||
|
||||
@Dao
|
||||
interface ChatMessageNostrEventRelationDao {
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(chatMessageNostrEventRelation: at.torch.compose.database.model.ChatMessageNostrEventRelation)
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package at.torch.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
|
||||
@Dao
|
||||
interface GiftWrapMessageDao {
|
||||
@Query("SELECT * FROM GiftWrapMessage")
|
||||
fun getAllGiftWrapMessages(): List<at.torch.compose.database.model.GiftWrapMessage>
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(giftWrapMessage: at.torch.compose.database.model.GiftWrapMessage)
|
||||
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package at.torch.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
|
||||
@Dao
|
||||
interface GiftWrapSealDao {
|
||||
@Query("SELECT * FROM GiftWrapSeal")
|
||||
fun getAllGiftWrapSeals(): List<at.torch.compose.database.model.GiftWrapSeal>
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(giftWrapSeal: at.torch.compose.database.model.GiftWrapSeal)
|
||||
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package at.torch.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
import at.torch.compose.database.model.MarmotGroupEvent
|
||||
import at.torch.compose.database.model.MarmotInnerEvent
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Dao
|
||||
interface MarmotGroupEventDao {
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(marmotGroupEvent: MarmotGroupEvent)
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package at.torch.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Upsert
|
||||
|
||||
@Dao
|
||||
interface NegentropySynchronizeResultDao {
|
||||
@Upsert
|
||||
fun upsert(negentropySynchronizeResult: at.torch.compose.database.model.NegentropySynchronizeResult)
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package at.torch.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Upsert
|
||||
|
||||
@Dao
|
||||
interface NostrEventRelayDao {
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(nostrEventRelay: at.torch.compose.database.model.NostrEventRelay)
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package at.torch.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Insert
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
|
||||
@Dao
|
||||
interface PostDao {
|
||||
@Query("SELECT * FROM Post")
|
||||
fun getAllPosts(): List<at.torch.compose.database.model.intermdiate.LocalPost>
|
||||
|
||||
@Query("SELECT * FROM Post WHERE id = :id")
|
||||
fun getPostById(id: String): at.torch.compose.database.model.Post?
|
||||
|
||||
@Insert
|
||||
suspend fun insert(post: at.torch.compose.database.model.Post)
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(post: at.torch.compose.database.model.Post)
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package at.torch.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Dao
|
||||
interface ReactionDao {
|
||||
@Query("SELECT * FROM Reaction")
|
||||
fun getAllReactions(): List<at.torch.compose.database.model.Reaction>
|
||||
|
||||
@Query("SELECT * FROM Reaction WHERE id = :id")
|
||||
fun getReactionById(id: String): Flow<at.torch.compose.database.model.Reaction?>
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(reaction: at.torch.compose.database.model.Reaction)
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package at.torch.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Delete
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Dao
|
||||
interface RecentSearchDao {
|
||||
@Query("SELECT * FROM RecentSearch WHERE `query` = :query")
|
||||
fun observeRecentSearchByQuery(query: String): Flow<at.torch.compose.database.model.RecentSearch?>
|
||||
|
||||
@Query("SELECT * FROM RecentSearch ORDER BY createdAt DESC LIMIT :limit ")
|
||||
fun getAllRecentSearches(limit: Int = 21): List<at.torch.compose.database.model.RecentSearch>
|
||||
|
||||
@Delete
|
||||
fun deleteRecentSearch(recentSearch: at.torch.compose.database.model.RecentSearch)
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(recentSearch: at.torch.compose.database.model.RecentSearch)
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package at.torch.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Dao
|
||||
interface RelayDao {
|
||||
@Query("SELECT * FROM Relay")
|
||||
fun getAllPosts(): List<at.torch.compose.database.model.Relay>
|
||||
|
||||
@Query("SELECT * FROM Relay WHERE publicKey = :publicKey")
|
||||
fun observePublicKeyRelays(publicKey: String): Flow<List<at.torch.compose.database.model.Relay>>
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(relay: at.torch.compose.database.model.Relay)
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package at.torch.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
|
||||
@Dao
|
||||
interface RepostedRelationDao {
|
||||
@Query("SELECT * FROM RepostedRelation")
|
||||
fun getAllReposts(): List<at.torch.compose.database.model.RepostedRelation>
|
||||
|
||||
@Query("SELECT * FROM RepostedRelation WHERE repostingNostrEventId = :repostingNostrEventId")
|
||||
fun getRepostByRepostingId(repostingNostrEventId: String): at.torch.compose.database.model.RepostedRelation?
|
||||
|
||||
@Query("SELECT * FROM RepostedRelation WHERE repostedNostrEventId = :repostedNostrEventId")
|
||||
fun getRepostByRepostedId(repostedNostrEventId: String): at.torch.compose.database.model.RepostedRelation?
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(repostedRelation: at.torch.compose.database.model.RepostedRelation)
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package at.torch.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Upsert
|
||||
|
||||
@Dao
|
||||
interface SynchronizeNostrEventResultDao {
|
||||
@Upsert
|
||||
fun upsert(synchronizeNostrEventResult: at.torch.compose.database.model.SynchronizeNostrEventResult)
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package at.torch.compose.database.model.intermdiate
|
||||
|
||||
import androidx.room3.Embedded
|
||||
import androidx.room3.Relation
|
||||
|
||||
data class LocalBroadcastNostrEventRequest(
|
||||
@Embedded val broadcastNostrEventRequest: at.torch.compose.database.model.BroadcastNostrEventRequest,
|
||||
|
||||
@Relation(
|
||||
parentColumns = ["nostrEventId"],
|
||||
entityColumns = ["id"]
|
||||
)
|
||||
val nostrEvent: at.torch.compose.database.model.NostrEvent,
|
||||
)
|
||||
@@ -1,34 +0,0 @@
|
||||
package at.torch.compose.database.model.intermdiate
|
||||
|
||||
import androidx.room3.Embedded
|
||||
import androidx.room3.Relation
|
||||
|
||||
data class LocalChatMessage(
|
||||
@Embedded val chatMessage: at.torch.compose.database.model.ChatMessage,
|
||||
|
||||
@Relation(
|
||||
parentColumns = ["senderPublicKey"],
|
||||
entityColumns = ["publicKey"]
|
||||
)
|
||||
val profile: at.torch.compose.database.model.Profile?,
|
||||
|
||||
@Relation(
|
||||
parentColumns = ["id"],
|
||||
entityColumns = ["chatMessageId"]
|
||||
)
|
||||
val chatMessageBroadcastNostrEventReceiptRelation: at.torch.compose.database.model.ChatMessageBroadcastNostrEventReceiptRelation? = null,
|
||||
|
||||
|
||||
@Relation(
|
||||
parentColumns = ["id"],
|
||||
entityColumns = ["chatMessageId"]
|
||||
)
|
||||
val chatMessageBroadcastNostrEventRequestRelation: at.torch.compose.database.model.ChatMessageBroadcastNostrEventRequestRelation? = null,
|
||||
|
||||
|
||||
@Relation(
|
||||
parentColumns = ["id"],
|
||||
entityColumns = ["chatMessageId"]
|
||||
)
|
||||
val chatMessageNostrEventRelation: at.torch.compose.database.model.ChatMessageNostrEventRelation? = null,
|
||||
)
|
||||
@@ -1,4 +0,0 @@
|
||||
package at.torch.compose.database.model.typealiases
|
||||
|
||||
typealias HexArray = Array<String>
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
package at.torch.compose.database.model.typealiases
|
||||
|
||||
typealias KindArray = Array<Int>
|
||||
@@ -1,3 +0,0 @@
|
||||
package at.torch.compose.database.model.typealiases
|
||||
|
||||
typealias SynchronizationFilterArray = Array<at.torch.compose.database.model.types.SynchronizationFilter>
|
||||
@@ -1,5 +0,0 @@
|
||||
package at.torch.compose.database.repository
|
||||
|
||||
class DatabasePostRepository(
|
||||
private val database: at.torch.compose.database.TorchDatabase
|
||||
): at.torch.compose.repository.PostRepository
|
||||
@@ -1,12 +0,0 @@
|
||||
package at.torch.compose.database.repository
|
||||
|
||||
class DatabaseSearchRepository(
|
||||
private val database: at.torch.compose.database.TorchDatabase
|
||||
): at.torch.compose.repository.SearchRepository {
|
||||
|
||||
override suspend fun submitSearch(synchronizeNostrEventRequests: List<at.torch.compose.database.model.SynchronizeNostrEventRequest>) {
|
||||
database.synchronizeNostrEventRequestDao().insert(
|
||||
synchronizeNostrEventRequests = synchronizeNostrEventRequests
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
package at.torch.compose.exceptions
|
||||
|
||||
open class GiftWrapImpersonationException(message: String? = null, cause: Throwable? = null) : Exception(message, cause)
|
||||
@@ -1,3 +0,0 @@
|
||||
package at.torch.compose.exceptions
|
||||
|
||||
open class GiftWrapPayloadUnsupportedException(message: String? = null, cause: Throwable? = null) : Exception(message, cause)
|
||||
@@ -1,3 +0,0 @@
|
||||
package at.torch.compose.exceptions
|
||||
|
||||
open class GiftWrapSealDecryptionException(message: String? = null, cause: Throwable? = null) : Exception(message, cause)
|
||||
@@ -1,3 +0,0 @@
|
||||
package at.torch.compose.exceptions
|
||||
|
||||
open class GiftWrapUnsealException(message: String? = null, cause: Throwable? = null) : Exception(message, cause)
|
||||
@@ -1,3 +0,0 @@
|
||||
package at.torch.compose.exceptions
|
||||
|
||||
class InvalidNostrPrivateKeyException: RuntimeException()
|
||||
@@ -1,3 +0,0 @@
|
||||
package at.torch.compose.exceptions
|
||||
|
||||
open class SignatureException(message: String? = null, cause: Throwable? = null) : Exception(message, cause)
|
||||
@@ -1,3 +0,0 @@
|
||||
package at.torch.compose.exceptions
|
||||
|
||||
class SigningRejectedException(message: String? = null, cause: Throwable? = null) : SignatureException(message, cause)
|
||||
@@ -1,26 +0,0 @@
|
||||
package at.torch.compose.managers
|
||||
|
||||
class AuxDatabaseManager(
|
||||
torchGlobal: at.torch.compose.TorchGlobal
|
||||
) {
|
||||
val auxDatabase by lazy {
|
||||
_root_ide_package_.at.torch.compose.database.builder.getRoomDatabase(
|
||||
at.torch.compose.database.builder.PlatformDatabaseBuilder.getDatabaseBuilder(
|
||||
torchGlobal.platformContext
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamic data like user feeds and the likes will be in a in-memory db.
|
||||
*
|
||||
* We may also decide to just use the normal DB and manage what's saved better...
|
||||
*/
|
||||
val inMemoryAuxDatabase by lazy {
|
||||
_root_ide_package_.at.torch.compose.database.builder.getRoomDatabase(
|
||||
at.torch.compose.database.builder.PlatformDatabaseBuilder.getInMemoryDatabaseBuilder(
|
||||
torchGlobal.platformContext
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package at.torch.compose.repository
|
||||
|
||||
/**
|
||||
* As seen in Primal
|
||||
*
|
||||
* https://github.com/PrimalHQ/primal-android-app/blob/a7e32e2203555d27e60a749238175cd1ee0fa2af/domain/primal/src/commonMain/kotlin/net/primal/domain/global/CachingImportRepository.kt
|
||||
*
|
||||
*/
|
||||
interface CachingImportRepository {
|
||||
suspend fun cacheNostrEvents(vararg events: at.torch.compose.database.model.NostrEvent)
|
||||
suspend fun cacheNostrEvents(events: List<at.torch.compose.database.model.NostrEvent>)
|
||||
|
||||
suspend fun importEvents(events: List<at.torch.compose.database.model.NostrEvent>): Boolean
|
||||
suspend fun broadcastEvents(events: List<at.torch.compose.database.model.NostrEvent>, relays: List<String>): Result<List<at.torch.compose.network.relays.broadcast.BroadcastEventResponse>>
|
||||
|
||||
companion object {
|
||||
val NO_OP_CACHING_IMPORT_REPOSITORY = object : CachingImportRepository {
|
||||
override suspend fun cacheNostrEvents(vararg events: at.torch.compose.database.model.NostrEvent) {
|
||||
}
|
||||
|
||||
override suspend fun cacheNostrEvents(events: List<at.torch.compose.database.model.NostrEvent>) {
|
||||
|
||||
}
|
||||
|
||||
override suspend fun importEvents(events: List<at.torch.compose.database.model.NostrEvent>): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override suspend fun broadcastEvents(
|
||||
events: List<at.torch.compose.database.model.NostrEvent>,
|
||||
relays: List<String>
|
||||
): Result<List<at.torch.compose.network.relays.broadcast.BroadcastEventResponse>> {
|
||||
return Result.success(
|
||||
emptyList()
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
package at.torch.compose.repository
|
||||
|
||||
interface PostRepository
|
||||
@@ -1,6 +0,0 @@
|
||||
package at.torch.compose.ui.composable.navigation.routes
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data object AuthenticatedProfileRoute
|
||||
@@ -1,6 +0,0 @@
|
||||
package at.torch.compose.ui.composable.navigation.routes
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
object BlankRoute: Route()
|
||||
@@ -1,6 +0,0 @@
|
||||
package at.torch.compose.ui.composable.navigation.routes
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
object LandingRoute: Route()
|
||||
@@ -1,3 +0,0 @@
|
||||
package at.torch.compose.ui.composable.navigation.routes
|
||||
|
||||
abstract class Route
|
||||
@@ -1,6 +0,0 @@
|
||||
package at.torch.compose.ui.composable.navigation.routes
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
object SignInRoute: Route()
|
||||
@@ -1,6 +0,0 @@
|
||||
package at.torch.compose.ui.composable.navigation.routes
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data object SovereignWalletStartupRoute
|
||||
@@ -1,24 +0,0 @@
|
||||
package at.torch.compose.ui.view.state
|
||||
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
|
||||
abstract class WriteNewNoteUIState {
|
||||
data object Loading: WriteNewNoteUIState()
|
||||
|
||||
data object Error: WriteNewNoteUIState()
|
||||
|
||||
data class InputPrompt(
|
||||
val localProfile: at.torch.compose.database.model.intermdiate.LocalProfileWithFollowing,
|
||||
val inReplyToNostrEvent: at.torch.compose.database.model.intermdiate.LocalNostrEvent? = null,
|
||||
val quotedNostrEvent: at.torch.compose.database.model.intermdiate.LocalNostrEvent? = null,
|
||||
val replayToId: HexKey? = null,
|
||||
): WriteNewNoteUIState()
|
||||
|
||||
data class ConfirmNote(
|
||||
val localProfile: at.torch.compose.database.model.intermdiate.LocalProfileWithFollowing,
|
||||
val inReplyToNostrEvent: at.torch.compose.database.model.intermdiate.LocalNostrEvent? = null,
|
||||
val quotedNostrEvent: at.torch.compose.database.model.intermdiate.LocalNostrEvent? = null,
|
||||
val text: String,
|
||||
) : WriteNewNoteUIState()
|
||||
|
||||
}
|
||||
@@ -6,13 +6,13 @@ import fr.acinq.lightning.utils.ServerAddress
|
||||
import fr.acinq.phoenix.utils.extensions.isOnion
|
||||
import kotlinx.serialization.Serializable
|
||||
import org.jetbrains.compose.resources.getString
|
||||
import torch.composeapp.generated.resources.Res
|
||||
import torch.composeapp.generated.resources.currency_ars_bm
|
||||
import torch.composeapp.generated.resources.currency_ars_official
|
||||
import torch.composeapp.generated.resources.currency_cup_fm
|
||||
import torch.composeapp.generated.resources.currency_cup_official
|
||||
import torch.composeapp.generated.resources.currency_lbp_bm
|
||||
import torch.composeapp.generated.resources.currency_lbp_official
|
||||
import mantra.composeapp.generated.resources.Res
|
||||
import mantra.composeapp.generated.resources.currency_ars_bm
|
||||
import mantra.composeapp.generated.resources.currency_ars_official
|
||||
import mantra.composeapp.generated.resources.currency_cup_fm
|
||||
import mantra.composeapp.generated.resources.currency_cup_official
|
||||
import mantra.composeapp.generated.resources.currency_lbp_bm
|
||||
import mantra.composeapp.generated.resources.currency_lbp_official
|
||||
|
||||
|
||||
sealed interface CurrencyUnit {
|
||||
|
||||
@@ -18,14 +18,14 @@ import fr.acinq.phoenix.data.lnurl.LnurlPay
|
||||
import fr.acinq.phoenix.utils.converters.AmountFormatter.toPrettyString
|
||||
import fr.acinq.phoenix.utils.extensions.desc
|
||||
import org.jetbrains.compose.resources.stringResource
|
||||
import torch.composeapp.generated.resources.Res
|
||||
import torch.composeapp.generated.resources.paymentdetails_desc_closing_channel
|
||||
import torch.composeapp.generated.resources.paymentdetails_desc_cpfp
|
||||
import torch.composeapp.generated.resources.paymentdetails_desc_liquidity_automated
|
||||
import torch.composeapp.generated.resources.paymentdetails_desc_liquidity_manual
|
||||
import torch.composeapp.generated.resources.paymentdetails_desc_splice_out
|
||||
import torch.composeapp.generated.resources.paymentdetails_desc_swapin
|
||||
import torch.composeapp.generated.resources.paymentdetails_desc_swapout
|
||||
import mantra.composeapp.generated.resources.Res
|
||||
import mantra.composeapp.generated.resources.paymentdetails_desc_closing_channel
|
||||
import mantra.composeapp.generated.resources.paymentdetails_desc_cpfp
|
||||
import mantra.composeapp.generated.resources.paymentdetails_desc_liquidity_automated
|
||||
import mantra.composeapp.generated.resources.paymentdetails_desc_liquidity_manual
|
||||
import mantra.composeapp.generated.resources.paymentdetails_desc_splice_out
|
||||
import mantra.composeapp.generated.resources.paymentdetails_desc_swapin
|
||||
import mantra.composeapp.generated.resources.paymentdetails_desc_swapout
|
||||
|
||||
/**
|
||||
* Represents a payment & its associated metadata.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package at.torch.compose
|
||||
package press.mantra.compose
|
||||
|
||||
expect object AppVersion {
|
||||
val versionName: String
|
||||
@@ -1,26 +1,26 @@
|
||||
package at.torch.compose
|
||||
package press.mantra.compose
|
||||
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.navigation.NavHostController
|
||||
import at.torch.compose.ui.composable.navigation.TorchNavHost
|
||||
import at.torch.compose.ui.theme.TorchTheme
|
||||
import press.mantra.compose.ui.composable.navigation.MantraNavHost
|
||||
import press.mantra.compose.ui.theme.TorchTheme
|
||||
import fr.acinq.phoenix.PhoenixGlobal
|
||||
|
||||
@Composable
|
||||
fun TorchApp(
|
||||
fun MantraApp(
|
||||
navController: NavHostController,
|
||||
torchGlobal: TorchGlobal,
|
||||
mantraGlobal: MantraGlobal,
|
||||
phoenixGlobal: PhoenixGlobal
|
||||
) {
|
||||
TorchTheme {
|
||||
Surface(
|
||||
modifier = Modifier.fillMaxSize()
|
||||
) {
|
||||
TorchNavHost(
|
||||
torchGlobal = torchGlobal,
|
||||
MantraNavHost(
|
||||
mantraGlobal = mantraGlobal,
|
||||
phoenixGlobal = phoenixGlobal,
|
||||
navController = navController
|
||||
)
|
||||
@@ -0,0 +1,5 @@
|
||||
package press.mantra.compose
|
||||
|
||||
class MantraGlobal(
|
||||
val platformContext: PlatformContext
|
||||
)
|
||||
@@ -0,0 +1,7 @@
|
||||
package press.mantra.compose
|
||||
|
||||
interface Platform {
|
||||
val name: String
|
||||
}
|
||||
|
||||
expect fun getPlatform(): Platform
|
||||
@@ -0,0 +1,3 @@
|
||||
package press.mantra.compose
|
||||
|
||||
expect class PlatformContext
|
||||
@@ -1,6 +1,6 @@
|
||||
package at.torch.compose.cryptography
|
||||
package press.mantra.compose.cryptography
|
||||
|
||||
import at.torch.compose.database.model.NostrEvent
|
||||
import press.mantra.compose.database.model.NostrEvent
|
||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||
import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair
|
||||
import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerSync
|
||||
@@ -8,12 +8,12 @@ import com.vitorpamplona.quartz.nip19Bech32.bech32.Bech32
|
||||
import com.vitorpamplona.quartz.nip51Lists.encryption.PrivateTagsInContent
|
||||
import kotlin.time.Instant
|
||||
|
||||
fun at.torch.compose.database.model.UnsignedNostrEvent.signOrThrow(nsec: String): NostrEvent {
|
||||
fun press.mantra.compose.database.model.UnsignedNostrEvent.signOrThrow(nsec: String): NostrEvent {
|
||||
val hexPrivateKey = Bech32.decodeBytes(nsec).second
|
||||
return this.signOrThrow(hexPrivateKey)
|
||||
}
|
||||
|
||||
fun at.torch.compose.database.model.UnsignedNostrEvent.signOrThrow(hexPrivateKey: ByteArray): NostrEvent {
|
||||
fun press.mantra.compose.database.model.UnsignedNostrEvent.signOrThrow(hexPrivateKey: ByteArray): NostrEvent {
|
||||
val tempSigner = NostrSignerSync(
|
||||
KeyPair(
|
||||
privKey = hexPrivateKey
|
||||
@@ -0,0 +1,209 @@
|
||||
package press.mantra.compose.database
|
||||
|
||||
import androidx.room3.Database
|
||||
import androidx.room3.RoomDatabase
|
||||
import androidx.room3.TypeConverters
|
||||
import androidx.room3.immediateTransaction
|
||||
import androidx.room3.useWriterConnection
|
||||
import press.mantra.compose.database.converters.TorchConverters
|
||||
import press.mantra.compose.database.dao.BroadcastNostrEventReceiptDao
|
||||
import press.mantra.compose.database.dao.BroadcastNostrEventRequestDao
|
||||
import press.mantra.compose.database.dao.ChatMessageBroadcastNostrEventReceiptRelationDao
|
||||
import press.mantra.compose.database.dao.ChatMessageBroadcastNostrEventRequestRelationDao
|
||||
import press.mantra.compose.database.dao.ChatMessageDao
|
||||
import press.mantra.compose.database.dao.ChatMessageNostrEventRelationDao
|
||||
import press.mantra.compose.database.dao.ChatRoomDao
|
||||
import press.mantra.compose.database.dao.ConnectionDao
|
||||
import press.mantra.compose.database.dao.GiftWrapMessageDao
|
||||
import press.mantra.compose.database.dao.GiftWrapPayloadDao
|
||||
import press.mantra.compose.database.dao.GiftWrapSealDao
|
||||
import press.mantra.compose.database.dao.InReplyToRelationDao
|
||||
import press.mantra.compose.database.dao.MarmotCommitResultDao
|
||||
import press.mantra.compose.database.dao.MarmotOutboundDao
|
||||
import press.mantra.compose.database.dao.MarmotGroupEventDao
|
||||
import press.mantra.compose.database.dao.MarmotInnerEventDao
|
||||
import press.mantra.compose.database.dao.MarmotKeyPackageBundleDao
|
||||
import press.mantra.compose.database.dao.MarmotKeyPackageDao
|
||||
import press.mantra.compose.database.dao.MarmotRetainedEpochSecretDao
|
||||
import press.mantra.compose.database.dao.MentionDao
|
||||
import press.mantra.compose.database.dao.NegentropySynchronizeRequestDao
|
||||
import press.mantra.compose.database.dao.NegentropySynchronizeResultDao
|
||||
import press.mantra.compose.database.dao.NostrDao
|
||||
import press.mantra.compose.database.dao.NostrEventDao
|
||||
import press.mantra.compose.database.dao.NostrEventRelayDao
|
||||
import press.mantra.compose.database.dao.NostrNip17Dao
|
||||
import press.mantra.compose.database.dao.ParticipantDao
|
||||
import press.mantra.compose.database.dao.PostDao
|
||||
import press.mantra.compose.database.dao.ProfileDao
|
||||
import press.mantra.compose.database.dao.QuotedRelationDao
|
||||
import press.mantra.compose.database.dao.ReactionDao
|
||||
import press.mantra.compose.database.dao.RecentSearchDao
|
||||
import press.mantra.compose.database.dao.RelayDao
|
||||
import press.mantra.compose.database.dao.RepostedRelationDao
|
||||
import press.mantra.compose.database.dao.SynchronizeNostrEventRequestDao
|
||||
import press.mantra.compose.database.dao.SynchronizeNostrEventResultDao
|
||||
import press.mantra.compose.database.dao.UnsignedNostrEventDao
|
||||
import press.mantra.compose.database.dao.ZapDao
|
||||
import press.mantra.compose.database.model.BroadcastNostrEventReceipt
|
||||
import press.mantra.compose.database.model.BroadcastNostrEventRequest
|
||||
import press.mantra.compose.database.model.ChatMessage
|
||||
import press.mantra.compose.database.model.ChatMessageBroadcastNostrEventReceiptRelation
|
||||
import press.mantra.compose.database.model.ChatMessageBroadcastNostrEventRequestRelation
|
||||
import press.mantra.compose.database.model.ChatMessageNostrEventRelation
|
||||
import press.mantra.compose.database.model.ChatRoom
|
||||
import press.mantra.compose.database.model.Connection
|
||||
import press.mantra.compose.database.model.GiftWrapMessage
|
||||
import press.mantra.compose.database.model.GiftWrapPayload
|
||||
import press.mantra.compose.database.model.GiftWrapSeal
|
||||
import press.mantra.compose.database.model.InReplyToRelation
|
||||
import press.mantra.compose.database.model.MarmotCommitResult
|
||||
import press.mantra.compose.database.model.MarmotGroupEvent
|
||||
import press.mantra.compose.database.model.MarmotInnerEvent
|
||||
import press.mantra.compose.database.model.MarmotKeyPackage
|
||||
import press.mantra.compose.database.model.MarmotKeyPackageBundle
|
||||
import press.mantra.compose.database.model.MarmotRetainedEpochSecret
|
||||
import press.mantra.compose.database.model.Mention
|
||||
import press.mantra.compose.database.model.NegentropySynchronizeRequest
|
||||
import press.mantra.compose.database.model.NegentropySynchronizeResult
|
||||
import press.mantra.compose.database.model.NostrEvent
|
||||
import press.mantra.compose.database.model.NostrEventRelay
|
||||
import press.mantra.compose.database.model.Participant
|
||||
import press.mantra.compose.database.model.Post
|
||||
import press.mantra.compose.database.model.Profile
|
||||
import press.mantra.compose.database.model.QuotedRelation
|
||||
import press.mantra.compose.database.model.Reaction
|
||||
import press.mantra.compose.database.model.RecentSearch
|
||||
import press.mantra.compose.database.model.Relay
|
||||
import press.mantra.compose.database.model.RepostedRelation
|
||||
import press.mantra.compose.database.model.SynchronizeNostrEventRequest
|
||||
import press.mantra.compose.database.model.SynchronizeNostrEventResult
|
||||
import press.mantra.compose.database.model.UnsignedNostrEvent
|
||||
import press.mantra.compose.database.model.Zap
|
||||
import kotlin.time.Instant
|
||||
|
||||
val GENESIS_AT = Instant.fromEpochMilliseconds(1231006505000L)
|
||||
|
||||
@Database(
|
||||
entities = [
|
||||
BroadcastNostrEventReceipt::class,
|
||||
BroadcastNostrEventRequest::class,
|
||||
Connection::class,
|
||||
ChatMessage::class,
|
||||
ChatMessageBroadcastNostrEventRequestRelation::class,
|
||||
ChatMessageBroadcastNostrEventReceiptRelation::class,
|
||||
ChatMessageNostrEventRelation::class,
|
||||
ChatRoom::class,
|
||||
GiftWrapMessage::class,
|
||||
GiftWrapSeal::class,
|
||||
GiftWrapPayload::class,
|
||||
InReplyToRelation::class,
|
||||
MarmotCommitResult::class,
|
||||
MarmotGroupEvent::class,
|
||||
MarmotInnerEvent::class,
|
||||
MarmotKeyPackage::class,
|
||||
MarmotKeyPackageBundle::class,
|
||||
MarmotRetainedEpochSecret::class,
|
||||
Mention::class,
|
||||
NegentropySynchronizeRequest::class,
|
||||
NegentropySynchronizeResult::class,
|
||||
NostrEvent::class,
|
||||
NostrEventRelay::class,
|
||||
Participant::class,
|
||||
Post::class,
|
||||
Profile::class,
|
||||
QuotedRelation::class,
|
||||
Reaction::class,
|
||||
RecentSearch::class,
|
||||
Relay::class,
|
||||
RepostedRelation::class,
|
||||
SynchronizeNostrEventRequest::class,
|
||||
SynchronizeNostrEventResult::class,
|
||||
UnsignedNostrEvent::class,
|
||||
Zap::class
|
||||
],
|
||||
version = 1
|
||||
)
|
||||
@TypeConverters(TorchConverters::class)
|
||||
abstract class TorchDatabase: RoomDatabase() {
|
||||
abstract fun broadcastNostrEventReceiptDao(): BroadcastNostrEventReceiptDao
|
||||
abstract fun broadcastNostrEventRequestDao(): BroadcastNostrEventRequestDao
|
||||
|
||||
abstract fun chatMessageDao(): ChatMessageDao
|
||||
|
||||
abstract fun chatMessageBroadcastNostrEventRequestRelationDao(): ChatMessageBroadcastNostrEventRequestRelationDao
|
||||
|
||||
abstract fun chatMessageBroadcastNostrEventReceiptRelationDao(): ChatMessageBroadcastNostrEventReceiptRelationDao
|
||||
|
||||
abstract fun chatMessageNostrEventRelationDao(): ChatMessageNostrEventRelationDao
|
||||
|
||||
abstract fun chatRoomDao(): ChatRoomDao
|
||||
|
||||
abstract fun connectionDao(): ConnectionDao
|
||||
|
||||
abstract fun giftWrapMessageDao(): GiftWrapMessageDao
|
||||
|
||||
abstract fun giftWrapSealDao(): GiftWrapSealDao
|
||||
|
||||
abstract fun giftWrapPayloadDao(): GiftWrapPayloadDao
|
||||
|
||||
abstract fun inReplyToRelationDao(): InReplyToRelationDao
|
||||
|
||||
abstract fun marmotCommitResultDao(): MarmotCommitResultDao
|
||||
|
||||
abstract fun marmotGroupEventDao(): MarmotGroupEventDao
|
||||
|
||||
abstract fun marmotInnerEventDao(): MarmotInnerEventDao
|
||||
|
||||
abstract fun marmotKeyPackageBundleDao(): MarmotKeyPackageBundleDao
|
||||
|
||||
abstract fun marmotKeyPackageDao(): MarmotKeyPackageDao
|
||||
|
||||
abstract fun marmotOutboundDao(): MarmotOutboundDao
|
||||
|
||||
abstract fun marmotRetainedEpochSecretDao(): MarmotRetainedEpochSecretDao
|
||||
|
||||
abstract fun mentionDao(): MentionDao
|
||||
|
||||
abstract fun negentropySynchronizeRequestDao(): NegentropySynchronizeRequestDao
|
||||
|
||||
abstract fun negentropySynchronizeResultDao(): NegentropySynchronizeResultDao
|
||||
|
||||
abstract fun nostrDao(): NostrDao
|
||||
|
||||
abstract fun nostrEventDao(): NostrEventDao
|
||||
|
||||
abstract fun nostrEventRelayDao(): NostrEventRelayDao
|
||||
|
||||
abstract fun nostrNip17Dao(): NostrNip17Dao
|
||||
|
||||
abstract fun participantDao(): ParticipantDao
|
||||
|
||||
abstract fun postDao(): PostDao
|
||||
|
||||
abstract fun profileDao(): ProfileDao
|
||||
|
||||
abstract fun quotedRelationDao(): QuotedRelationDao
|
||||
|
||||
abstract fun reactionDao(): ReactionDao
|
||||
|
||||
abstract fun recentSearchDao(): RecentSearchDao
|
||||
|
||||
abstract fun relayDao(): RelayDao
|
||||
|
||||
abstract fun repostedRelationDao(): RepostedRelationDao
|
||||
|
||||
abstract fun synchronizeNostrEventRequestDao(): SynchronizeNostrEventRequestDao
|
||||
|
||||
abstract fun synchronizeNostrEventResultDao(): SynchronizeNostrEventResultDao
|
||||
|
||||
abstract fun unsignedNostrEventDao(): UnsignedNostrEventDao
|
||||
abstract fun zapDao(): ZapDao
|
||||
|
||||
suspend fun wipeData() {
|
||||
useWriterConnection { transactor ->
|
||||
transactor.immediateTransaction {
|
||||
// TODO: Actually delete the data...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package at.torch.compose.database
|
||||
package press.mantra.compose.database
|
||||
|
||||
import androidx.room3.RoomDatabaseConstructor
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package press.mantra.compose.database.builder
|
||||
|
||||
import androidx.room3.RoomDatabase
|
||||
import androidx.sqlite.driver.bundled.BundledSQLiteDriver
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.IO
|
||||
|
||||
expect object PlatformDatabaseBuilder {
|
||||
fun getDatabaseBuilder(platformContext: press.mantra.compose.PlatformContext): RoomDatabase.Builder<press.mantra.compose.database.TorchDatabase>
|
||||
|
||||
fun getInMemoryDatabaseBuilder(platform: press.mantra.compose.PlatformContext): RoomDatabase.Builder<press.mantra.compose.database.TorchDatabase>
|
||||
}
|
||||
|
||||
fun getRoomDatabase(
|
||||
builder: RoomDatabase.Builder<press.mantra.compose.database.TorchDatabase>
|
||||
): press.mantra.compose.database.TorchDatabase {
|
||||
return builder
|
||||
.setDriver(BundledSQLiteDriver())
|
||||
.setQueryCoroutineContext(Dispatchers.IO)
|
||||
.build()
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package at.torch.compose.database.converters
|
||||
package press.mantra.compose.database.converters
|
||||
|
||||
import androidx.room3.TypeConverter
|
||||
import at.torch.compose.database.model.types.SynchronizationFilter
|
||||
import press.mantra.compose.database.model.types.SynchronizationFilter
|
||||
import co.touchlab.kermit.Logger
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlin.time.Instant
|
||||
@@ -0,0 +1,21 @@
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Dao
|
||||
interface BroadcastNostrEventReceiptDao {
|
||||
@Query("SELECT * FROM BroadcastNostrEventReceipt")
|
||||
fun getAllBroadcastNostrEventReceipts(): List<press.mantra.compose.database.model.BroadcastNostrEventReceipt>
|
||||
|
||||
@Query("SELECT * FROM BroadcastNostrEventReceipt WHERE id = :id")
|
||||
fun getBroadcastNostrEventReceiptById(id: Long): Flow<press.mantra.compose.database.model.BroadcastNostrEventReceipt?>
|
||||
|
||||
@Query("SELECT * FROM BroadcastNostrEventReceipt WHERE nostrEventId = :nostrEventId")
|
||||
fun getBroadcastNostrEventReceiptByNostrEventId(nostrEventId: String): Flow<press.mantra.compose.database.model.BroadcastNostrEventReceipt?>
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(broadcastNostrEventReceipt: press.mantra.compose.database.model.BroadcastNostrEventReceipt): Long
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package at.torch.compose.database.dao
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Insert
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
import at.torch.compose.database.model.BroadcastNostrEventRequest
|
||||
import at.torch.compose.database.model.intermdiate.LocalBroadcastNostrEventRequest
|
||||
import press.mantra.compose.database.model.BroadcastNostrEventRequest
|
||||
import press.mantra.compose.database.model.intermdiate.LocalBroadcastNostrEventRequest
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlin.time.Clock
|
||||
import kotlin.time.Instant
|
||||
@@ -1,4 +1,4 @@
|
||||
package at.torch.compose.database.dao
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Upsert
|
||||
@@ -6,5 +6,5 @@ import androidx.room3.Upsert
|
||||
@Dao
|
||||
interface ChatMessageBroadcastNostrEventReceiptRelationDao {
|
||||
@Upsert
|
||||
suspend fun upsert(chatMessageBroadcastNostrEventReceiptRelation: at.torch.compose.database.model.ChatMessageBroadcastNostrEventReceiptRelation)
|
||||
suspend fun upsert(chatMessageBroadcastNostrEventReceiptRelation: press.mantra.compose.database.model.ChatMessageBroadcastNostrEventReceiptRelation)
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package at.torch.compose.database.dao
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
import at.torch.compose.database.model.ChatMessageBroadcastNostrEventRequestRelation
|
||||
import press.mantra.compose.database.model.ChatMessageBroadcastNostrEventRequestRelation
|
||||
|
||||
@Dao
|
||||
interface ChatMessageBroadcastNostrEventRequestRelationDao {
|
||||
@@ -1,10 +1,10 @@
|
||||
package at.torch.compose.database.dao
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Transaction
|
||||
import androidx.room3.Upsert
|
||||
import at.torch.compose.database.model.ChatMessage
|
||||
import press.mantra.compose.database.model.ChatMessage
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@@ -12,11 +12,11 @@ import kotlinx.coroutines.flow.Flow
|
||||
interface ChatMessageDao {
|
||||
@Transaction
|
||||
@Query("SELECT * FROM ChatMessage WHERE chatRoomId = :chatRoomId ORDER BY createdAt DESC")
|
||||
fun observeChatMessagesByChatRoomId(chatRoomId: String): Flow<List<at.torch.compose.database.model.intermdiate.LocalChatMessage>>
|
||||
fun observeChatMessagesByChatRoomId(chatRoomId: String): Flow<List<press.mantra.compose.database.model.intermdiate.LocalChatMessage>>
|
||||
|
||||
@Transaction
|
||||
@Query("SELECT * FROM ChatMessage WHERE chatRoomId = :chatRoomId ORDER BY createdAt DESC")
|
||||
fun getChatMessagesByChatRoomId(chatRoomId: String): List<at.torch.compose.database.model.intermdiate.LocalChatMessage>
|
||||
fun getChatMessagesByChatRoomId(chatRoomId: String): List<press.mantra.compose.database.model.intermdiate.LocalChatMessage>
|
||||
|
||||
@Query("SELECT * FROM ChatMessage WHERE giftWrapPayloadId = :giftWrapPayloadId ORDER BY createdAt DESC")
|
||||
fun getChatMessagesByGiftWrapPayloadId(giftWrapPayloadId: HexKey): ChatMessage?
|
||||
@@ -31,5 +31,5 @@ interface ChatMessageDao {
|
||||
fun countChatMessagesBySenderPublicKey(chatRoomId: HexKey, senderPublicKey: HexKey): Int
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(chatMessage: at.torch.compose.database.model.ChatMessage): Long
|
||||
suspend fun upsert(chatMessage: press.mantra.compose.database.model.ChatMessage): Long
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Upsert
|
||||
|
||||
@Dao
|
||||
interface ChatMessageNostrEventRelationDao {
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(chatMessageNostrEventRelation: press.mantra.compose.database.model.ChatMessageNostrEventRelation)
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package at.torch.compose.database.dao
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Delete
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Transaction
|
||||
import androidx.room3.Upsert
|
||||
import at.torch.compose.database.model.ChatRoom
|
||||
import at.torch.compose.database.model.intermdiate.LocalChatRoom
|
||||
import press.mantra.compose.database.model.ChatRoom
|
||||
import press.mantra.compose.database.model.intermdiate.LocalChatRoom
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Dao
|
||||
@@ -1,4 +1,4 @@
|
||||
package at.torch.compose.database.dao
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Delete
|
||||
@@ -11,19 +11,19 @@ import kotlinx.coroutines.flow.Flow
|
||||
@Dao
|
||||
interface ConnectionDao {
|
||||
@Query("SELECT * FROM Connection LIMIT :limit")
|
||||
fun getAllConnections(limit: Int = 21): List<at.torch.compose.database.model.Connection>
|
||||
fun getAllConnections(limit: Int = 21): List<press.mantra.compose.database.model.Connection>
|
||||
|
||||
|
||||
@Query("SELECT * FROM Connection WHERE (sourcePublicKey = :alicePublicKey AND destinationPublicKey = :bobPublicKey) OR (sourcePublicKey = :bobPublicKey AND destinationPublicKey = :alicePublicKey)")
|
||||
fun observeRelation(alicePublicKey: HexKey, bobPublicKey: HexKey): Flow<List<at.torch.compose.database.model.Connection>>
|
||||
fun observeRelation(alicePublicKey: HexKey, bobPublicKey: HexKey): Flow<List<press.mantra.compose.database.model.Connection>>
|
||||
|
||||
@Insert
|
||||
suspend fun insertPlaceholderProfile(connection: at.torch.compose.database.model.Connection)
|
||||
suspend fun insertPlaceholderProfile(connection: press.mantra.compose.database.model.Connection)
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(connection: at.torch.compose.database.model.Connection)
|
||||
suspend fun upsert(connection: press.mantra.compose.database.model.Connection)
|
||||
|
||||
@Delete
|
||||
suspend fun delete(connection: at.torch.compose.database.model.Connection)
|
||||
suspend fun delete(connection: press.mantra.compose.database.model.Connection)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
|
||||
@Dao
|
||||
interface GiftWrapMessageDao {
|
||||
@Query("SELECT * FROM GiftWrapMessage")
|
||||
fun getAllGiftWrapMessages(): List<press.mantra.compose.database.model.GiftWrapMessage>
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(giftWrapMessage: press.mantra.compose.database.model.GiftWrapMessage)
|
||||
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package at.torch.compose.database.dao
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Insert
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
import at.torch.compose.database.model.GiftWrapPayload
|
||||
import press.mantra.compose.database.model.GiftWrapPayload
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Dao
|
||||
@@ -0,0 +1,15 @@
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
|
||||
@Dao
|
||||
interface GiftWrapSealDao {
|
||||
@Query("SELECT * FROM GiftWrapSeal")
|
||||
fun getAllGiftWrapSeals(): List<press.mantra.compose.database.model.GiftWrapSeal>
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(giftWrapSeal: press.mantra.compose.database.model.GiftWrapSeal)
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package at.torch.compose.database.dao
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Insert
|
||||
@@ -8,14 +8,14 @@ import androidx.room3.Upsert
|
||||
@Dao
|
||||
interface InReplyToRelationDao {
|
||||
@Query("SELECT * FROM InReplyToRelation WHERE replyingNostrEventId = :replyingNostrEventId")
|
||||
fun getRepostByReplyingNostrEventId(replyingNostrEventId: String): at.torch.compose.database.model.InReplyToRelation?
|
||||
fun getRepostByReplyingNostrEventId(replyingNostrEventId: String): press.mantra.compose.database.model.InReplyToRelation?
|
||||
|
||||
@Query("SELECT * FROM InReplyToRelation WHERE inReplyToNostrEventId = :inReplyToNostrEventId")
|
||||
fun getRepostByInReplyToNostrEventId(inReplyToNostrEventId: String): at.torch.compose.database.model.InReplyToRelation?
|
||||
fun getRepostByInReplyToNostrEventId(inReplyToNostrEventId: String): press.mantra.compose.database.model.InReplyToRelation?
|
||||
|
||||
@Insert
|
||||
suspend fun insert(inReplyToRelation: at.torch.compose.database.model.InReplyToRelation)
|
||||
suspend fun insert(inReplyToRelation: press.mantra.compose.database.model.InReplyToRelation)
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(inReplyToRelation: at.torch.compose.database.model.InReplyToRelation)
|
||||
suspend fun upsert(inReplyToRelation: press.mantra.compose.database.model.InReplyToRelation)
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
package at.torch.compose.database.dao
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
import at.torch.compose.database.model.MarmotCommitResult
|
||||
import at.torch.compose.database.model.MarmotKeyPackage
|
||||
import press.mantra.compose.database.model.MarmotCommitResult
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import fr.acinq.bitcoin.PublicKey
|
||||
|
||||
@Dao
|
||||
interface MarmotCommitResultDao {
|
||||
@@ -0,0 +1,12 @@
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Upsert
|
||||
import press.mantra.compose.database.model.MarmotGroupEvent
|
||||
|
||||
@Dao
|
||||
interface MarmotGroupEventDao {
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(marmotGroupEvent: MarmotGroupEvent)
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package at.torch.compose.database.dao
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
import at.torch.compose.database.model.MarmotInnerEvent
|
||||
import press.mantra.compose.database.model.MarmotInnerEvent
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Dao
|
||||
@@ -1,9 +1,9 @@
|
||||
package at.torch.compose.database.dao
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
import at.torch.compose.database.model.MarmotKeyPackageBundle
|
||||
import press.mantra.compose.database.model.MarmotKeyPackageBundle
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package at.torch.compose.database.dao
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
import at.torch.compose.database.model.MarmotKeyPackage
|
||||
import press.mantra.compose.database.model.MarmotKeyPackage
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import fr.acinq.bitcoin.PublicKey
|
||||
|
||||
@Dao
|
||||
interface MarmotKeyPackageDao {
|
||||
@@ -1,27 +1,27 @@
|
||||
package at.torch.compose.database.dao
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Transaction
|
||||
import at.torch.compose.database.TorchDatabase
|
||||
import at.torch.compose.database.model.BroadcastNostrEventRequest
|
||||
import at.torch.compose.database.model.ChatMessage
|
||||
import at.torch.compose.database.model.ChatMessageBroadcastNostrEventRequestRelation
|
||||
import at.torch.compose.database.model.ChatMessageNostrEventRelation
|
||||
import at.torch.compose.database.model.ChatRoom
|
||||
import at.torch.compose.database.model.GiftWrapPayload
|
||||
import at.torch.compose.database.model.MarmotCommitResult
|
||||
import at.torch.compose.database.model.MarmotGroupEvent
|
||||
import at.torch.compose.database.model.MarmotInnerEvent
|
||||
import at.torch.compose.database.model.MarmotInnerEvent.Companion.disappearingExpiration
|
||||
import at.torch.compose.database.model.MarmotKeyPackage
|
||||
import at.torch.compose.database.model.MarmotRetainedEpochSecret
|
||||
import at.torch.compose.database.model.NostrEvent
|
||||
import at.torch.compose.database.model.Participant
|
||||
import at.torch.compose.database.model.intermdiate.LocalChatRoom
|
||||
import at.torch.compose.extensions.exporterSecret
|
||||
import at.torch.compose.extensions.toHex
|
||||
import at.torch.compose.managers.MarmotInboundManager.EPOCH_RETENTION_WINDOW
|
||||
import at.torch.compose.nostr.Relays
|
||||
import press.mantra.compose.database.TorchDatabase
|
||||
import press.mantra.compose.database.model.BroadcastNostrEventRequest
|
||||
import press.mantra.compose.database.model.ChatMessage
|
||||
import press.mantra.compose.database.model.ChatMessageBroadcastNostrEventRequestRelation
|
||||
import press.mantra.compose.database.model.ChatMessageNostrEventRelation
|
||||
import press.mantra.compose.database.model.ChatRoom
|
||||
import press.mantra.compose.database.model.GiftWrapPayload
|
||||
import press.mantra.compose.database.model.MarmotCommitResult
|
||||
import press.mantra.compose.database.model.MarmotGroupEvent
|
||||
import press.mantra.compose.database.model.MarmotInnerEvent
|
||||
import press.mantra.compose.database.model.MarmotInnerEvent.Companion.disappearingExpiration
|
||||
import press.mantra.compose.database.model.MarmotKeyPackage
|
||||
import press.mantra.compose.database.model.MarmotRetainedEpochSecret
|
||||
import press.mantra.compose.database.model.NostrEvent
|
||||
import press.mantra.compose.database.model.Participant
|
||||
import press.mantra.compose.database.model.intermdiate.LocalChatRoom
|
||||
import press.mantra.compose.extensions.exporterSecret
|
||||
import press.mantra.compose.extensions.toHex
|
||||
import press.mantra.compose.managers.MarmotInboundManager.EPOCH_RETENTION_WINDOW
|
||||
import press.mantra.compose.nostr.Relays
|
||||
import co.touchlab.kermit.Logger
|
||||
import com.vitorpamplona.quartz.marmot.mip00KeyPackages.tags.EncodingTag
|
||||
import com.vitorpamplona.quartz.marmot.mip01Groups.MarmotGroupData
|
||||
@@ -1,11 +1,11 @@
|
||||
package at.torch.compose.database.dao
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Delete
|
||||
import androidx.room3.Insert
|
||||
import androidx.room3.OnConflictStrategy.Companion.IGNORE
|
||||
import androidx.room3.Query
|
||||
import at.torch.compose.database.model.MarmotRetainedEpochSecret
|
||||
import press.mantra.compose.database.model.MarmotRetainedEpochSecret
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
|
||||
@Dao
|
||||
@@ -1,4 +1,4 @@
|
||||
package at.torch.compose.database.dao
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Insert
|
||||
@@ -11,8 +11,8 @@ interface MentionDao {
|
||||
@Insert(
|
||||
onConflict = IGNORE
|
||||
)
|
||||
suspend fun insert(mention: at.torch.compose.database.model.Mention)
|
||||
suspend fun insert(mention: press.mantra.compose.database.model.Mention)
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(mention: at.torch.compose.database.model.Mention)
|
||||
suspend fun upsert(mention: press.mantra.compose.database.model.Mention)
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package at.torch.compose.database.dao
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Insert
|
||||
import androidx.room3.OnConflictStrategy.Companion.IGNORE
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
import at.torch.compose.database.model.NegentropySynchronizeRequest
|
||||
import press.mantra.compose.database.model.NegentropySynchronizeRequest
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlin.time.Clock
|
||||
import kotlin.time.Instant
|
||||
@@ -0,0 +1,10 @@
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Upsert
|
||||
|
||||
@Dao
|
||||
interface NegentropySynchronizeResultDao {
|
||||
@Upsert
|
||||
fun upsert(negentropySynchronizeResult: press.mantra.compose.database.model.NegentropySynchronizeResult)
|
||||
}
|
||||
@@ -1,34 +1,33 @@
|
||||
package at.torch.compose.database.dao
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.compose.runtime.key
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Transaction
|
||||
import at.torch.compose.database.GENESIS_AT
|
||||
import at.torch.compose.database.model.BroadcastNostrEventRequest
|
||||
import at.torch.compose.database.model.ChatMessage
|
||||
import at.torch.compose.database.model.ChatMessageBroadcastNostrEventRequestRelation
|
||||
import at.torch.compose.database.model.ChatRoom
|
||||
import at.torch.compose.database.model.Connection
|
||||
import at.torch.compose.database.model.MarmotGroupEvent
|
||||
import at.torch.compose.database.model.MarmotKeyPackage
|
||||
import at.torch.compose.database.model.Mention
|
||||
import at.torch.compose.database.model.NegentropySynchronizeRequest
|
||||
import at.torch.compose.database.model.NostrEvent
|
||||
import at.torch.compose.database.model.NostrEventRelay
|
||||
import at.torch.compose.database.model.Participant
|
||||
import at.torch.compose.database.model.Post
|
||||
import at.torch.compose.database.model.Profile
|
||||
import at.torch.compose.database.model.types.SynchronizationFilter
|
||||
import at.torch.compose.exceptions.GiftWrapImpersonationException
|
||||
import at.torch.compose.exceptions.GiftWrapSealDecryptionException
|
||||
import at.torch.compose.exceptions.GiftWrapUnsealException
|
||||
import at.torch.compose.exceptions.MarmotMissingChatGroupException
|
||||
import at.torch.compose.exceptions.MarmotMissingKeyPackageBundleException
|
||||
import at.torch.compose.exceptions.MarmotMissingNostrGroupDataExtension
|
||||
import at.torch.compose.exceptions.MarmotNotMemberOfChatGroupException
|
||||
import at.torch.compose.exceptions.MarmotWelcomeEventMissingKeyPackageEventIdException
|
||||
import at.torch.compose.extensions.toHex
|
||||
import at.torch.compose.managers.MarmotInboundManager
|
||||
import press.mantra.compose.database.GENESIS_AT
|
||||
import press.mantra.compose.database.model.BroadcastNostrEventRequest
|
||||
import press.mantra.compose.database.model.ChatMessage
|
||||
import press.mantra.compose.database.model.ChatMessageBroadcastNostrEventRequestRelation
|
||||
import press.mantra.compose.database.model.ChatRoom
|
||||
import press.mantra.compose.database.model.Connection
|
||||
import press.mantra.compose.database.model.MarmotGroupEvent
|
||||
import press.mantra.compose.database.model.MarmotKeyPackage
|
||||
import press.mantra.compose.database.model.Mention
|
||||
import press.mantra.compose.database.model.NegentropySynchronizeRequest
|
||||
import press.mantra.compose.database.model.NostrEvent
|
||||
import press.mantra.compose.database.model.NostrEventRelay
|
||||
import press.mantra.compose.database.model.Participant
|
||||
import press.mantra.compose.database.model.Post
|
||||
import press.mantra.compose.database.model.Profile
|
||||
import press.mantra.compose.database.model.types.SynchronizationFilter
|
||||
import press.mantra.compose.exceptions.GiftWrapImpersonationException
|
||||
import press.mantra.compose.exceptions.GiftWrapSealDecryptionException
|
||||
import press.mantra.compose.exceptions.GiftWrapUnsealException
|
||||
import press.mantra.compose.exceptions.MarmotMissingChatGroupException
|
||||
import press.mantra.compose.exceptions.MarmotMissingKeyPackageBundleException
|
||||
import press.mantra.compose.exceptions.MarmotMissingNostrGroupDataExtension
|
||||
import press.mantra.compose.exceptions.MarmotNotMemberOfChatGroupException
|
||||
import press.mantra.compose.exceptions.MarmotWelcomeEventMissingKeyPackageEventIdException
|
||||
import press.mantra.compose.extensions.toHex
|
||||
import press.mantra.compose.managers.MarmotInboundManager
|
||||
import co.touchlab.kermit.Logger
|
||||
import com.vitorpamplona.quartz.marmot.GroupEventResult
|
||||
import com.vitorpamplona.quartz.marmot.mip00KeyPackages.KeyPackageEvent
|
||||
@@ -44,7 +43,6 @@ import com.vitorpamplona.quartz.nip01Core.core.toHexKey
|
||||
import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair
|
||||
import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent
|
||||
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
|
||||
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.normalizedUrls
|
||||
import com.vitorpamplona.quartz.nip01Core.tags.events.taggedEvents
|
||||
import com.vitorpamplona.quartz.nip01Core.tags.people.taggedUsers
|
||||
import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent
|
||||
@@ -53,13 +51,12 @@ import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent
|
||||
import com.vitorpamplona.quartz.nip40Expiration.expiration
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent
|
||||
import kotlin.io.encoding.Base64
|
||||
import kotlin.math.log
|
||||
import kotlin.time.Clock
|
||||
import kotlin.time.Instant
|
||||
|
||||
@Dao
|
||||
abstract class NostrDao(
|
||||
private val database: at.torch.compose.database.TorchDatabase,
|
||||
private val database: press.mantra.compose.database.TorchDatabase,
|
||||
) {
|
||||
val logger = Logger.withTag("NostrDao")
|
||||
|
||||
@@ -78,7 +75,7 @@ abstract class NostrDao(
|
||||
|
||||
@Transaction
|
||||
open suspend fun publishNostrEvent(
|
||||
unsignedNostrEvent: at.torch.compose.database.model.UnsignedNostrEvent,
|
||||
unsignedNostrEvent: press.mantra.compose.database.model.UnsignedNostrEvent,
|
||||
nostrEvent: NostrEvent,
|
||||
relayURLs: List<String>,
|
||||
activeKeyPair: KeyPair
|
||||
@@ -1186,7 +1183,7 @@ abstract class NostrDao(
|
||||
|
||||
/**
|
||||
* Persist the rescheduling using a transaction so that we are assured of the existence of the
|
||||
* [ChatMessageBroadcastNostrEventRequestRelation] when we produce the [at.torch.compose.database.model.BroadcastNostrEventReceipt]
|
||||
* [ChatMessageBroadcastNostrEventRequestRelation] when we produce the [press.mantra.compose.database.model.BroadcastNostrEventReceipt]
|
||||
*/
|
||||
@Transaction
|
||||
open suspend fun rescheduleBroadcastNostrEventRequests(broadcastNostrEventRequests: List<BroadcastNostrEventRequest>) {
|
||||
@@ -1,6 +1,5 @@
|
||||
package at.torch.compose.database.dao
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.compose.runtime.IntState
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Insert
|
||||
import androidx.room3.OnConflictStrategy.Companion.IGNORE
|
||||
@@ -9,8 +8,8 @@ import androidx.room3.RawQuery
|
||||
import androidx.room3.RoomRawQuery
|
||||
import androidx.room3.Transaction
|
||||
import androidx.room3.Upsert
|
||||
import at.torch.compose.database.model.MarmotGroupEvent
|
||||
import at.torch.compose.database.model.NostrEvent
|
||||
import press.mantra.compose.database.model.MarmotGroupEvent
|
||||
import press.mantra.compose.database.model.NostrEvent
|
||||
import com.vitorpamplona.quartz.marmot.mip03GroupMessages.GroupEvent
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import com.vitorpamplona.quartz.nip01Core.core.Kind
|
||||
@@ -22,35 +21,35 @@ import kotlin.time.Instant
|
||||
interface NostrEventDao {
|
||||
@Transaction
|
||||
@Query("SELECT * FROM NostrEvent WHERE kind in (:kinds) ORDER BY createdAt DESC")
|
||||
fun observeNostrEvents(kinds: Array<Kind>): Flow<List<at.torch.compose.database.model.intermdiate.LocalNostrEvent>>
|
||||
fun observeNostrEvents(kinds: Array<Kind>): Flow<List<press.mantra.compose.database.model.intermdiate.LocalNostrEvent>>
|
||||
|
||||
@Transaction
|
||||
@Query("SELECT * FROM NostrEvent WHERE content LIKE '%' || :search || '%' AND kind in (:kinds) ORDER BY createdAt DESC")
|
||||
fun observeFilteredNostrEvents(
|
||||
kinds: Array<Kind>,
|
||||
search: String
|
||||
): Flow<List<at.torch.compose.database.model.intermdiate.LocalNostrEvent>>
|
||||
): Flow<List<press.mantra.compose.database.model.intermdiate.LocalNostrEvent>>
|
||||
|
||||
@Transaction
|
||||
@Query("SELECT * FROM NostrEvent WHERE kind in (:kinds) AND id in (:ids) ORDER BY createdAt DESC")
|
||||
fun observeFilteredNostrEvents(
|
||||
kinds: Array<Kind>,
|
||||
ids: Array<HexKey>,
|
||||
): Flow<List<at.torch.compose.database.model.intermdiate.LocalNostrEvent>>
|
||||
): Flow<List<press.mantra.compose.database.model.intermdiate.LocalNostrEvent>>
|
||||
|
||||
@Transaction
|
||||
@Query("SELECT * FROM NostrEvent WHERE kind in (:kinds) AND pubKey in (:authors) ORDER BY createdAt DESC LIMIT 50")
|
||||
fun observeAuthoredNostrEvents(
|
||||
kinds: Array<Kind>,
|
||||
authors: Array<HexKey>,
|
||||
): Flow<List<at.torch.compose.database.model.intermdiate.LocalNostrEvent>>
|
||||
): Flow<List<press.mantra.compose.database.model.intermdiate.LocalNostrEvent>>
|
||||
|
||||
@Transaction
|
||||
@Query("SELECT * FROM NostrEvent WHERE tags LIKE '%' || :publicKey || '%' AND kind in (:kinds) ORDER BY createdAt DESC")
|
||||
fun observePublicKeyMentionedNostrEvents(
|
||||
kinds: Array<Kind>,
|
||||
publicKey: HexKey
|
||||
): Flow<List<at.torch.compose.database.model.intermdiate.LocalNostrEvent>>
|
||||
): Flow<List<press.mantra.compose.database.model.intermdiate.LocalNostrEvent>>
|
||||
|
||||
@Transaction
|
||||
@Query("SELECT * FROM NostrEvent WHERE tags LIKE '%' || :eventId || '%reply%' AND kind in (:kinds) AND createdAt > :since ORDER BY createdAt DESC")
|
||||
@@ -58,13 +57,13 @@ interface NostrEventDao {
|
||||
kinds: Array<Kind>,
|
||||
eventId: HexKey,
|
||||
since: Instant
|
||||
): Flow<List<at.torch.compose.database.model.intermdiate.LocalNostrEvent>>
|
||||
): Flow<List<press.mantra.compose.database.model.intermdiate.LocalNostrEvent>>
|
||||
|
||||
@Transaction
|
||||
@RawQuery
|
||||
fun observePublicKeyFollowingNostrEvents(
|
||||
query: RoomRawQuery
|
||||
): Flow<List<at.torch.compose.database.model.intermdiate.LocalNostrEvent>>
|
||||
): Flow<List<press.mantra.compose.database.model.intermdiate.LocalNostrEvent>>
|
||||
|
||||
@Transaction
|
||||
@Query("SELECT * FROM NostrEvent WHERE kind in (:kinds) AND createdAt > :since ORDER BY createdAt ASC LIMIT :limit")
|
||||
@@ -149,7 +148,7 @@ interface NostrEventDao {
|
||||
|
||||
@Transaction
|
||||
@Query("SELECT * FROM NostrEvent WHERE id = :id")
|
||||
fun observeNostrEventById(id: String): Flow<at.torch.compose.database.model.intermdiate.LocalNostrEvent?>
|
||||
fun observeNostrEventById(id: String): Flow<press.mantra.compose.database.model.intermdiate.LocalNostrEvent?>
|
||||
|
||||
@Query("SELECT * FROM NostrEvent WHERE id = :id")
|
||||
fun getNostrEventById(id: String): NostrEvent?
|
||||
@@ -0,0 +1,12 @@
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Upsert
|
||||
|
||||
@Dao
|
||||
interface NostrEventRelayDao {
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(nostrEventRelay: press.mantra.compose.database.model.NostrEventRelay)
|
||||
|
||||
}
|
||||
@@ -1,19 +1,19 @@
|
||||
package at.torch.compose.database.dao
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Transaction
|
||||
import at.torch.compose.database.GENESIS_AT
|
||||
import at.torch.compose.database.model.BroadcastNostrEventRequest
|
||||
import at.torch.compose.database.model.ChatMessageBroadcastNostrEventRequestRelation
|
||||
import at.torch.compose.database.model.ChatMessageNostrEventRelation
|
||||
import at.torch.compose.database.model.ChatRoom
|
||||
import at.torch.compose.database.model.GiftWrapMessage
|
||||
import at.torch.compose.database.model.GiftWrapPayload
|
||||
import at.torch.compose.database.model.GiftWrapSeal
|
||||
import at.torch.compose.database.model.NostrEvent
|
||||
import at.torch.compose.database.model.Participant
|
||||
import at.torch.compose.database.model.intermdiate.LocalChatRoom
|
||||
import at.torch.compose.nostr.Relays
|
||||
import press.mantra.compose.database.GENESIS_AT
|
||||
import press.mantra.compose.database.model.BroadcastNostrEventRequest
|
||||
import press.mantra.compose.database.model.ChatMessageBroadcastNostrEventRequestRelation
|
||||
import press.mantra.compose.database.model.ChatMessageNostrEventRelation
|
||||
import press.mantra.compose.database.model.ChatRoom
|
||||
import press.mantra.compose.database.model.GiftWrapMessage
|
||||
import press.mantra.compose.database.model.GiftWrapPayload
|
||||
import press.mantra.compose.database.model.GiftWrapSeal
|
||||
import press.mantra.compose.database.model.NostrEvent
|
||||
import press.mantra.compose.database.model.Participant
|
||||
import press.mantra.compose.database.model.intermdiate.LocalChatRoom
|
||||
import press.mantra.compose.nostr.Relays
|
||||
import co.touchlab.kermit.Logger
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import com.vitorpamplona.quartz.nip01Core.tags.people.PTag
|
||||
@@ -25,7 +25,7 @@ import kotlin.time.Instant
|
||||
|
||||
@Dao
|
||||
abstract class NostrNip17Dao(
|
||||
private val database: at.torch.compose.database.TorchDatabase
|
||||
private val database: press.mantra.compose.database.TorchDatabase
|
||||
) {
|
||||
val logger = Logger.withTag(TAG)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package at.torch.compose.database.dao
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Delete
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
import at.torch.compose.database.model.Participant
|
||||
import press.mantra.compose.database.model.Participant
|
||||
|
||||
@Dao
|
||||
interface ParticipantDao {
|
||||
@@ -0,0 +1,21 @@
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Insert
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
|
||||
@Dao
|
||||
interface PostDao {
|
||||
@Query("SELECT * FROM Post")
|
||||
fun getAllPosts(): List<press.mantra.compose.database.model.intermdiate.LocalPost>
|
||||
|
||||
@Query("SELECT * FROM Post WHERE id = :id")
|
||||
fun getPostById(id: String): press.mantra.compose.database.model.Post?
|
||||
|
||||
@Insert
|
||||
suspend fun insert(post: press.mantra.compose.database.model.Post)
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(post: press.mantra.compose.database.model.Post)
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package at.torch.compose.database.dao
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Insert
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
import at.torch.compose.database.GENESIS_AT
|
||||
import at.torch.compose.database.model.Profile
|
||||
import press.mantra.compose.database.GENESIS_AT
|
||||
import press.mantra.compose.database.model.Profile
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlin.time.Instant
|
||||
@@ -23,7 +23,7 @@ interface ProfileDao {
|
||||
|
||||
|
||||
@Query("SELECT * FROM NostrEvent WHERE kind = 0 AND content LIKE '%' || :searchTerm || '%' LIMIT :limit")
|
||||
fun filterProfiles(searchTerm: String, limit: Int = 21): List<at.torch.compose.database.model.intermdiate.LocalProfile>
|
||||
fun filterProfiles(searchTerm: String, limit: Int = 21): List<press.mantra.compose.database.model.intermdiate.LocalProfile>
|
||||
|
||||
@Query("SELECT * FROM Profile WHERE publicKey = :publicKey")
|
||||
fun getProfileByPublicKey(publicKey: String): Profile?
|
||||
@@ -35,10 +35,10 @@ interface ProfileDao {
|
||||
fun getProfileByPublicKeys(publicKeys: List<String>): List<Profile>
|
||||
|
||||
@Query("SELECT * FROM NostrEvent WHERE kind = 0 AND pubKey = :publicKey")
|
||||
fun observeProfileWithFollowersByPublicKey(publicKey: String): Flow<at.torch.compose.database.model.intermdiate.LocalProfileWithFollowers?>
|
||||
fun observeProfileWithFollowersByPublicKey(publicKey: String): Flow<press.mantra.compose.database.model.intermdiate.LocalProfileWithFollowers?>
|
||||
|
||||
@Query("SELECT * FROM NostrEvent WHERE kind = 0 AND pubKey = :publicKey")
|
||||
fun observeProfileWithFollowingByPublicKey(publicKey: String): Flow<at.torch.compose.database.model.intermdiate.LocalProfileWithFollowing?>
|
||||
fun observeProfileWithFollowingByPublicKey(publicKey: String): Flow<press.mantra.compose.database.model.intermdiate.LocalProfileWithFollowing?>
|
||||
|
||||
@Insert
|
||||
suspend fun insertPlaceholderProfile(profile: Profile)
|
||||
@@ -1,4 +1,4 @@
|
||||
package at.torch.compose.database.dao
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Insert
|
||||
@@ -8,14 +8,14 @@ import androidx.room3.Upsert
|
||||
@Dao
|
||||
interface QuotedRelationDao {
|
||||
@Query("SELECT * FROM QuotedRelation WHERE quotingNostrEventId = :quotingNostrEventId")
|
||||
fun getRepostByQuotingNostrEventId(quotingNostrEventId: String): at.torch.compose.database.model.QuotedRelation?
|
||||
fun getRepostByQuotingNostrEventId(quotingNostrEventId: String): press.mantra.compose.database.model.QuotedRelation?
|
||||
|
||||
@Query("SELECT * FROM QuotedRelation WHERE quotedNostrEventId = :quotedNostrEventId")
|
||||
fun getRepostByQuotedNostrEventId(quotedNostrEventId: String): at.torch.compose.database.model.QuotedRelation?
|
||||
fun getRepostByQuotedNostrEventId(quotedNostrEventId: String): press.mantra.compose.database.model.QuotedRelation?
|
||||
|
||||
@Insert
|
||||
suspend fun insert(quotedRelation: at.torch.compose.database.model.QuotedRelation)
|
||||
suspend fun insert(quotedRelation: press.mantra.compose.database.model.QuotedRelation)
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(quotedRelation: at.torch.compose.database.model.QuotedRelation)
|
||||
suspend fun upsert(quotedRelation: press.mantra.compose.database.model.QuotedRelation)
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Dao
|
||||
interface ReactionDao {
|
||||
@Query("SELECT * FROM Reaction")
|
||||
fun getAllReactions(): List<press.mantra.compose.database.model.Reaction>
|
||||
|
||||
@Query("SELECT * FROM Reaction WHERE id = :id")
|
||||
fun getReactionById(id: String): Flow<press.mantra.compose.database.model.Reaction?>
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(reaction: press.mantra.compose.database.model.Reaction)
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Delete
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Dao
|
||||
interface RecentSearchDao {
|
||||
@Query("SELECT * FROM RecentSearch WHERE `query` = :query")
|
||||
fun observeRecentSearchByQuery(query: String): Flow<press.mantra.compose.database.model.RecentSearch?>
|
||||
|
||||
@Query("SELECT * FROM RecentSearch ORDER BY createdAt DESC LIMIT :limit ")
|
||||
fun getAllRecentSearches(limit: Int = 21): List<press.mantra.compose.database.model.RecentSearch>
|
||||
|
||||
@Delete
|
||||
fun deleteRecentSearch(recentSearch: press.mantra.compose.database.model.RecentSearch)
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(recentSearch: press.mantra.compose.database.model.RecentSearch)
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Dao
|
||||
interface RelayDao {
|
||||
@Query("SELECT * FROM Relay")
|
||||
fun getAllPosts(): List<press.mantra.compose.database.model.Relay>
|
||||
|
||||
@Query("SELECT * FROM Relay WHERE publicKey = :publicKey")
|
||||
fun observePublicKeyRelays(publicKey: String): Flow<List<press.mantra.compose.database.model.Relay>>
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(relay: press.mantra.compose.database.model.Relay)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
|
||||
@Dao
|
||||
interface RepostedRelationDao {
|
||||
@Query("SELECT * FROM RepostedRelation")
|
||||
fun getAllReposts(): List<press.mantra.compose.database.model.RepostedRelation>
|
||||
|
||||
@Query("SELECT * FROM RepostedRelation WHERE repostingNostrEventId = :repostingNostrEventId")
|
||||
fun getRepostByRepostingId(repostingNostrEventId: String): press.mantra.compose.database.model.RepostedRelation?
|
||||
|
||||
@Query("SELECT * FROM RepostedRelation WHERE repostedNostrEventId = :repostedNostrEventId")
|
||||
fun getRepostByRepostedId(repostedNostrEventId: String): press.mantra.compose.database.model.RepostedRelation?
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(repostedRelation: press.mantra.compose.database.model.RepostedRelation)
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package at.torch.compose.database.dao
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Insert
|
||||
@@ -11,14 +11,14 @@ import kotlin.time.Instant
|
||||
@Dao
|
||||
interface SynchronizeNostrEventRequestDao {
|
||||
@Query("SELECT * FROM SynchronizeNostrEventRequest WHERE status = :status AND createdAt > :createdAt")
|
||||
fun observeSynchronizeNostrEventRequestsByStatus(status: String, createdAt: Instant = Clock.System.now()): Flow<at.torch.compose.database.model.SynchronizeNostrEventRequest?>
|
||||
fun observeSynchronizeNostrEventRequestsByStatus(status: String, createdAt: Instant = Clock.System.now()): Flow<press.mantra.compose.database.model.SynchronizeNostrEventRequest?>
|
||||
|
||||
@Query("SELECT COUNT(*) FROM SynchronizeNostrEventRequest WHERE purpose = :purpose AND status IN (:status) AND createdAt > :createdAt")
|
||||
fun observeSynchronizeNostrEventRequestByPurposeAndStatusCount(purpose: String, status: List<String>, createdAt: Instant = Clock.System.now()): Flow<Int>
|
||||
|
||||
@Upsert
|
||||
fun upsert(synchronizeNostrEventRequest: at.torch.compose.database.model.SynchronizeNostrEventRequest)
|
||||
fun upsert(synchronizeNostrEventRequest: press.mantra.compose.database.model.SynchronizeNostrEventRequest)
|
||||
|
||||
@Insert
|
||||
fun insert(synchronizeNostrEventRequests: List<at.torch.compose.database.model.SynchronizeNostrEventRequest>)
|
||||
fun insert(synchronizeNostrEventRequests: List<press.mantra.compose.database.model.SynchronizeNostrEventRequest>)
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Upsert
|
||||
|
||||
@Dao
|
||||
interface SynchronizeNostrEventResultDao {
|
||||
@Upsert
|
||||
fun upsert(synchronizeNostrEventResult: press.mantra.compose.database.model.SynchronizeNostrEventResult)
|
||||
}
|
||||
@@ -1,29 +1,29 @@
|
||||
package at.torch.compose.database.dao
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Insert
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Transaction
|
||||
import androidx.room3.Upsert
|
||||
import at.torch.compose.database.model.intermdiate.LocalAccount
|
||||
import press.mantra.compose.database.model.intermdiate.LocalAccount
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Dao
|
||||
interface UnsignedNostrEventDao {
|
||||
@Query("SELECT * FROM UnsignedNostrEvent")
|
||||
fun getAUnsignedNostrEvents(): List<at.torch.compose.database.model.UnsignedNostrEvent>
|
||||
fun getAUnsignedNostrEvents(): List<press.mantra.compose.database.model.UnsignedNostrEvent>
|
||||
|
||||
@Query("SELECT * FROM UnsignedNostrEvent") // TODO: where nostrEvent.unsignedNostrEventId is 0
|
||||
fun getAllUnprocessedUnsignedNostrEvents(): List<at.torch.compose.database.model.UnsignedNostrEvent>
|
||||
fun getAllUnprocessedUnsignedNostrEvents(): List<press.mantra.compose.database.model.UnsignedNostrEvent>
|
||||
|
||||
@Query("SELECT * FROM UnsignedNostrEvent WHERE id = :id")
|
||||
fun getUnsignedNostrEventById(id: Long): Flow<at.torch.compose.database.model.UnsignedNostrEvent?>
|
||||
fun getUnsignedNostrEventById(id: Long): Flow<press.mantra.compose.database.model.UnsignedNostrEvent?>
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(unsignedNostrEvent: at.torch.compose.database.model.UnsignedNostrEvent): Long
|
||||
suspend fun upsert(unsignedNostrEvent: press.mantra.compose.database.model.UnsignedNostrEvent): Long
|
||||
|
||||
@Insert
|
||||
suspend fun insert(unsignedNostrEvents: List<at.torch.compose.database.model.UnsignedNostrEvent>)
|
||||
suspend fun insert(unsignedNostrEvents: List<press.mantra.compose.database.model.UnsignedNostrEvent>)
|
||||
|
||||
@Transaction
|
||||
@Query("SELECT * FROM UnsignedNostrEvent WHERE kind = 0 AND pubKey = :publicKey")
|
||||
@@ -34,5 +34,5 @@ interface UnsignedNostrEventDao {
|
||||
fun getLocalAccounts(): List<LocalAccount>
|
||||
|
||||
@Query("SELECT * FROM UnsignedNostrEvent WHERE pubKey = :publicKey AND signedAt IS NULL")
|
||||
fun observeUnsignedNostrEvents(publicKey: String): Flow<at.torch.compose.database.model.UnsignedNostrEvent?>
|
||||
fun observeUnsignedNostrEvents(publicKey: String): Flow<press.mantra.compose.database.model.UnsignedNostrEvent?>
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package at.torch.compose.database.dao
|
||||
package press.mantra.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
import at.torch.compose.database.model.Zap
|
||||
import press.mantra.compose.database.model.Zap
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Dao
|
||||
@@ -1,4 +1,4 @@
|
||||
package at.torch.compose.database.model
|
||||
package press.mantra.compose.database.model
|
||||
|
||||
import androidx.room3.Entity
|
||||
import androidx.room3.ForeignKey
|
||||
@@ -35,5 +35,5 @@ data class BroadcastNostrEventReceipt(
|
||||
val isSync: Boolean = false,
|
||||
val relayURL: String,
|
||||
val messages: String? = null
|
||||
): at.torch.compose.database.model.traits.NostrEventEntity,
|
||||
at.torch.compose.database.model.traits.UnsignedNostrEventEntity
|
||||
): press.mantra.compose.database.model.traits.NostrEventEntity,
|
||||
press.mantra.compose.database.model.traits.UnsignedNostrEventEntity
|
||||
@@ -1,12 +1,12 @@
|
||||
package at.torch.compose.database.model
|
||||
package press.mantra.compose.database.model
|
||||
|
||||
import androidx.room3.Entity
|
||||
import androidx.room3.ForeignKey
|
||||
import androidx.room3.Index
|
||||
import androidx.room3.PrimaryKey
|
||||
import at.torch.compose.database.model.traits.NostrEventEntity
|
||||
import at.torch.compose.database.model.traits.TimestampedEntity
|
||||
import at.torch.compose.database.model.traits.UnsignedNostrEventEntity
|
||||
import press.mantra.compose.database.model.traits.NostrEventEntity
|
||||
import press.mantra.compose.database.model.traits.TimestampedEntity
|
||||
import press.mantra.compose.database.model.traits.UnsignedNostrEventEntity
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import kotlin.time.Clock
|
||||
import kotlin.time.Instant
|
||||
@@ -1,17 +1,15 @@
|
||||
package at.torch.compose.database.model
|
||||
package press.mantra.compose.database.model
|
||||
|
||||
import androidx.room3.Entity
|
||||
import androidx.room3.ForeignKey
|
||||
import androidx.room3.PrimaryKey
|
||||
import at.torch.compose.database.TorchDatabase
|
||||
import at.torch.compose.database.model.traits.LocalStoreEntity
|
||||
import at.torch.compose.database.model.traits.SoftDeletableEntity
|
||||
import at.torch.compose.database.model.traits.TimestampedEntity
|
||||
import at.torch.compose.database.model.traits.UserViewableEntity
|
||||
import at.torch.compose.exceptions.GiftWrapImpersonationException
|
||||
import at.torch.compose.exceptions.MarmotUnprocessableInnerEventException
|
||||
import at.torch.compose.exceptions.MarmotUnsupportedWireFormatException
|
||||
import at.torch.compose.extensions.toHex
|
||||
import press.mantra.compose.database.TorchDatabase
|
||||
import press.mantra.compose.database.model.traits.LocalStoreEntity
|
||||
import press.mantra.compose.database.model.traits.SoftDeletableEntity
|
||||
import press.mantra.compose.database.model.traits.TimestampedEntity
|
||||
import press.mantra.compose.database.model.traits.UserViewableEntity
|
||||
import press.mantra.compose.exceptions.MarmotUnprocessableInnerEventException
|
||||
import press.mantra.compose.extensions.toHex
|
||||
import com.vitorpamplona.quartz.marmot.GroupEventResult
|
||||
import com.vitorpamplona.quartz.marmot.mip03GroupMessages.GroupEvent
|
||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||
@@ -1,4 +1,4 @@
|
||||
package at.torch.compose.database.model
|
||||
package press.mantra.compose.database.model
|
||||
|
||||
import androidx.room3.Entity
|
||||
import androidx.room3.ForeignKey
|
||||
@@ -32,5 +32,5 @@ data class ChatMessageBroadcastNostrEventReceiptRelation(
|
||||
override val createdAt: Instant = Clock.System.now(),
|
||||
override val updatedAt: Instant = Clock.System.now(),
|
||||
override val savedAt: Instant = Clock.System.now()
|
||||
): at.torch.compose.database.model.traits.TimestampedEntity,
|
||||
at.torch.compose.database.model.traits.LocalStoreEntity
|
||||
): press.mantra.compose.database.model.traits.TimestampedEntity,
|
||||
press.mantra.compose.database.model.traits.LocalStoreEntity
|
||||
@@ -1,4 +1,4 @@
|
||||
package at.torch.compose.database.model
|
||||
package press.mantra.compose.database.model
|
||||
|
||||
import androidx.room3.Entity
|
||||
import androidx.room3.ForeignKey
|
||||
@@ -33,5 +33,5 @@ data class ChatMessageBroadcastNostrEventRequestRelation(
|
||||
override val createdAt: Instant = Clock.System.now(),
|
||||
override val updatedAt: Instant = Clock.System.now(),
|
||||
override val savedAt: Instant = Clock.System.now()
|
||||
): at.torch.compose.database.model.traits.TimestampedEntity,
|
||||
at.torch.compose.database.model.traits.LocalStoreEntity
|
||||
): press.mantra.compose.database.model.traits.TimestampedEntity,
|
||||
press.mantra.compose.database.model.traits.LocalStoreEntity
|
||||
@@ -1,4 +1,4 @@
|
||||
package at.torch.compose.database.model
|
||||
package press.mantra.compose.database.model
|
||||
|
||||
import androidx.room3.Entity
|
||||
import androidx.room3.ForeignKey
|
||||
@@ -33,5 +33,5 @@ data class ChatMessageNostrEventRelation(
|
||||
override val createdAt: Instant = Clock.System.now(),
|
||||
override val updatedAt: Instant = Clock.System.now(),
|
||||
override val savedAt: Instant = Clock.System.now(),
|
||||
): at.torch.compose.database.model.traits.TimestampedEntity,
|
||||
at.torch.compose.database.model.traits.LocalStoreEntity
|
||||
): press.mantra.compose.database.model.traits.TimestampedEntity,
|
||||
press.mantra.compose.database.model.traits.LocalStoreEntity
|
||||
@@ -1,13 +1,13 @@
|
||||
package at.torch.compose.database.model
|
||||
package press.mantra.compose.database.model
|
||||
|
||||
import androidx.room3.Entity
|
||||
import androidx.room3.ForeignKey
|
||||
import androidx.room3.Ignore
|
||||
import androidx.room3.PrimaryKey
|
||||
import at.torch.compose.database.model.traits.LocalStoreEntity
|
||||
import at.torch.compose.database.model.traits.SoftDeletableEntity
|
||||
import at.torch.compose.database.model.traits.TimestampedEntity
|
||||
import at.torch.compose.database.model.traits.UserViewableEntity
|
||||
import press.mantra.compose.database.model.traits.LocalStoreEntity
|
||||
import press.mantra.compose.database.model.traits.SoftDeletableEntity
|
||||
import press.mantra.compose.database.model.traits.TimestampedEntity
|
||||
import press.mantra.compose.database.model.traits.UserViewableEntity
|
||||
import co.touchlab.kermit.Logger
|
||||
import com.vitorpamplona.quartz.marmot.mls.group.MlsGroup
|
||||
import com.vitorpamplona.quartz.marmot.mls.group.MlsGroupState
|
||||
@@ -1,4 +1,4 @@
|
||||
package at.torch.compose.database.model
|
||||
package press.mantra.compose.database.model
|
||||
|
||||
import androidx.room3.Entity
|
||||
import androidx.room3.ForeignKey
|
||||
@@ -34,8 +34,8 @@ data class Connection(
|
||||
override val savedAt: Instant = Clock.System.now(),
|
||||
override val deletedAt: Instant? = null,
|
||||
override val broadcastedAt: Instant? = null,
|
||||
): at.torch.compose.database.model.traits.NostrEventEntity,
|
||||
at.torch.compose.database.model.traits.TimestampedEntity,
|
||||
at.torch.compose.database.model.traits.LocalStoreEntity,
|
||||
at.torch.compose.database.model.traits.BroadcastableEntity,
|
||||
at.torch.compose.database.model.traits.SoftDeletableEntity
|
||||
): press.mantra.compose.database.model.traits.NostrEventEntity,
|
||||
press.mantra.compose.database.model.traits.TimestampedEntity,
|
||||
press.mantra.compose.database.model.traits.LocalStoreEntity,
|
||||
press.mantra.compose.database.model.traits.BroadcastableEntity,
|
||||
press.mantra.compose.database.model.traits.SoftDeletableEntity
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user