applesauce-actions 0.0.0-next-20250315140539 → 0.12.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,15 +1,17 @@
|
|
|
1
|
+
import { NostrEvent } from "nostr-tools";
|
|
1
2
|
import { Action } from "../action-hub.js";
|
|
3
|
+
import { ProfilePointer } from "nostr-tools/nip19";
|
|
2
4
|
/**
|
|
3
5
|
* An action that adds a pubkey to a follow set
|
|
4
6
|
* @param pubkey the pubkey to add to the set
|
|
5
7
|
* @param identifier the "d" tag of the follow set
|
|
6
8
|
* @param hidden set to true to add to hidden follows
|
|
7
9
|
*/
|
|
8
|
-
export declare function AddUserToFollowSet(pubkey: string, identifier: string, hidden?: boolean): Action;
|
|
10
|
+
export declare function AddUserToFollowSet(pubkey: string | ProfilePointer, identifier: NostrEvent | string, hidden?: boolean): Action;
|
|
9
11
|
/**
|
|
10
12
|
* An action that removes a pubkey from a follow set
|
|
11
13
|
* @param pubkey the pubkey to remove from the set
|
|
12
14
|
* @param identifier the "d" tag of the follow set
|
|
13
15
|
* @param hidden set to true to remove from hidden follows
|
|
14
16
|
*/
|
|
15
|
-
export declare function RemoveUserFromFollowSet(pubkey: string, identifier: string, hidden?: boolean): Action;
|
|
17
|
+
export declare function RemoveUserFromFollowSet(pubkey: string | ProfilePointer, identifier: NostrEvent | string, hidden?: boolean): Action;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { kinds } from "nostr-tools";
|
|
2
2
|
import { addPubkeyTag, removePubkeyTag } from "applesauce-factory/operations/tag";
|
|
3
3
|
function getFollowSetEvent(events, self, identifier) {
|
|
4
|
-
|
|
4
|
+
const set = typeof identifier === "string" ? events.getReplaceable(kinds.Followsets, self, identifier) : identifier;
|
|
5
|
+
if (!set)
|
|
6
|
+
throw new Error("Can't find follow set");
|
|
7
|
+
if (set.kind !== kinds.Followsets)
|
|
8
|
+
throw new Error("Event is not a follow set");
|
|
9
|
+
return set;
|
|
5
10
|
}
|
|
6
11
|
/**
|
|
7
12
|
* An action that adds a pubkey to a follow set
|
|
@@ -12,9 +17,7 @@ function getFollowSetEvent(events, self, identifier) {
|
|
|
12
17
|
export function AddUserToFollowSet(pubkey, identifier, hidden = false) {
|
|
13
18
|
return async function* ({ events, factory, self }) {
|
|
14
19
|
const follows = getFollowSetEvent(events, self, identifier);
|
|
15
|
-
|
|
16
|
-
throw new Error("Can't find follow set");
|
|
17
|
-
const operation = addPubkeyTag({ pubkey });
|
|
20
|
+
const operation = addPubkeyTag(pubkey);
|
|
18
21
|
const draft = await factory.modifyTags(follows, hidden ? { hidden: operation } : operation);
|
|
19
22
|
yield await factory.sign(draft);
|
|
20
23
|
};
|
|
@@ -28,8 +31,6 @@ export function AddUserToFollowSet(pubkey, identifier, hidden = false) {
|
|
|
28
31
|
export function RemoveUserFromFollowSet(pubkey, identifier, hidden = false) {
|
|
29
32
|
return async function* ({ events, factory, self }) {
|
|
30
33
|
const follows = getFollowSetEvent(events, self, identifier);
|
|
31
|
-
if (!follows)
|
|
32
|
-
throw new Error("Can't find follow set");
|
|
33
34
|
const operation = removePubkeyTag(pubkey);
|
|
34
35
|
const draft = await factory.modifyTags(follows, hidden ? { hidden: operation } : operation);
|
|
35
36
|
yield await factory.sign(draft);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "applesauce-actions",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "A package for performing common nostr actions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -32,15 +32,15 @@
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"applesauce-core": "0.
|
|
36
|
-
"applesauce-factory": "0.
|
|
35
|
+
"applesauce-core": "^0.12.0",
|
|
36
|
+
"applesauce-factory": "^0.12.0",
|
|
37
37
|
"nostr-tools": "^2.10.4",
|
|
38
38
|
"rxjs": "^7.8.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@hirez_io/observer-spy": "^2.2.0",
|
|
42
42
|
"@types/debug": "^4.1.12",
|
|
43
|
-
"applesauce-signers": "0.
|
|
43
|
+
"applesauce-signers": "^0.12.0",
|
|
44
44
|
"nanoid": "^5.0.9",
|
|
45
45
|
"typescript": "^5.7.3",
|
|
46
46
|
"vitest": "^3.0.5"
|