Change how mentions are handled

This commit is contained in:
Kgothatso Ngako
2026-05-02 01:19:28 +02:00
parent bfc540812d
commit b9cece869e
7 changed files with 30 additions and 24 deletions

View File

@@ -362,7 +362,7 @@ abstract class NostrDao(
database.mentionDao().insert(
Mention(
mentionedPublicKey = taggedUser.pubKey,
nostrEventId = nostrEvent.id,
mentioningNostrEventId = nostrEvent.id,
relayUrl = taggedUser.relayHint?.url
)
)

View File

@@ -7,6 +7,7 @@ import ac.cord.auxiliary.compose.database.model.traits.SoftDeletableEntity
import ac.cord.auxiliary.compose.database.model.traits.TimestampedEntity
import androidx.room3.Entity
import androidx.room3.ForeignKey
import androidx.room3.PrimaryKey
import com.vitorpamplona.quartz.nip01Core.core.HexKey
import kotlin.time.Clock
import kotlin.time.Instant
@@ -22,22 +23,23 @@ import kotlin.time.Instant
ForeignKey(
entity = NostrEvent::class,
parentColumns = ["id"],
childColumns = ["nostrEventId"],
childColumns = ["mentioningNostrEventId"],
onDelete = ForeignKey.CASCADE,
),
],
primaryKeys = ["nostrEventId", "mentionedPublicKey"]
]
)
data class Mention(
@PrimaryKey(autoGenerate = true)
val id: Long = 0,
val mentionedPublicKey: HexKey,
val mentioningNostrEventId: HexKey? = null,
val relayUrl: String? = null,
override val nostrEventId: HexKey, // This is the contactListEvent with this following...
override val createdAt: Instant = Clock.System.now(),
override val updatedAt: Instant = Clock.System.now(),
override val savedAt: Instant = Clock.System.now(),
override val deletedAt: Instant? = null,
override val broadcastedAt: Instant? = null,
): NostrEventEntity, TimestampedEntity, LocalStoreEntity, BroadcastableEntity, SoftDeletableEntity
): TimestampedEntity, LocalStoreEntity, BroadcastableEntity, SoftDeletableEntity

View File

@@ -41,7 +41,7 @@ data class LocalInReplyToNostrEvent(
@Relation(
entity = Mention::class,
parentColumn = "inReplyToNostrEventId",
entityColumn = "nostrEventId",
entityColumn = "mentioningNostrEventId",
)
val mentionedProfiles: List<LocalMention?> = emptyList(),
) {

View File

@@ -59,7 +59,7 @@ data class LocalNostrEvent(
@Relation(
entity = Mention::class,
parentColumn = "id",
entityColumn = "nostrEventId",
entityColumn = "mentioningNostrEventId",
)
val mentionedProfiles: List<LocalMention?>? = emptyList(),
) {

View File

@@ -41,7 +41,7 @@ data class LocalQuotedNostrEvent(
@Relation(
entity = Mention::class,
parentColumn = "quotedNostrEventId",
entityColumn = "nostrEventId",
entityColumn = "mentioningNostrEventId",
)
val mentionedProfiles: List<LocalMention?> = emptyList(),
) {

View File

@@ -41,7 +41,7 @@ data class LocalRepostedNostrEvent(
@Relation(
entity = Mention::class,
parentColumn = "repostedNostrEventId",
entityColumn = "nostrEventId",
entityColumn = "mentioningNostrEventId",
)
val mentionedProfiles: List<LocalMention?> = emptyList(),
) {