Dms class

Direct-messages usecase built on NIP-17 gift-wrapped messages.

This usecase provides app-facing helpers for:

  • sending a DM to a peer
  • loading the logged-in user's conversations
  • loading one conversation with a specific peer
  • parsing a wrapped event into a DM message model

Conversation loading uses the logged-in user's DM relay list and can reuse cached decrypted payload sidecars for fast repeated reads.

Constructors

Dms({required Accounts accounts, required Requests requests, required Broadcast broadcast, required GiftWrap giftWrap, required UserRelayLists userRelayLists, required CacheManager cacheManager, required EventVerifier eventVerifier})
Creates the direct-messages usecase.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

loadConversation({required String peerPubKey, bool forceRefresh = false, Duration timeout = const Duration(seconds: 5)}) Future<List<Nip17Message>>
Loads the full conversation with one peer.
loadConversations({bool forceRefresh = false, Duration timeout = const Duration(seconds: 5)}) Future<List<Nip17Conversation>>
Loads all conversations for the logged-in user.
loadConversationSnapshot({required String peerPubKey}) Future<List<Nip17Message>>
Loads the conversation with one peer using cache only.
loadConversationsSnapshot() Future<List<Nip17Conversation>>
Loads all conversations for the logged-in user using cache only.
loadLegacyNip04Conversation({required String peerPubKey, required Iterable<String> rendezvousRelays, bool forceRefresh = false, Duration timeout = const Duration(seconds: 5)}) Future<List<LegacyNip04Message>>
Loads and decrypts legacy NIP-04 messages with peerPubKey from the explicitly supplied rendezvous relays.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parseWrappedMessage({required Nip01Event wrappedEvent}) Future<Nip17Message?>
Parses a single wrapped event into a DM message if possible.
publishDmRelays({required List<String> relayUrlsOrdered, Iterable<String>? broadcastRelays}) Future<List<RelayBroadcastResponse>>
Publishes the logged-in account's ordered NIP-17 inbox relay list as a replaceable kind-10050 event.
sendFileMessage({required String recipientPubKey, required Nip17FileMetadata metadata, List<List<String>> additionalTags = const [], Iterable<String>? recipientDmRelayDiscoveryRelays}) Future<void>
Sends an already-uploaded encrypted file as a NIP-17 kind-15 message.
sendLegacyNip04Message({required String recipientPubKey, required String content, required Iterable<String> rendezvousRelays}) Future<void>
Sends a legacy NIP-04 text DM through explicitly supplied rendezvous relays.
sendMessage({required String recipientPubKey, required String content, List<List<String>> additionalTags = const [], Iterable<String>? recipientDmRelayDiscoveryRelays}) Future<void>
Sends a direct message to recipientPubKey.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

kFileMessageKind → const int
Encrypted file rumor kind defined by NIP-17.
kLegacyNip04MessageKind → const int
Legacy NIP-04 encrypted direct-message event kind.
kMessageKind → const int
Message rumor kind used by this DM usecase.