mirror of
https://github.com/svemagie/indiekit-endpoint-activitypub.git
synced 2026-04-02 15:44:58 +02:00
fix: use getTags() async iterator and instanceof checks for Mention/Hashtag
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user