applesauce-actions 6.0.0 → 6.1.0
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CommentFactoryOptions } from "applesauce-common/factories";
|
|
2
2
|
import { CommentPointer } from "applesauce-common/helpers/comment";
|
|
3
3
|
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
4
4
|
import { Action } from "../action-runner.js";
|
|
@@ -7,4 +7,4 @@ import { Action } from "../action-runner.js";
|
|
|
7
7
|
* - The parent event's author's inboxes (if the author exists and pubkey is available)
|
|
8
8
|
* - The current user's outboxes
|
|
9
9
|
*/
|
|
10
|
-
export declare function CreateComment(parent: NostrEvent | CommentPointer, content: string, options?:
|
|
10
|
+
export declare function CreateComment(parent: NostrEvent | CommentPointer, content: string, options?: CommentFactoryOptions): Action;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { LegacyMessageBlueprintOptions } from "applesauce-common/factories";
|
|
2
1
|
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
3
2
|
import { Action } from "../action-runner.js";
|
|
4
3
|
/** Sends a legacy NIP-04 message to a recipient */
|
|
5
|
-
export declare function SendLegacyMessage(recipient: string, message: string,
|
|
4
|
+
export declare function SendLegacyMessage(recipient: string, message: string, options?: {
|
|
5
|
+
expiration?: number;
|
|
6
|
+
}): Action;
|
|
6
7
|
/** Send a reply to a legacy message */
|
|
7
|
-
export declare function ReplyToLegacyMessage(parent: NostrEvent, message: string,
|
|
8
|
+
export declare function ReplyToLegacyMessage(parent: NostrEvent, message: string, options?: {
|
|
9
|
+
expiration?: number;
|
|
10
|
+
}): Action;
|
|
@@ -2,11 +2,14 @@ import { LegacyMessageFactory } from "applesauce-common/factories";
|
|
|
2
2
|
import { castUser } from "applesauce-common/casts";
|
|
3
3
|
import { kinds } from "applesauce-core/helpers/event";
|
|
4
4
|
/** Sends a legacy NIP-04 message to a recipient */
|
|
5
|
-
export function SendLegacyMessage(recipient, message,
|
|
5
|
+
export function SendLegacyMessage(recipient, message, options) {
|
|
6
6
|
return async ({ signer, publish, events }) => {
|
|
7
7
|
if (!signer)
|
|
8
8
|
throw new Error("Missing signer");
|
|
9
|
-
|
|
9
|
+
let draft = LegacyMessageFactory.create(recipient, message);
|
|
10
|
+
if (options?.expiration)
|
|
11
|
+
draft = draft.expiration(options.expiration);
|
|
12
|
+
const signed = await draft.sign(signer);
|
|
10
13
|
// Get the recipient's inbox relays
|
|
11
14
|
const receiver = castUser(recipient, events);
|
|
12
15
|
const [inboxes, directMessageRelays] = await Promise.all([
|
|
@@ -19,7 +22,7 @@ export function SendLegacyMessage(recipient, message, _opts) {
|
|
|
19
22
|
};
|
|
20
23
|
}
|
|
21
24
|
/** Send a reply to a legacy message */
|
|
22
|
-
export function ReplyToLegacyMessage(parent, message,
|
|
25
|
+
export function ReplyToLegacyMessage(parent, message, options) {
|
|
23
26
|
return async ({ signer, publish, events }) => {
|
|
24
27
|
if (!signer)
|
|
25
28
|
throw new Error("Missing signer");
|
|
@@ -30,7 +33,10 @@ export function ReplyToLegacyMessage(parent, message, _opts) {
|
|
|
30
33
|
const recipient = parent.pubkey === self ? parent.tags.find((t) => t[0] === "p")?.[1] : parent.pubkey;
|
|
31
34
|
if (!recipient)
|
|
32
35
|
throw new Error("Could not determine reply recipient");
|
|
33
|
-
|
|
36
|
+
let draft = LegacyMessageFactory.reply(parent, recipient, message);
|
|
37
|
+
if (options?.expiration)
|
|
38
|
+
draft = draft.expiration(options.expiration);
|
|
39
|
+
const signed = await draft.sign(signer);
|
|
34
40
|
// Get the recipient's inbox relays (the sender of the parent message)
|
|
35
41
|
const receiver = castUser(parent.pubkey, events);
|
|
36
42
|
const [inboxes, directMessageRelays] = await Promise.all([
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "applesauce-actions",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"description": "A package for performing common nostr actions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"applesauce-common": "^6.
|
|
36
|
-
"applesauce-core": "^6.
|
|
35
|
+
"applesauce-common": "^6.1.0",
|
|
36
|
+
"applesauce-core": "^6.1.0",
|
|
37
37
|
"rxjs": "^7.8.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|