Skip to content

Commit

Permalink
Merge #163: Rename EventBuilder arg
Browse files Browse the repository at this point in the history
  • Loading branch information
yukibtc committed Sep 12, 2023
2 parents 5ce0e4b + 4519344 commit f2b2e05
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions bindings/nostr-ffi/src/event/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,14 @@ impl EventBuilder {
sender_keys: Arc<Keys>,
receiver_pubkey: Arc<PublicKey>,
content: String,
reply: Option<Arc<EventId>>,
reply_to: Option<Arc<EventId>>,
) -> Result<Self> {
Ok(Self {
builder: EventBuilderSdk::new_encrypted_direct_msg(
sender_keys.deref(),
*receiver_pubkey.as_ref().deref(),
content,
reply.map(|id| id.as_ref().into()),
reply_to.map(|id| id.as_ref().into()),
)?,
})
}
Expand Down
2 changes: 1 addition & 1 deletion bindings/nostr-ffi/src/nostr.udl
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ interface EventBuilder {
[Name=set_contact_list]
constructor(sequence<Contact> list);
[Throws=NostrError, Name=new_encrypted_direct_msg]
constructor(Keys sender_keys, PublicKey receiver_pubkey, string content, EventId? reply);
constructor(Keys sender_keys, PublicKey receiver_pubkey, string content, EventId? reply_to);
[Name=delete]
constructor(sequence<EventId> ids, optional string? reason = null);
[Name=new_reaction]
Expand Down
4 changes: 2 additions & 2 deletions bindings/nostr-js/src/event/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ impl JsEventBuilder {
sender_keys: &JsKeys,
receiver_pubkey: &JsPublicKey,
content: String,
reply: Option<JsEventId>,
reply_to: Option<JsEventId>,
) -> Result<JsEventBuilder> {
Ok(Self {
builder: EventBuilder::new_encrypted_direct_msg(
sender_keys.deref(),
receiver_pubkey.into(),
content,
reply.map(|id| id.into()),
reply_to.map(|id| id.into()),
)
.map_err(into_err)?,
})
Expand Down
2 changes: 1 addition & 1 deletion bindings/nostr-sdk-ffi/src/nostr_sdk.udl
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ interface EventBuilder {
[Name=set_contact_list]
constructor(sequence<Contact> list);
[Throws=NostrError, Name=new_encrypted_direct_msg]
constructor(Keys sender_keys, PublicKey receiver_pubkey, string content, EventId? reply);
constructor(Keys sender_keys, PublicKey receiver_pubkey, string content, EventId? reply_to);
[Name=delete]
constructor(sequence<EventId> ids, optional string? reason = null);
[Name=new_reaction]
Expand Down
6 changes: 3 additions & 3 deletions crates/nostr-sdk/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ impl Client {
&self,
receiver: XOnlyPublicKey,
msg: S,
reply: Option<EventId>,
reply_to: Option<EventId>,
) -> Result<EventId, Error>
where
S: Into<String>,
Expand All @@ -1010,11 +1010,11 @@ impl Client {
return Err(Error::ResponseNotMatchRequest);
}
} else {
EventBuilder::new_encrypted_direct_msg(&self.keys, receiver, msg, reply)?
EventBuilder::new_encrypted_direct_msg(&self.keys, receiver, msg, reply_to)?
};

#[cfg(not(feature = "nip46"))]
let builder = EventBuilder::new_encrypted_direct_msg(&self.keys, receiver, msg, reply)?;
let builder = EventBuilder::new_encrypted_direct_msg(&self.keys, receiver, msg, reply_to)?;

self.send_event_builder(builder).await
}
Expand Down
6 changes: 3 additions & 3 deletions crates/nostr/src/event/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,14 +363,14 @@ impl EventBuilder {
sender_keys: &Keys,
receiver_pubkey: XOnlyPublicKey,
content: S,
reply: Option<EventId>,
reply_to: Option<EventId>,
) -> Result<Self, Error>
where
S: Into<String>,
{
let mut tags: Vec<Tag> = vec![Tag::PubKey(receiver_pubkey, None)];
if let Some(reply) = reply {
tags.push(Tag::Event(reply, None, None));
if let Some(reply_to) = reply_to {
tags.push(Tag::Event(reply_to, None, None));
}
Ok(Self::new(
Kind::EncryptedDirectMessage,
Expand Down

0 comments on commit f2b2e05

Please sign in to comment.