feat: support content warning

This commit is contained in:
reya
2024-06-21 08:57:49 +07:00
parent 4f0f210076
commit 59eaaec903
2 changed files with 54 additions and 12 deletions

View File

@@ -25,11 +25,6 @@ export class LumeEvent {
Object.assign(this, event);
}
get isWarning() {
const tag = this.tags.find((tag) => tag[0] === "content-warning");
return tag?.[1]; // return: reason;
}
get isQuote() {
return this.tags.filter((tag) => tag[0] === "q").length > 0;
}
@@ -95,6 +90,26 @@ export class LumeEvent {
return { id, relayHint };
}
get warning() {
const warningTag = this.tags.filter(
(tag) => tag[0] === "content-warning",
)?.[0];
if (warningTag) {
return warningTag[1];
} else {
const nsfwTag = this.tags.filter(
(tag) => tag[0] === "t" && tag[1] === "NSFW",
)?.[0];
if (nsfwTag) {
return "NSFW";
} else {
return null;
}
}
}
public async getAllReplies() {
const query = await commands.getReplies(this.id);