applesauce-core 3.0.1 → 3.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.
package/dist/helpers/groups.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getOrComputeCachedValue } from "./cache.js";
|
|
2
2
|
import { getHiddenTags } from "./hidden-tags.js";
|
|
3
3
|
import { processTags } from "./tags.js";
|
|
4
|
+
import { normalizeURL } from "./url.js";
|
|
4
5
|
export const GROUPS_LIST_KIND = 10009;
|
|
5
6
|
export const GROUP_MESSAGE_KIND = 9;
|
|
6
7
|
/**
|
|
@@ -14,6 +15,8 @@ export function decodeGroupPointer(str) {
|
|
|
14
15
|
// Prepend wss:// if missing
|
|
15
16
|
if (!relay.match(/^wss?:/))
|
|
16
17
|
relay = `wss://${relay}`;
|
|
18
|
+
// Normalize the relay url
|
|
19
|
+
relay = normalizeURL(relay);
|
|
17
20
|
return { relay, id: id || "_" };
|
|
18
21
|
}
|
|
19
22
|
/** Converts a group pointer into a group identifier */
|
|
@@ -7,6 +7,13 @@ export declare function isLegacyMessageLocked(event: NostrEvent): boolean;
|
|
|
7
7
|
* @throws if no corraspondant is found
|
|
8
8
|
*/
|
|
9
9
|
export declare function getLegacyMessageCorraspondant(message: NostrEvent, self: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Returns the receiver of a legacy direct message
|
|
12
|
+
* @throws if no receiver is found
|
|
13
|
+
*/
|
|
14
|
+
export declare const getLegacyMessageReceiver: typeof getLegacyMessageCorraspondant;
|
|
15
|
+
/** Returns the sender of a legacy direct message */
|
|
16
|
+
export declare function getLegacyMessageSender(message: NostrEvent): string;
|
|
10
17
|
/** Returns the parent message id of a legacy message */
|
|
11
18
|
export declare function getLegacyMessageParent(message: NostrEvent): string | undefined;
|
|
12
19
|
/**
|
|
@@ -14,6 +14,15 @@ export function getLegacyMessageCorraspondant(message, self) {
|
|
|
14
14
|
throw new Error("No corraspondant found");
|
|
15
15
|
return corraspondant;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Returns the receiver of a legacy direct message
|
|
19
|
+
* @throws if no receiver is found
|
|
20
|
+
*/
|
|
21
|
+
export const getLegacyMessageReceiver = getLegacyMessageCorraspondant;
|
|
22
|
+
/** Returns the sender of a legacy direct message */
|
|
23
|
+
export function getLegacyMessageSender(message) {
|
|
24
|
+
return message.pubkey;
|
|
25
|
+
}
|
|
17
26
|
/** Returns the parent message id of a legacy message */
|
|
18
27
|
export function getLegacyMessageParent(message) {
|
|
19
28
|
return getTagValue(message, "e");
|
|
@@ -3,3 +3,10 @@ import { Rumor } from "./gift-wraps.js";
|
|
|
3
3
|
export declare function getWrappedMessageSubject(message: Rumor): string | undefined;
|
|
4
4
|
/** Returns the parent id of a wrapped direct message */
|
|
5
5
|
export declare function getWrappedMessageParent(message: Rumor): string | undefined;
|
|
6
|
+
/** Returns the sender of a wrapped direct message */
|
|
7
|
+
export declare function getWrappedMesssageSender(message: Rumor): string;
|
|
8
|
+
/**
|
|
9
|
+
* Returns the frist participant in a conversation that is not the sender
|
|
10
|
+
* @see getConversationParticipants
|
|
11
|
+
*/
|
|
12
|
+
export declare function getWrappedMessageReceiver(message: Rumor): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getTagValue } from "./index.js";
|
|
1
|
+
import { getConversationParticipants, getTagValue } from "./index.js";
|
|
2
2
|
/** Returns the subject of a warpped direct message */
|
|
3
3
|
export function getWrappedMessageSubject(message) {
|
|
4
4
|
return getTagValue(message, "subject");
|
|
@@ -7,3 +7,14 @@ export function getWrappedMessageSubject(message) {
|
|
|
7
7
|
export function getWrappedMessageParent(message) {
|
|
8
8
|
return getTagValue(message, "e");
|
|
9
9
|
}
|
|
10
|
+
/** Returns the sender of a wrapped direct message */
|
|
11
|
+
export function getWrappedMesssageSender(message) {
|
|
12
|
+
return message.pubkey;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Returns the frist participant in a conversation that is not the sender
|
|
16
|
+
* @see getConversationParticipants
|
|
17
|
+
*/
|
|
18
|
+
export function getWrappedMessageReceiver(message) {
|
|
19
|
+
return getConversationParticipants(message).filter((p) => p !== message.pubkey)[0];
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "applesauce-core",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"hash-sum": "^2.0.0",
|
|
65
65
|
"light-bolt11-decoder": "^3.2.0",
|
|
66
66
|
"nanoid": "^5.0.9",
|
|
67
|
-
"nostr-tools": "
|
|
67
|
+
"nostr-tools": "~2.15",
|
|
68
68
|
"rxjs": "^7.8.1"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|