feat: improve NIP-17 DM loading logic for incoming and outgoing messages

This commit is contained in:
2026-01-16 21:24:08 +01:00
parent 9c50d8a3ba
commit b05267c8d5
4 changed files with 130 additions and 42 deletions

View File

@@ -1,14 +1,19 @@
use crate::nips::nip17::{self, Message};
use anyhow::Result;
use nostr_sdk::prelude::*;
// Importiere das Message Struct aus nip17!
use crate::nips::nip17::{self, Message};
pub async fn send_private_message(client: &Client, receiver_pubkey: &str, message: &str) -> Result<EventId> {
/// Sends a private message.
/// The SDK will automatically handle the NIP-17 (modern) or NIP-04 (legacy) logic.
pub async fn send_private_message(
client: &Client,
receiver_pubkey: &str,
message: &str,
) -> Result<EventId> {
let receiver = PublicKey::parse(receiver_pubkey)?;
nip17::send_dm(client, receiver, message).await
}
// Rückgabetyp ist Vec<Message>
/// Fetches all private messages between the user and a specific contact.
pub async fn get_private_messages(client: &Client, contact_npub: &str) -> Result<Vec<Message>> {
nip17::get_dm_messages(client, contact_npub).await
}
}