ckolderup / postmarks

a single-user bookmarking website designed to live on the Fediverse
https://postmarks.glitch.me
MIT License
467 stars 38 forks source link

Replies to bookmarks not being stored in database #141

Closed jeffsikes closed 1 year ago

jeffsikes commented 1 year ago

Hi! Really enjoying this platform and it's been a great way to learn more about ActivityPub.

When someone replies to my bookmark post, I noticed I wasn't getting any comments in the approval section. In fact, they weren't getting added at all.

No one else has mentioned this, but I've searched through other postmarkie sites and I don't see any publicly approved comments, at least.

After some debugging, I found that the ActvitiyPub inbox received the replies, but it was returning the response “couldn't find a bookmark this message is related to”.

This is what I found.

In the ActivityPub SqlLite database, the Guids were getting saved with the "m/" part of the url path along with the Guid in the messages.guid column. For example, m/ebff578a49b2095e94e8aa64c4c5d347

When a new comment comes in, it wasn't looking for the "m/" part and therefore failing to find the related post and get attached to.

It came down to this regex pattern in the src/activitypub.js file. When I updated it, new bookmarks now get saved excluding the “m/“, and the replies are matching to an entry and applied correctly. Below is the updated version.

https://github.com/ckolderup/postmarks/blob/d1e24bd0ec514376ccf8e1064c075ddff92cf531/src/activitypub.js#L8

The updated version:

function getGuidFromPermalink(urlString) {

return urlString.match(/(?:\/m\/)([a-zA-Z0-9+/]+)/)[1];

}

I've made this change and will attach this issue to the pull request.

ckolderup commented 1 year ago

fixed by #142.