applesauce-actions 0.0.0-next-20250315140539 → 0.0.0-next-20250323173930
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/dist/actions/__tests__/mute.test.d.ts +1 -0
- package/dist/actions/__tests__/mute.test.js +67 -0
- package/dist/actions/follow-sets.d.ts +30 -2
- package/dist/actions/follow-sets.js +43 -9
- package/dist/actions/index.d.ts +2 -0
- package/dist/actions/index.js +2 -0
- package/dist/actions/mailboxes.d.ts +11 -0
- package/dist/actions/mailboxes.js +66 -0
- package/dist/actions/mute.d.ts +19 -0
- package/dist/actions/mute.js +79 -0
- package/package.json +4 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it } from "vitest";
|
|
2
|
+
import { EventStore } from "applesauce-core";
|
|
3
|
+
import { EventFactory } from "applesauce-factory";
|
|
4
|
+
import { kinds } from "nostr-tools";
|
|
5
|
+
import { getMutedThings, getHiddenMutedThings } from "applesauce-core/helpers";
|
|
6
|
+
import { subscribeSpyTo } from "@hirez_io/observer-spy";
|
|
7
|
+
import { FakeUser } from "../../__tests__/fake-user.js";
|
|
8
|
+
import { ActionHub } from "../../action-hub.js";
|
|
9
|
+
import { MuteThread, UnmuteThread } from "../mute.js";
|
|
10
|
+
const user = new FakeUser();
|
|
11
|
+
const testEventId = "test-event-id";
|
|
12
|
+
let events;
|
|
13
|
+
let factory;
|
|
14
|
+
let hub;
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
events = new EventStore();
|
|
17
|
+
factory = new EventFactory({ signer: user });
|
|
18
|
+
hub = new ActionHub(events, factory);
|
|
19
|
+
// Add a mute list event to work with
|
|
20
|
+
const muteList = user.event({
|
|
21
|
+
kind: kinds.Mutelist,
|
|
22
|
+
tags: [],
|
|
23
|
+
content: "",
|
|
24
|
+
created_at: Math.floor(Date.now() / 1000),
|
|
25
|
+
});
|
|
26
|
+
events.add(muteList);
|
|
27
|
+
});
|
|
28
|
+
describe("MuteThread", () => {
|
|
29
|
+
it("should add an event to public tags in mute list", async () => {
|
|
30
|
+
const spy = subscribeSpyTo(hub.exec(MuteThread, testEventId), { expectErrors: false });
|
|
31
|
+
await spy.onComplete();
|
|
32
|
+
const emittedEvent = spy.getLastValue();
|
|
33
|
+
const mutedThings = getMutedThings(emittedEvent);
|
|
34
|
+
expect(mutedThings.threads).toContain(testEventId);
|
|
35
|
+
});
|
|
36
|
+
it("should add an event to hidden tags in mute list", async () => {
|
|
37
|
+
const spy = subscribeSpyTo(hub.exec(MuteThread, testEventId, true), { expectErrors: false });
|
|
38
|
+
await spy.onComplete();
|
|
39
|
+
const emittedEvent = spy.getLastValue();
|
|
40
|
+
const hiddenMutedThings = await getHiddenMutedThings(emittedEvent);
|
|
41
|
+
expect(hiddenMutedThings?.threads).toContain(testEventId);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
describe("UnmuteThread", () => {
|
|
45
|
+
it("should remove an event from public tags in mute list", async () => {
|
|
46
|
+
// First add the thread to mute list
|
|
47
|
+
const addSpy = subscribeSpyTo(hub.exec(MuteThread, testEventId), { expectErrors: false });
|
|
48
|
+
await addSpy.onComplete();
|
|
49
|
+
// Then unmute it
|
|
50
|
+
const spy = subscribeSpyTo(hub.exec(UnmuteThread, testEventId), { expectErrors: false });
|
|
51
|
+
await spy.onComplete();
|
|
52
|
+
const emittedEvent = spy.getLastValue();
|
|
53
|
+
const mutedThings = getMutedThings(emittedEvent);
|
|
54
|
+
expect(mutedThings.threads).not.toContain(testEventId);
|
|
55
|
+
});
|
|
56
|
+
it("should remove an event from hidden tags in mute list", async () => {
|
|
57
|
+
// First add the thread to hidden mute list
|
|
58
|
+
const addSpy = subscribeSpyTo(hub.exec(MuteThread, testEventId, true), { expectErrors: false });
|
|
59
|
+
await addSpy.onComplete();
|
|
60
|
+
// Then unmute it
|
|
61
|
+
const spy = subscribeSpyTo(hub.exec(UnmuteThread, testEventId, true), { expectErrors: false });
|
|
62
|
+
await spy.onComplete();
|
|
63
|
+
const emittedEvent = spy.getLastValue();
|
|
64
|
+
const hiddenMutedThings = await getHiddenMutedThings(emittedEvent);
|
|
65
|
+
expect(hiddenMutedThings?.threads).not.toContain(testEventId);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
@@ -1,15 +1,43 @@
|
|
|
1
|
+
import { NostrEvent } from "nostr-tools";
|
|
1
2
|
import { Action } from "../action-hub.js";
|
|
3
|
+
import { ProfilePointer } from "nostr-tools/nip19";
|
|
4
|
+
/**
|
|
5
|
+
* An action that creates a new follow set
|
|
6
|
+
* @param identifier the "d" tag of the follow set
|
|
7
|
+
* @param pubkeys the pubkeys to add to the follow set
|
|
8
|
+
* @param hidden set to true to create a hidden follow set
|
|
9
|
+
* @throws if a follow set already exists
|
|
10
|
+
*/
|
|
11
|
+
export declare function CreateFollowSet(title: string, options?: {
|
|
12
|
+
description?: string;
|
|
13
|
+
image?: string;
|
|
14
|
+
public?: (string | ProfilePointer)[];
|
|
15
|
+
hidden?: (string | ProfilePointer)[];
|
|
16
|
+
}): Action;
|
|
2
17
|
/**
|
|
3
18
|
* An action that adds a pubkey to a follow set
|
|
4
19
|
* @param pubkey the pubkey to add to the set
|
|
5
20
|
* @param identifier the "d" tag of the follow set
|
|
6
21
|
* @param hidden set to true to add to hidden follows
|
|
22
|
+
* @throws if the follow set does not exist
|
|
7
23
|
*/
|
|
8
|
-
export declare function AddUserToFollowSet(pubkey: string, identifier: string, hidden?: boolean): Action;
|
|
24
|
+
export declare function AddUserToFollowSet(pubkey: (string | ProfilePointer)[] | string | ProfilePointer, identifier: NostrEvent | string, hidden?: boolean): Action;
|
|
9
25
|
/**
|
|
10
26
|
* An action that removes a pubkey from a follow set
|
|
11
27
|
* @param pubkey the pubkey to remove from the set
|
|
12
28
|
* @param identifier the "d" tag of the follow set
|
|
13
29
|
* @param hidden set to true to remove from hidden follows
|
|
30
|
+
* @throws if the follow set does not exist
|
|
31
|
+
*/
|
|
32
|
+
export declare function RemoveUserFromFollowSet(pubkey: (string | ProfilePointer)[] | string | ProfilePointer, identifier: NostrEvent | string, hidden?: boolean): Action;
|
|
33
|
+
/**
|
|
34
|
+
* An action that updates the title, description, or image of a follow set
|
|
35
|
+
* @param identifier the "d" tag of the follow set
|
|
36
|
+
* @param info the new information for the follow set
|
|
37
|
+
* @throws if the follow set does not exist
|
|
14
38
|
*/
|
|
15
|
-
export declare function
|
|
39
|
+
export declare function UpdateFollowSetInformation(identifier: string, info: {
|
|
40
|
+
title?: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
image?: string;
|
|
43
|
+
}): Action;
|
|
@@ -1,21 +1,43 @@
|
|
|
1
1
|
import { kinds } from "nostr-tools";
|
|
2
2
|
import { addPubkeyTag, removePubkeyTag } from "applesauce-factory/operations/tag";
|
|
3
|
+
import { modifyHiddenTags, modifyPublicTags, setListDescription, setListImage, setListTitle, } from "applesauce-factory/operations/event";
|
|
3
4
|
function getFollowSetEvent(events, self, identifier) {
|
|
4
|
-
|
|
5
|
+
const set = typeof identifier === "string" ? events.getReplaceable(kinds.Followsets, self, identifier) : identifier;
|
|
6
|
+
if (!set)
|
|
7
|
+
throw new Error("Can't find follow set");
|
|
8
|
+
if (set.kind !== kinds.Followsets)
|
|
9
|
+
throw new Error("Event is not a follow set");
|
|
10
|
+
return set;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* An action that creates a new follow set
|
|
14
|
+
* @param identifier the "d" tag of the follow set
|
|
15
|
+
* @param pubkeys the pubkeys to add to the follow set
|
|
16
|
+
* @param hidden set to true to create a hidden follow set
|
|
17
|
+
* @throws if a follow set already exists
|
|
18
|
+
*/
|
|
19
|
+
export function CreateFollowSet(title, options) {
|
|
20
|
+
return async function* ({ factory }) {
|
|
21
|
+
const draft = await factory.build({ kind: kinds.Followsets },
|
|
22
|
+
// set list information
|
|
23
|
+
setListTitle(title), options?.description ? setListDescription(options.description) : undefined, options?.image ? setListImage(options.image) : undefined,
|
|
24
|
+
// add pubkey tags
|
|
25
|
+
options?.public ? modifyPublicTags(...options.public.map((p) => addPubkeyTag(p))) : undefined, options?.hidden ? modifyHiddenTags(...options.hidden.map((p) => addPubkeyTag(p))) : undefined);
|
|
26
|
+
yield await factory.sign(draft);
|
|
27
|
+
};
|
|
5
28
|
}
|
|
6
29
|
/**
|
|
7
30
|
* An action that adds a pubkey to a follow set
|
|
8
31
|
* @param pubkey the pubkey to add to the set
|
|
9
32
|
* @param identifier the "d" tag of the follow set
|
|
10
33
|
* @param hidden set to true to add to hidden follows
|
|
34
|
+
* @throws if the follow set does not exist
|
|
11
35
|
*/
|
|
12
36
|
export function AddUserToFollowSet(pubkey, identifier, hidden = false) {
|
|
13
37
|
return async function* ({ events, factory, self }) {
|
|
14
38
|
const follows = getFollowSetEvent(events, self, identifier);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const operation = addPubkeyTag({ pubkey });
|
|
18
|
-
const draft = await factory.modifyTags(follows, hidden ? { hidden: operation } : operation);
|
|
39
|
+
const operations = Array.isArray(pubkey) ? pubkey.map((p) => addPubkeyTag(p)) : addPubkeyTag(pubkey);
|
|
40
|
+
const draft = await factory.modifyTags(follows, hidden ? { hidden: operations } : operations);
|
|
19
41
|
yield await factory.sign(draft);
|
|
20
42
|
};
|
|
21
43
|
}
|
|
@@ -24,14 +46,26 @@ export function AddUserToFollowSet(pubkey, identifier, hidden = false) {
|
|
|
24
46
|
* @param pubkey the pubkey to remove from the set
|
|
25
47
|
* @param identifier the "d" tag of the follow set
|
|
26
48
|
* @param hidden set to true to remove from hidden follows
|
|
49
|
+
* @throws if the follow set does not exist
|
|
27
50
|
*/
|
|
28
51
|
export function RemoveUserFromFollowSet(pubkey, identifier, hidden = false) {
|
|
29
52
|
return async function* ({ events, factory, self }) {
|
|
30
53
|
const follows = getFollowSetEvent(events, self, identifier);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
54
|
+
const operations = Array.isArray(pubkey) ? pubkey.map((p) => removePubkeyTag(p)) : removePubkeyTag(pubkey);
|
|
55
|
+
const draft = await factory.modifyTags(follows, hidden ? { hidden: operations } : operations);
|
|
56
|
+
yield await factory.sign(draft);
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* An action that updates the title, description, or image of a follow set
|
|
61
|
+
* @param identifier the "d" tag of the follow set
|
|
62
|
+
* @param info the new information for the follow set
|
|
63
|
+
* @throws if the follow set does not exist
|
|
64
|
+
*/
|
|
65
|
+
export function UpdateFollowSetInformation(identifier, info) {
|
|
66
|
+
return async function* ({ events, factory, self }) {
|
|
67
|
+
const follows = getFollowSetEvent(events, self, identifier);
|
|
68
|
+
const draft = await factory.modify(follows, info?.title ? setListTitle(info.title) : undefined, info?.description ? setListDescription(info.description) : undefined, info?.image ? setListImage(info.image) : undefined);
|
|
35
69
|
yield await factory.sign(draft);
|
|
36
70
|
};
|
|
37
71
|
}
|
package/dist/actions/index.d.ts
CHANGED
package/dist/actions/index.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Action } from "../action-hub.js";
|
|
2
|
+
/** An action to create a new kind 10002 relay list event */
|
|
3
|
+
export declare function CreateMailboxes(inboxes: string[], outboxes: string[]): Action;
|
|
4
|
+
/** An action to add an inbox relay to the kind 10002 relay list */
|
|
5
|
+
export declare function AddInboxRelay(relay: string | string[]): Action;
|
|
6
|
+
/** An action to remove an inbox relay from the kind 10002 relay list */
|
|
7
|
+
export declare function RemoveInboxRelay(relay: string | string[]): Action;
|
|
8
|
+
/** An action to add an outbox relay to the kind 10002 relay list */
|
|
9
|
+
export declare function AddOutboxRelay(relay: string | string[]): Action;
|
|
10
|
+
/** An action to remove an outbox relay from the kind 10002 relay list */
|
|
11
|
+
export declare function RemoveOutboxRelay(relay: string | string[]): Action;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { kinds } from "nostr-tools";
|
|
2
|
+
import { addInboxRelay, addOutboxRelay, removeInboxRelay, removeOutboxRelay } from "applesauce-factory/operations/tag";
|
|
3
|
+
import { modifyPublicTags } from "applesauce-factory/operations/event";
|
|
4
|
+
/** An action to create a new kind 10002 relay list event */
|
|
5
|
+
export function CreateMailboxes(inboxes, outboxes) {
|
|
6
|
+
return async function* ({ events, factory, self }) {
|
|
7
|
+
const mailboxes = events.getReplaceable(kinds.RelayList, self);
|
|
8
|
+
if (mailboxes)
|
|
9
|
+
throw new Error("Mailbox event already exists");
|
|
10
|
+
const draft = await factory.build({ kind: kinds.RelayList }, modifyPublicTags(...inboxes.map(addInboxRelay), ...outboxes.map(addOutboxRelay)));
|
|
11
|
+
const signed = await factory.sign(draft);
|
|
12
|
+
yield signed;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/** An action to add an inbox relay to the kind 10002 relay list */
|
|
16
|
+
export function AddInboxRelay(relay) {
|
|
17
|
+
return async function* ({ events, factory, self }) {
|
|
18
|
+
if (typeof relay === "string")
|
|
19
|
+
relay = [relay];
|
|
20
|
+
const mailboxes = events.getReplaceable(kinds.RelayList, self);
|
|
21
|
+
if (!mailboxes)
|
|
22
|
+
throw new Error("Missing mailboxes event");
|
|
23
|
+
const draft = await factory.modifyTags(mailboxes, ...relay.map(addInboxRelay));
|
|
24
|
+
const signed = await factory.sign(draft);
|
|
25
|
+
yield signed;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** An action to remove an inbox relay from the kind 10002 relay list */
|
|
29
|
+
export function RemoveInboxRelay(relay) {
|
|
30
|
+
return async function* ({ events, factory, self }) {
|
|
31
|
+
if (typeof relay === "string")
|
|
32
|
+
relay = [relay];
|
|
33
|
+
const mailboxes = events.getReplaceable(kinds.RelayList, self);
|
|
34
|
+
if (!mailboxes)
|
|
35
|
+
throw new Error("Missing mailboxes event");
|
|
36
|
+
const draft = await factory.modifyTags(mailboxes, ...relay.map(removeInboxRelay));
|
|
37
|
+
const signed = await factory.sign(draft);
|
|
38
|
+
yield signed;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/** An action to add an outbox relay to the kind 10002 relay list */
|
|
42
|
+
export function AddOutboxRelay(relay) {
|
|
43
|
+
return async function* ({ events, factory, self }) {
|
|
44
|
+
if (typeof relay === "string")
|
|
45
|
+
relay = [relay];
|
|
46
|
+
const mailboxes = events.getReplaceable(kinds.RelayList, self);
|
|
47
|
+
if (!mailboxes)
|
|
48
|
+
throw new Error("Missing mailboxes event");
|
|
49
|
+
const draft = await factory.modifyTags(mailboxes, ...relay.map(addOutboxRelay));
|
|
50
|
+
const signed = await factory.sign(draft);
|
|
51
|
+
yield signed;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/** An action to remove an outbox relay from the kind 10002 relay list */
|
|
55
|
+
export function RemoveOutboxRelay(relay) {
|
|
56
|
+
return async function* ({ events, factory, self }) {
|
|
57
|
+
if (typeof relay === "string")
|
|
58
|
+
relay = [relay];
|
|
59
|
+
const mailboxes = events.getReplaceable(kinds.RelayList, self);
|
|
60
|
+
if (!mailboxes)
|
|
61
|
+
throw new Error("Missing mailboxes event");
|
|
62
|
+
const draft = await factory.modifyTags(mailboxes, ...relay.map(removeOutboxRelay));
|
|
63
|
+
const signed = await factory.sign(draft);
|
|
64
|
+
yield signed;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { NostrEvent } from "nostr-tools";
|
|
2
|
+
import { EventPointer } from "nostr-tools/nip19";
|
|
3
|
+
import { Action } from "../action-hub.js";
|
|
4
|
+
/** An action that adds a pubkey to the mute list */
|
|
5
|
+
export declare function MuteUser(pubkey: string, hidden?: boolean): Action;
|
|
6
|
+
/** Removes a pubkey from the mute list */
|
|
7
|
+
export declare function UnmuteUser(pubkey: string, hidden?: boolean): Action;
|
|
8
|
+
/** Add a thread to the mute list */
|
|
9
|
+
export declare function MuteThread(thread: string | NostrEvent | EventPointer, hidden?: boolean): Action;
|
|
10
|
+
/** Removes a thread from the mute list */
|
|
11
|
+
export declare function UnmuteThread(thread: string | NostrEvent | EventPointer, hidden?: boolean): Action;
|
|
12
|
+
/** Add a word to the mute list */
|
|
13
|
+
export declare function MuteWord(word: string, hidden?: boolean): Action;
|
|
14
|
+
/** Removes a word from the mute list */
|
|
15
|
+
export declare function UnmuteWord(word: string, hidden?: boolean): Action;
|
|
16
|
+
/** Add a hashtag to the mute list */
|
|
17
|
+
export declare function MuteHashtag(hashtag: string, hidden?: boolean): Action;
|
|
18
|
+
/** Removes a hashtag from the mute list */
|
|
19
|
+
export declare function UnmuteHashtag(hashtag: string, hidden?: boolean): Action;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { addEventTag, addNameValueTag, addPubkeyTag, removeEventTag, removeNameValueTag, removePubkeyTag, } from "applesauce-factory/operations/tag";
|
|
2
|
+
import { kinds } from "nostr-tools";
|
|
3
|
+
function ensureMuteList(events, self) {
|
|
4
|
+
const mute = events.getReplaceable(kinds.Mutelist, self);
|
|
5
|
+
if (!mute)
|
|
6
|
+
throw new Error("No mute list found");
|
|
7
|
+
return mute;
|
|
8
|
+
}
|
|
9
|
+
/** An action that adds a pubkey to the mute list */
|
|
10
|
+
export function MuteUser(pubkey, hidden = false) {
|
|
11
|
+
return async function* ({ events, factory, self }) {
|
|
12
|
+
const mute = ensureMuteList(events, self);
|
|
13
|
+
const operation = addPubkeyTag(pubkey);
|
|
14
|
+
const draft = await factory.modifyTags(mute, hidden ? { hidden: operation } : operation);
|
|
15
|
+
yield await factory.sign(draft);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/** Removes a pubkey from the mute list */
|
|
19
|
+
export function UnmuteUser(pubkey, hidden = false) {
|
|
20
|
+
return async function* ({ events, factory, self }) {
|
|
21
|
+
const mute = ensureMuteList(events, self);
|
|
22
|
+
const draft = await factory.modifyTags(mute, hidden ? { hidden: removePubkeyTag(pubkey) } : removePubkeyTag(pubkey));
|
|
23
|
+
yield await factory.sign(draft);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/** Add a thread to the mute list */
|
|
27
|
+
export function MuteThread(thread, hidden = false) {
|
|
28
|
+
return async function* ({ events, factory, self }) {
|
|
29
|
+
const mute = ensureMuteList(events, self);
|
|
30
|
+
const operation = addEventTag(thread);
|
|
31
|
+
const draft = await factory.modifyTags(mute, hidden ? { hidden: operation } : operation);
|
|
32
|
+
yield await factory.sign(draft);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** Removes a thread from the mute list */
|
|
36
|
+
export function UnmuteThread(thread, hidden = false) {
|
|
37
|
+
return async function* ({ events, factory, self }) {
|
|
38
|
+
const mute = ensureMuteList(events, self);
|
|
39
|
+
const operation = removeEventTag(thread);
|
|
40
|
+
const draft = await factory.modifyTags(mute, hidden ? { hidden: operation } : operation);
|
|
41
|
+
yield await factory.sign(draft);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** Add a word to the mute list */
|
|
45
|
+
export function MuteWord(word, hidden = false) {
|
|
46
|
+
return async function* ({ events, factory, self }) {
|
|
47
|
+
const mute = ensureMuteList(events, self);
|
|
48
|
+
const operation = addNameValueTag(["word", word.toLocaleLowerCase()], true);
|
|
49
|
+
const draft = await factory.modifyTags(mute, hidden ? { hidden: operation } : operation);
|
|
50
|
+
yield await factory.sign(draft);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** Removes a word from the mute list */
|
|
54
|
+
export function UnmuteWord(word, hidden = false) {
|
|
55
|
+
return async function* ({ events, factory, self }) {
|
|
56
|
+
const mute = ensureMuteList(events, self);
|
|
57
|
+
const operation = removeNameValueTag(["word", word.toLocaleLowerCase()]);
|
|
58
|
+
const draft = await factory.modifyTags(mute, hidden ? { hidden: operation } : operation);
|
|
59
|
+
yield await factory.sign(draft);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/** Add a hashtag to the mute list */
|
|
63
|
+
export function MuteHashtag(hashtag, hidden = false) {
|
|
64
|
+
return async function* ({ events, factory, self }) {
|
|
65
|
+
const mute = ensureMuteList(events, self);
|
|
66
|
+
const operation = addNameValueTag(["t", hashtag.toLocaleLowerCase()], true);
|
|
67
|
+
const draft = await factory.modifyTags(mute, hidden ? { hidden: operation } : operation);
|
|
68
|
+
yield await factory.sign(draft);
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/** Removes a hashtag from the mute list */
|
|
72
|
+
export function UnmuteHashtag(hashtag, hidden = false) {
|
|
73
|
+
return async function* ({ events, factory, self }) {
|
|
74
|
+
const mute = ensureMuteList(events, self);
|
|
75
|
+
const operation = removeNameValueTag(["t", hashtag.toLocaleLowerCase()]);
|
|
76
|
+
const draft = await factory.modifyTags(mute, hidden ? { hidden: operation } : operation);
|
|
77
|
+
yield await factory.sign(draft);
|
|
78
|
+
};
|
|
79
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "applesauce-actions",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20250323173930",
|
|
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.0.0-next-
|
|
43
|
+
"applesauce-signers": "0.0.0-next-20250323173930",
|
|
44
44
|
"nanoid": "^5.0.9",
|
|
45
45
|
"typescript": "^5.7.3",
|
|
46
46
|
"vitest": "^3.0.5"
|