PacketRepository

Repository interface for managing mesh packets and message history.

This component provides methods for persisting received packets, querying message history, tracking unread counts, and managing contact-specific settings. It supports both reactive (Flow) and one-shot (suspend) queries.

Functions

Link copied to clipboard
abstract suspend fun clearAllUnreadCounts()

Clears the unread status for all messages across all conversations.

Link copied to clipboard
abstract suspend fun clearPacketDB()

Clears all packet and message history from the database.

Link copied to clipboard
abstract suspend fun clearUnreadCount(contact: String, timestamp: Long)

Clears the unread status for messages in a conversation up to the given timestamp.

Link copied to clipboard
abstract suspend fun deleteContacts(contactList: List<String>)

Deletes all messages and settings for the given contacts.

Link copied to clipboard
abstract suspend fun deleteMessages(uuidList: List<Long>)

Deletes messages by their database UUIDs.

Link copied to clipboard
abstract suspend fun deleteWaypoint(id: Int)

Deletes a waypoint by its ID.

Link copied to clipboard
abstract suspend fun findPacketsWithId(packetId: Int): List<DataPacket>

Finds all packets matching a specific packet ID.

Link copied to clipboard
abstract suspend fun findReactionsWithId(packetId: Int): List<Reaction>

Finds all reactions associated with a specific packet ID.

Link copied to clipboard
abstract fun getContacts(): Flow<Map<String, DataPacket>>

Reactive flow of all conversation contacts, keyed by their contact identifier.

Link copied to clipboard

Reactive flow of all contact settings (e.g., mute status).

abstract suspend fun getContactSettings(contact: String): ContactSettings

Returns the settings for a specific contact.

Link copied to clipboard
abstract fun getContactsPaged(): Flow<PagingData<DataPacket>>

Reactive paged flow of conversation contacts.

Link copied to clipboard
abstract suspend fun getFilteredCount(contactKey: String): Int

Returns the total count of filtered messages for a contact.

Link copied to clipboard
abstract fun getFilteredCountFlow(contactKey: String): Flow<Int>

Reactive flow of the number of filtered messages for a contact.

Link copied to clipboard
abstract fun getFirstUnreadMessageUuid(contact: String): Flow<Long?>

Reactive flow of the UUID of the first unread message in a conversation.

Link copied to clipboard
abstract suspend fun getMessageCount(contact: String): Int

Returns the total number of messages in a conversation.

Link copied to clipboard
abstract suspend fun getMessagesFrom(contact: String, limit: Int? = null, includeFiltered: Boolean = true, getNode: suspend (String?) -> Node): Flow<List<Message>>

Returns a reactive flow of messages for a conversation.

Link copied to clipboard
abstract fun getMessagesFromPaged(contact: String, getNode: suspend (String?) -> Node): Flow<PagingData<Message>>

Returns a paged flow of messages for a conversation.

abstract fun getMessagesFromPaged(contactKey: String, includeFiltered: Boolean, getNode: suspend (String?) -> Node): Flow<PagingData<Message>>

Returns a paged flow of messages for a conversation, with filtering options.

Link copied to clipboard
abstract suspend fun getPacketById(id: Int): DataPacket?

Returns a packet by its internal database ID.

Link copied to clipboard
abstract suspend fun getPacketByPacketId(packetId: Int): DataPacket?

Returns a packet by its mesh-layer packet ID.

Link copied to clipboard
abstract suspend fun getQueuedPackets(): List<DataPacket>

Returns all packets currently queued for transmission.

Link copied to clipboard
abstract suspend fun getReactionByPacketId(packetId: Int): Reaction?

Returns a reaction associated with a specific packet ID.

Link copied to clipboard
abstract suspend fun getUnreadCount(contact: String): Int

Returns the count of unread messages in a conversation.

Link copied to clipboard
abstract fun getUnreadCountFlow(contact: String): Flow<Int>

Reactive flow of the unread message count in a conversation.

Link copied to clipboard
abstract fun getUnreadCountTotal(): Flow<Int>

Reactive flow of the total unread message count across all conversations.

Link copied to clipboard
abstract fun getWaypoints(): Flow<List<DataPacket>>

Reactive flow of all persisted waypoints (GPS locations).

Link copied to clipboard
abstract fun hasUnreadMessages(contact: String): Flow<Boolean>

Reactive flow indicating whether a conversation has any unread messages.

Link copied to clipboard
abstract suspend fun insert(packet: DataPacket, myNodeNum: Int, contactKey: String, receivedTime: Long, read: Boolean = true, filtered: Boolean = false)

Inserts a packet into the database.

Link copied to clipboard
abstract suspend fun insertReaction(reaction: Reaction, myNodeNum: Int)

Persists a message reaction (emoji).

Link copied to clipboard
abstract suspend fun migrateChannelsByPSK(oldSettings: List<ChannelSettings>, newSettings: List<ChannelSettings>)

Migrates channel-specific message history when encryption keys change.

Link copied to clipboard
abstract suspend fun savePacket(myNodeNum: Int, contactKey: String, packet: DataPacket, receivedTime: Long, read: Boolean = true, filtered: Boolean = false)

Persists a packet in the database.

Link copied to clipboard
abstract suspend fun setContactFilteringDisabled(contactKey: String, disabled: Boolean)

Disables or enables message filtering for a specific contact.

Link copied to clipboard
abstract suspend fun setMuteUntil(contacts: List<String>, until: Long)

Mutes the given contacts until the specified timestamp.

Link copied to clipboard
abstract suspend fun update(packet: DataPacket, routingError: Int = -1)

Updates an existing packet in the database, optionally setting a routing error code.

Link copied to clipboard
abstract suspend fun updateFilteredBySender(senderId: String, filtered: Boolean)

Marks all messages from a specific sender as filtered or unfiltered.

Link copied to clipboard
abstract suspend fun updateLastReadMessage(contact: String, messageUuid: Long, lastReadTimestamp: Long)

Updates the identifier of the last read message in a conversation.

Link copied to clipboard
abstract suspend fun updateMessageId(d: DataPacket, id: Int)

Updates the identifier of a persisted packet.

Link copied to clipboard
abstract suspend fun updateMessageStatus(d: DataPacket, m: MessageStatus)

Updates the transmission status of a packet.

Link copied to clipboard
abstract suspend fun updateReaction(reaction: Reaction)

Updates an existing reaction.

Link copied to clipboard
abstract suspend fun updateSFPPStatus(packetId: Int, from: Int, to: Int, hash: ByteArray, status: MessageStatus, rxTime: Long, myNodeNum: Int?)

Updates the Store-and-Forward PlusPlus (SFPP) status for packets.

Link copied to clipboard
abstract suspend fun updateSFPPStatusByHash(hash: ByteArray, status: MessageStatus, rxTime: Long)

Updates the SFPP status of packets matching the given commit hash.