applesauce-actions 5.0.2 → 5.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A collection of pre-built actions nostr clients can use. Built on top of `applesauce-core` and `applesauce-factory`.
4
4
 
5
- [Documentation](https://hzrd149.github.io/applesauce/typedoc/modules/applesauce-actions.html)
5
+ [Documentation](https://applesauce.build/typedoc/modules/applesauce-actions.html)
6
6
 
7
7
  ## Installation
8
8
 
@@ -39,4 +39,4 @@ await hub
39
39
  .forEach((event) => publishEvent(event));
40
40
  ```
41
41
 
42
- For more detailed documentation and examples, visit the [full documentation](https://hzrd149.github.io/applesauce/overview/actions.html).
42
+ For more detailed documentation and examples, visit the [full documentation](https://applesauce.build/overview/actions.html).
@@ -5,11 +5,11 @@ import { getConversationParticipants } from "applesauce-common/helpers/messages"
5
5
  export function GiftWrapMessageToParticipants(message, opts) {
6
6
  return async ({ factory, user, publish, events }) => {
7
7
  // Get the pubkeys to send this message to and ensure the sender is included
8
- const pubkeys = new Set(getConversationParticipants(message));
9
- pubkeys.add(user.pubkey);
8
+ const receivers = new Set(getConversationParticipants(message));
9
+ receivers.add(user.pubkey);
10
10
  // Get all the users inbox relays
11
11
  const inboxRelays = new Map();
12
- await Promise.allSettled(Array.from(pubkeys).map(async (pubkey) => {
12
+ await Promise.allSettled(Array.from(receivers).map(async (pubkey) => {
13
13
  const receiver = castUser(pubkey, events);
14
14
  // Use the dm relays or inboxes as the inbox relays for the participant
15
15
  const relays = (await receiver.directMessageRelays$.$first(1_000, undefined)) ??
@@ -19,14 +19,13 @@ export function GiftWrapMessageToParticipants(message, opts) {
19
19
  }));
20
20
  // Create the gift wraps to send
21
21
  const giftWraps = [];
22
- for (const pubkey of pubkeys) {
23
- giftWraps.push(await factory.create(GiftWrapBlueprint, pubkey, message, opts));
22
+ for (const receiver of receivers) {
23
+ const event = await factory.create(GiftWrapBlueprint, receiver, message, opts);
24
+ const relays = inboxRelays.get(receiver);
25
+ giftWraps.push({ event, relays });
24
26
  }
25
27
  // Publish all gift wraps in parallel
26
- await Promise.allSettled(giftWraps.map(async (giftWrap) => {
27
- const relays = inboxRelays.get(giftWrap.pubkey);
28
- await publish(giftWrap, relays);
29
- }));
28
+ await Promise.allSettled(giftWraps.map(({ event, relays }) => publish(event, relays)));
30
29
  };
31
30
  }
32
31
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "applesauce-actions",
3
- "version": "5.0.2",
3
+ "version": "5.1.1",
4
4
  "description": "A package for performing common nostr actions",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",