Changeset 204bd74 in Klonkt
- Timestamp:
- 06/27/2026 12:28:08 PM (2 months ago)
- Branches:
- main
- Children:
- 0a7ba90
- Parents:
- 04c70fc
- File:
-
- 1 edited
-
src/services/ActivityPubService.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/services/ActivityPubService.js
r04c70fc r204bd74 934 934 function mentionTags(content) { 935 935 const tags = [], seen = new Set(); 936 const re = /<a href="([^"]+)" class="u-url mention">@([^<]+)<\/a>/gi; 936 // The link href is the human profile URL; the actor URI (for the Mention tag) is in data-actor. 937 const re = /<a href="[^"]*" class="u-url mention" data-actor="([^"]+)">@([^<]+)<\/a>/gi; 937 938 let m; 938 939 while ((m = re.exec(content || ''))) { … … 959 960 const inbox = actor && ((actor.endpoints && actor.endpoints.sharedInbox) || actor.inbox); 960 961 if (inbox) inboxes.push(inbox); 962 const profileUrl = actorInfo(actor, actorUri).url || actorUri; // human profile page → the link href 961 963 const esc = h.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); 962 964 out = out.replace(new RegExp('(^|[\\s>])@' + esc + '(?![A-Za-z0-9_.-])', 'g'), 963 (full, pre) => `${pre}<a href="${ actorUri}" class="u-url mention">@${h}</a>`);965 (full, pre) => `${pre}<a href="${profileUrl}" class="u-url mention" data-actor="${actorUri}">@${h}</a>`); 964 966 } 965 967 return { html: out, inboxes }; … … 1005 1007 const mres = await resolveMentionsInText(base, body); // link inline @mentions + collect their inboxes 1006 1008 const mention = parent.actor_uri 1007 ? `<a href="${escHtml(parent.actor_ur i || parent.actor_url)}" class="u-url mention">${escHtml(dispHandle)}</a> ` : '';1009 ? `<a href="${escHtml(parent.actor_url || parent.actor_uri)}" class="u-url mention" data-actor="${escHtml(parent.actor_uri)}">${escHtml(dispHandle)}</a> ` : ''; 1008 1010 const content = `<p>${mention}${linkHashtags(base, mres.html)}</p>`; 1009 1011 // Dedup: skip if the exact same reply was already sent (double-submit guard). … … 1158 1160 if (!base) return false; 1159 1161 const me = actorId(base, site.slug); 1162 const toActor = row.to_actor ? await fetchActor(row.to_actor).catch(() => null) : null; 1163 const toProfile = row.to_actor ? (actorInfo(toActor, row.to_actor).url || row.to_actor) : ''; 1164 const _h = row.to_handle || deriveHandle(row.to_actor); 1165 const toHandle = _h && _h[0] === '@' ? _h : '@' + (_h || ''); 1160 1166 const mention = row.to_actor 1161 ? `<a href="${escHtml( row.to_actor)}" class="u-url mention">${escHtml(row.to_handle || deriveHandle(row.to_actor))}</a> ` : '';1167 ? `<a href="${escHtml(toProfile)}" class="u-url mention" data-actor="${escHtml(row.to_actor)}">${escHtml(toHandle)}</a> ` : ''; 1162 1168 const mres = await resolveMentionsInText(base, escHtml(text).replace(/\r?\n/g, '<br>')); 1163 1169 const content = `<p>${mention}${linkHashtags(base, mres.html)}</p>`; … … 1172 1178 const keys = getOrCreateKeys(site.slug); 1173 1179 const inboxes = new Set(); 1174 if ( row.to_actor) { const a = await fetchActor(row.to_actor).catch(() => null); if (a) inboxes.add((a.endpoints && a.endpoints.sharedInbox) || a.inbox); }1180 if (toActor) inboxes.add((toActor.endpoints && toActor.endpoints.sharedInbox) || toActor.inbox); 1175 1181 for (const f of fStmts().list.all(site.slug)) inboxes.add(f.shared_inbox || f.inbox); 1182 mres.inboxes.forEach((i) => inboxes.add(i)); // people @mentioned inline in the edit 1176 1183 inboxes.delete(`${me}/inbox`); inboxes.delete(`${base}/ap/inbox`); 1177 1184 let delivered = 0;
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)