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

@@ -2,7 +2,7 @@
"formatVersion": 1,
"database": {
"version": 1,
"identityHash": "296c3251f1f835c144c94c7ff1598939",
"identityHash": "2e56a98cfa2734b3c9f8945e5384f7e7",
"entities": [
{
"tableName": "BroadcastNostrEventReceipt",
@@ -389,8 +389,14 @@
},
{
"tableName": "Mention",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`mentionedPublicKey` TEXT NOT NULL, `relayUrl` TEXT, `nostrEventId` TEXT NOT NULL, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, PRIMARY KEY(`nostrEventId`, `mentionedPublicKey`), FOREIGN KEY(`mentionedPublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`nostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `mentionedPublicKey` TEXT NOT NULL, `mentioningNostrEventId` TEXT, `relayUrl` TEXT, `createdAt` INTEGER NOT NULL, `updatedAt` INTEGER NOT NULL, `savedAt` INTEGER NOT NULL, `deletedAt` INTEGER, `broadcastedAt` INTEGER, FOREIGN KEY(`mentionedPublicKey`) REFERENCES `Profile`(`publicKey`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`mentioningNostrEventId`) REFERENCES `NostrEvent`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "mentionedPublicKey",
"columnName": "mentionedPublicKey",
@@ -398,15 +404,14 @@
"notNull": true
},
{
"fieldPath": "relayUrl",
"columnName": "relayUrl",
"fieldPath": "mentioningNostrEventId",
"columnName": "mentioningNostrEventId",
"affinity": "TEXT"
},
{
"fieldPath": "nostrEventId",
"columnName": "nostrEventId",
"affinity": "TEXT",
"notNull": true
"fieldPath": "relayUrl",
"columnName": "relayUrl",
"affinity": "TEXT"
},
{
"fieldPath": "createdAt",
@@ -438,10 +443,9 @@
}
],
"primaryKey": {
"autoGenerate": false,
"autoGenerate": true,
"columnNames": [
"nostrEventId",
"mentionedPublicKey"
"id"
]
},
"foreignKeys": [
@@ -461,7 +465,7 @@
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"nostrEventId"
"mentioningNostrEventId"
],
"referencedColumns": [
"id"
@@ -1818,7 +1822,7 @@
],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '296c3251f1f835c144c94c7ff1598939')"
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '2e56a98cfa2734b3c9f8945e5384f7e7')"
]
}
}

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(),
) {