fix: use getTags() async iterator and instanceof checks for Mention/Hashtag

This commit is contained in:
svemagie
2026-03-13 06:59:27 +01:00
parent e18d61d951
commit 4b4faea52f

View File

@@ -14,7 +14,9 @@ import {
Create,
Delete,
Follow,
Hashtag,
Like,
Mention,
Move,
Note,
Reject,
@@ -450,8 +452,7 @@ export function registerInboxListeners(inboxChain, options) {
}
// Check for mentions of our actor
if (object.tag) {
const tags = Array.isArray(object.tag) ? object.tag : [object.tag];
{
const ourActorUrl = ctx.getActorUri(handle).href;
// Detect direct/private visibility: no public collection in `to` or `cc`
@@ -462,8 +463,8 @@ export function registerInboxListeners(inboxChain, options) {
!toHrefs.includes(PUBLIC_COLLECTION) &&
!ccHrefs.includes(PUBLIC_COLLECTION);
for (const tag of tags) {
if (tag.type === "Mention" && tag.href?.href === ourActorUrl) {
for await (const tag of object.getTags()) {
if (tag instanceof Mention && tag.href?.href === ourActorUrl) {
const actorInfo = await extractActorInfo(actorObj, { documentLoader: authLoader });
const rawMentionHtml = object.content?.toString() || "";
const mentionHtml = sanitizeContent(rawMentionHtml);
@@ -525,10 +526,12 @@ export function registerInboxListeners(inboxChain, options) {
// Not a followed account — check if the post's hashtags match any followed tags
// so tagged posts from across the fediverse appear in the timeline
try {
const objectTags = Array.isArray(object.tag) ? object.tag : (object.tag ? [object.tag] : []);
const postHashtags = objectTags
.filter((t) => t.type === "Hashtag" && t.name)
.map((t) => t.name.toString().replace(/^#/, "").toLowerCase());
const postHashtags = [];
for await (const t of object.getTags()) {
if (t instanceof Hashtag && t.name) {
postHashtags.push(t.name.toString().replace(/^#/, "").toLowerCase());
}
}
if (postHashtags.length > 0) {
const followedTags = await getFollowedTags(collections);