-
Notifications
You must be signed in to change notification settings - Fork 44
Adjust ActivityPub bookmark representation to match Betula #219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,4 +7,5 @@ node_modules | |
| .sqlite_history | ||
| *.patch | ||
| request_logs.txt | ||
| .DS_Store | ||
| .DS_Store | ||
| account.json | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,26 +48,39 @@ export function createNoteObject(bookmark, account, domain) { | |
| .join(' '); | ||
| } | ||
|
|
||
| let escapedDescription = ''; | ||
| if (updatedBookmark.description?.trim().length > 0) { | ||
| updatedBookmark.description = `<br/>${updatedBookmark.description?.trim().replace('\n', '<br/>') || ''}`; | ||
| escapedDescription = `<br/>${updatedBookmark.description?.trim().replace('\n', '<br/>') || ''}`; | ||
| } | ||
|
|
||
| if (linkedTags.trim().length > 0) { | ||
| linkedTags = `<p>${linkedTags}</p>`; | ||
| } | ||
|
|
||
| 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: `<p><strong><a href="${updatedBookmark.url}" rel="nofollow noopener noreferrer">${replaceEmptyText( | ||
| updatedBookmark.title, | ||
| updatedBookmark.url, | ||
| )}</a></strong>${updatedBookmark.description}</p>${linkedTags}`, | ||
| )}</a></strong>${escapedDescription}</p>${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); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You took a shortcut here, which made sense, but the old logic failed for some servers such as Betula. Some form of caching would make sense, but I didn't find a db table with remote actors. |
||
| const myURL = new URL(follower); | ||
| const targetDomain = myURL.host; | ||
| signAndSend(message, account, domain, db, targetDomain, inbox); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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"`, | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did it work before? It shouldn't have. |
||
| `algorithm="rsa-sha256"`, | ||
| `headers="${signatureKeys.join(' ')}"`, | ||
| `signature="${signature}"`, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For formal correctness. Practical implementations often ignore JSON-LD contexts, but some of them don't.