diff --git a/.gitignore b/.gitignore
index e94357d..8188480 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,5 @@ node_modules
.sqlite_history
*.patch
request_logs.txt
-.DS_Store
\ No newline at end of file
+.DS_Store
+account.json
diff --git a/src/activitypub.js b/src/activitypub.js
index 86eaff1..3c1b453 100644
--- a/src/activitypub.js
+++ b/src/activitypub.js
@@ -48,8 +48,9 @@ export function createNoteObject(bookmark, account, domain) {
.join(' ');
}
+ let escapedDescription = '';
if (updatedBookmark.description?.trim().length > 0) {
- updatedBookmark.description = `
${updatedBookmark.description?.trim().replace('\n', '
') || ''}`;
+ escapedDescription = `
${updatedBookmark.description?.trim().replace('\n', '
') || ''}`;
}
if (linkedTags.trim().length > 0) {
@@ -57,17 +58,29 @@ export function createNoteObject(bookmark, account, domain) {
}
const noteMessage = {
- '@context': 'https://www.w3.org/ns/activitystreams',
+ '@context': ['https://www.w3.org/ns/activitystreams', { Hashtag: 'https://www.w3.org/ns/activitystreams#Hashtag' }],
id: `https://${domain}/m/${guidNote}`,
type: 'Note',
published: d.toISOString(),
attributedTo: `https://${domain}/u/${account}`,
+ name: updatedBookmark.title,
content: `
${replaceEmptyText( updatedBookmark.title, updatedBookmark.url, - )}${updatedBookmark.description}
${linkedTags}`, + )}${escapedDescription}${linkedTags}`, to: [`https://${domain}/u/${account}/followers/`, 'https://www.w3.org/ns/activitystreams#Public'], tag: [], + url: `https://${domain}/bookmark/${updatedBookmark.id}`, + source: { + content: updatedBookmark.description, + mediaType: 'text/plain', + }, + attachment: [ + { + type: 'Link', + href: updatedBookmark.url, + }, + ], }; bookmark.tags?.split(' ').forEach((tag) => { @@ -262,7 +275,8 @@ export async function broadcastMessage(bookmark, action, db, account, domain) { // eslint-disable-next-line no-restricted-syntax for (const follower of followers) { - const inbox = `${follower}/inbox`; + console.log(`Sending to ${follower}...`); + const inbox = await getInboxFromActorProfile(follower); const myURL = new URL(follower); const targetDomain = myURL.host; signAndSend(message, account, domain, db, targetDomain, inbox); diff --git a/src/signature.js b/src/signature.js index 7c79f4b..77aa2e8 100644 --- a/src/signature.js +++ b/src/signature.js @@ -74,7 +74,7 @@ function getSignatureParams(body, method, url) { */ function getSignatureHeader(signature, signatureKeys) { return [ - `keyId="https://${domain}/u/${account}"`, + `keyId="https://${domain}/u/${account}#main-key"`, `algorithm="rsa-sha256"`, `headers="${signatureKeys.join(' ')}"`, `signature="${signature}"`,