feat: screener for message requests #24

Merged
reya merged 6 commits from feat/screening into master 2026-06-19 09:06:50 +00:00
2 changed files with 10 additions and 12 deletions
Showing only changes of commit b1cb8b0fea - Show all commits

View File

@@ -734,7 +734,8 @@ fun ChatRoom(room: Room, onClick: () -> Unit) {
Text( Text(
text = room.lastMessage!!, text = room.lastMessage!!,
style = MaterialTheme.typography.bodyMedium, style = MaterialTheme.typography.bodyMedium,
overflow = TextOverflow.Ellipsis overflow = TextOverflow.Ellipsis,
maxLines = 1,
) )
} }
}, },

View File

@@ -399,15 +399,11 @@ class Nostr {
private suspend fun setCachedRumor(giftId: EventId, rumor: UnsignedEvent) { private suspend fun setCachedRumor(giftId: EventId, rumor: UnsignedEvent) {
try { try {
// Construct the room id
val roomId = rumor.roomId()
// Construct reference tags // Construct reference tags
val tags = listOf( val tags = listOf(
Tag.identifier(giftId.toHex()), Tag.identifier(giftId.toHex()),
Tag.publicKey(rumor.author()), Tag.publicKey(rumor.author()),
Tag.event(rumor.id()!!), Tag.custom("r", listOf(rumor.roomId().toString())),
Tag.custom("r", listOf(roomId.toString())),
Tag.custom("k", listOf("14")) Tag.custom("k", listOf("14"))
) )
@@ -748,8 +744,8 @@ class Nostr {
val kind = Kind.fromStd(KindStandard.APPLICATION_SPECIFIC_DATA) val kind = Kind.fromStd(KindStandard.APPLICATION_SPECIFIC_DATA)
val kTag = SingleLetterTag.lowercase(Alphabet.K) val kTag = SingleLetterTag.lowercase(Alphabet.K)
// Get all events sent by the user // Get all DM events
val filter = Filter().kind(kind).pubkey(userPubkey).customTags(kTag, listOf("14", "dm")) val filter = Filter().kind(kind).customTags(kTag, listOf("14", "dm"))
val events = client?.database()?.query(filter) val events = client?.database()?.query(filter)
// Collect rooms // Collect rooms
@@ -765,12 +761,13 @@ class Nostr {
// Check if the room already exists // Check if the room already exists
if (existingRoom == null || newRoom.createdAt.asSecs() > existingRoom.createdAt.asSecs()) { if (existingRoom == null || newRoom.createdAt.asSecs() > existingRoom.createdAt.asSecs()) {
val kind = Kind.fromStd(KindStandard.PRIVATE_DIRECT_MESSAGE) val rTag = SingleLetterTag.lowercase(Alphabet.R)
val pubkeys = newRoom.members.toList() val filter = Filter().kind(kind).pubkey(userPubkey)
val filter = Filter().kind(kind).author(userPubkey).pubkeys(pubkeys) .customTag(rTag, newRoom.id.toString())
// Determine if it's an ongoing room // Determine if it's an ongoing room
val isOngoing = client?.database()?.query(filter)?.isEmpty() ?: false val isOngoing =
client?.database()?.query(filter)?.toVec()?.isNotEmpty() ?: false
// Append room to map // Append room to map
roomsMap[newRoom.id] = roomsMap[newRoom.id] =