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 +2 -2
- package/dist/actions/wrapped-messages.js +8 -9
- package/package.json +1 -1
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://
|
|
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://
|
|
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
|
|
9
|
-
|
|
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(
|
|
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
|
|
23
|
-
|
|
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(
|
|
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
|
/**
|