-
Notifications
You must be signed in to change notification settings - Fork 124
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
Issue #213 - UI - Initial support for ActivityPub comments #218
Issue #213 - UI - Initial support for ActivityPub comments #218
Conversation
This commit introduces initial support for showing comments. It relies on the API also including socialInteracts and on a new API on the server being implemented to fetch the comments. This is not yet ready, I have implemented some mock code on the server side that is not included in this commit. The front-end code expects the comments API to respond with the same format as podverse's /api/v1/episode/{episodeid}/proxy/activity-pub Related issues: - resolves Podcastindex-org#213 - Podcastindex-org#213
Additional server side code I'm using at const fakeCommentsResponse = require('./fake-comments-response.json') app.use('/api/episodes/byfeedid', async (req, res) => {
let feedId = req.query.id
let max = req.query.max
const response = await api.episodesByFeedId(feedId, null, max)
// Injects fake socialInteract content here for testing
response.items.forEach((item) => {
item.socialInteracts = [{
uri: 'https://podcastindex.social/users/dave/statuses/109683341113064081',
protocol: 'activitypub',
}]
})
res.send(response)
}) // ------------------------------------------------
// ------------ API to get comments for episode ---
// ------------------------------------------------
app.use('/api/comments/byepisodeid', async (req, res) => {
let feedUrl = req.query.url
// fakeCommentsResponse was taken directly from the API used by podverse
res.send(fakeCommentsResponse)
}) For |
Added button to open on external source, and did some minor Ui changes.
@daveajones, we'll need to sanitize the content of the comments, do you have any library recommendations? |
Threadcap doesn't sanitize? |
This commit introduces the functionality of fetching comments on the server using threadcap through the API `/api/comments/byepisodeid?id={episode id}`. it currently fetches as comments and replies, and wait untill all comments are fetched. It takes some time (circa 7s during my tests). With this commit two new dependencies were introduced. Additionally, error handling was added for possible fetch issues for comments and replies (which were detected during tests)
@daveajones I'm not sure, but I am assuming it doesn't. I could not find information indicating whether it does or does not on the documentation. I asked @johnspurlock-skymethod, see skymethod/minipub#5 and https://fosstodon.org/@dellagustin/109771551290816322. Now that's the server is doing requests to 3rd party servers, we should define a user agent. Do you have any preferences on this one? I'll move forward with missing pieces, but soon it will be blocked only by Podcastindex-org/docs-api#91. Could you do a "call to action" for the community to contribute on the "beautification" part? Maybe on the next Podcasting 2.0 episode? This is a part were I'm very weak. |
I will 100% do a call out on the next board meeting. For user agent I typically use Podcastindex.org/v1.x so maybe something like: Podcastindex.org-web/v1.0 ? |
I recommend DOMPurify NPM module for sanitizing. I have been using it in my project "Quanta" for a while. |
One current limitation, I'm only taking into account English language content. threadcap returns the content of the comments as language-tagged strings: "content": {
"en": "content in English"
} I'm currently hardcoding to English. Note that the content on the Activity is not always language-tagged, and when it is, this is under the property e.g.: "content": "content in English",
"contentMap": {
"en": "content in English"
}, I was remembered about this when testing with a reply from a different account where it is not set to English (simplified example below): {
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://blob.cat/schemas/litepub-0.1.jsonld",
{
"@language": "und"
}
],
"content": "Content in und",
} Note that in the absence of a |
Sounds good to me. Is it ok if I read the version from |
@nathangathright my mouse pointer is going a bit haywire on the clickable elements of the UI at the current version, but it may be a codepen thing, let's see if it happens when I implement it in PI. |
So an expectation management message: as you can see, the To Do list is packed. What I did so far was during a "time multiplexing window" that I dedicate to this project, now I have to do the same to other projects 😄 . Also, I have the feeling we are at a "80% of the functionality with 20% of the effor" point. In other words, what is left may take more time than you would expect to be ready. I'm guessing something like 4 weeks with me "multiplexing" between projects and life. Let's see. |
Just for you Guilherme, this morning I added |
@dellagustin Yeah, I’ve pushed an updated code to a stand-alone repo with GitHub Pages so you can see the behavior without CodePen’s interference. Additionally, I’ve mocked up what Summarized/Content Warnings could look like. |
Yeah, that’s fine. Just replace that custom element with the HTML5 standard |
@johnspurlock-skymethod , @nathangathright you both have to slow down on your great and timely contributions, it is making me look bad 😛. |
@nathangathright , one note about the Content Warning, event though that the semantic for summary used by (at least) Mastodon and Pleroma, they show this in a very "neutral" way, meaning: they call it Content Warning when your are editing, but they don't refer to it when they are showing it, they just hide the content under a Show More/Show Content user interaction. Screenshots below. |
…_show-episode-comments
…odStation/podcastindex-web-ui into enhancement#213__show-episode-comments
Testing with threadcap v0.1.10 showed a regression, reported with skymethod/minipub#7. |
This commit adds support for the `summary` property, which is normally used also as _content warning_.
@nathangathright , I just implemented the support for |
This commit solves a react warning due to missing key on list elements. It uses the comment url as key, as there it no expectation that the same comment will appear twice in the same replies list.
f021d51
to
22f868b
Compare
I have been thinking about how stream back the comments processed by threadcap to the front-end, so that the user does not need to wait for the threadcap to finish its work to start seeing comments. The idea is to use the threadcap callback and send back a JSON with new nodes and and commenters each time there is a |
Indication that comments are loading is there: |
@dellagustin The CSS for the summary element didn't account for display names + handles + long timestamps. Adding But I’ve gone a bit further and pushed an update to my little repo with stacked name and handles on desktop and hiding the handles on mobile. (I still think handles are unnecessary given that you can click through to the original profile to verify anyone’s identity.) |
Hello @nathangathright , thank you for the changes. I can see they work well in your standalone mock up, but when I implemented them inside the podcast index, it still overflows, here is a screenshot: |
Fixed it by adding width: 100% to an outer div I added with the comments section. |
As Podcastindex-org/docs-api#91 is now implemented, this commit replaces the hard coded comment uri by the content of the socialInteract property from the podcast index API. Note: even though the spec does not forbid two socialInteracts with the same protocol, this implementation only takes the first one. If we see use cases for supporting both, then we will need to update later.
This commits add sanitization using for comments summary and content using DOMPurify. To test it, I faked the response of `/api/comments/byepisodeid` with a hard coded json file containing in the content of comments some examples from the section "Some purification samples please?". References: - https://www.npmjs.com/package/dompurify
Updated yarn.lock. There are a lot of changes, but the versions there do not look like they were drastically changed. I'm assuming some changes are related to using a newer yarn version, in my case, 3.4.1.
Content sanitization added with 07207d2 using DOMPurify. To test it, I faked the response of References: |
@daveajones , ready for review 🎉 . |
This commit introduces initial support for showing comments. It relies on the API also including socialInteracts and on a new API on the server being implemented to fetch the comments.
This is not yet ready, I have implemented some mock code on the server side that is not included in this commit.The front-end code expects the comments API to respond with the same format as podverse's
/api/v1/episode/{episodeid}/proxy/activity-pub
, which is exactly what is returned by threadcap.To Do
summary
(stretch goal)- see Issue #213 - UI - Initial support for ActivityPub comments #218 (comment) - done with 094393dLimitations
Performance
When this PR is ready for merge, it will still be limited to fetching all comments in a single shot, and the UI will wait until they are all fetched, which can take some time.
A potential improvement would be some kind of "long pooling", where the server sends partial updates back each time a new comment is fetched. This way the UI could be progressively updated. Maybe this can be achieved with https://developer.mozilla.org/en-US/docs/Web/API/Streams_API/Using_readable_streams.
I have created an issue to track this future improvement: #228
Summary / Content warning
The property
summary
is not taken into account, which is returned by Pleroma and Mastodon posts as a Content warning (e.g. to avoid spoilers).This is, to my best knowledge, also a limitation of threadcap (see skymethod/minipub#6), not anymore, see #218 (comment). I set this now as a stretch goal, could be easily added later in a compatible way with a separate PR, if this one is dragging too long.Attachments
Attachments are currently not shown (e.g. attached images).
I have created an issue to track this future improvement: #229.
Scaling
As all the API calls are going out from the same IP, if many users are checking comments in parallel, they could reach the instances' rate limit. For instance, the default for Mastodon instances is 300 calls within 5 mins (mastodon rate limits).
Related issues
Dependencies
Links and References