-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnostr-util.mjs
43 lines (39 loc) · 1.03 KB
/
nostr-util.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
export const extractHashtags = (tags) => {
return tags.filter(tag => String(tag[0]) === "t").map(tag => String(tag[1]));
}
export const isActivityPubUser = (tags) => {
for (let index = 0; index < tags.length; index++) {
const tag = tags[index];
if (tag.length === 3 && String(tag[0]) === "proxy" && String(tag[2]) === "activitypub") {
return true;
}
}
return false;
}
export const isRootPost = (tags) => {
for (let index = 0; index < tags.length; index++) {
const tag = tags[index];
if (String(tag[0]) === "e") {
return false;
}
}
return true;
}
export const hasContentWarning = (tags) => {
for (let index = 0; index < tags.length; index++) {
const tag = tags[index];
if (String(tag[0]) === "content-warning") {
return true;
}
}
return false;
}
export const hasNsfwHashtag = (hashtags) => {
for (let index = 0; index < hashtags.length; index++) {
const tag = String(hashtags[index]).toLowerCase();
if (tag === "nsfw") {
return true;
}
}
return false;
}