Skip to content
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

[feature] fetch all replies #8

Closed
wants to merge 2 commits into from
Closed

Conversation

sneakers-the-rat
Copy link
Collaborator

Adds a button to the bottom of an expanded status to fetch all replies from the OP server (or as many as they will give us).

The feature:

  • Tries to figure out the API URL for the OP server (currently just using the masto pattern, consider that a TODO)
  • Fetches the replies from the /statuses/{:id}/context endpoint
  • Uses the search API on the host instance in order to fetch the necessary status and account information to display the status.

It also:

  • Displays a dialogue box showing how many statuses it is grabbing

Still to do:

  • Write tests (dont know hwo to do that in ruby)
  • Catch errors better
  • Insert into thread in correct order (refreshing fixes)

…hat asks for the context of the post and then uses the search function to search for all the relevant posts and add them to the database
- Connect the search result completion to the updateContexts function to add posts as they are fetched.
- Also works with progress bar
- Add alert to indicate how many statuses are being fetched.
@sneakers-the-rat sneakers-the-rat self-assigned this Jan 2, 2023
@sneakers-the-rat sneakers-the-rat changed the title Feature fetch replies [feature] fetch all replies Jan 2, 2023
Copy link
Member

@mannazsci mannazsci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor comments on documentation, status visibility, non-mastodon domain handling, and accessibility.

dispatch(fetchExternalContextRequest(id));

api(getState).get(`${origin}/api/v1/statuses/${external_id}/context`).then(response => {
dispatch(showAlert('Getting Replies...', `Getting ${response.data.descendants.length} Replies.`));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Todo: We could maybe make this alert more accessible? It is currently in English. If possible, we could enable translation into other languages in the future.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, I gotta see how the translation system works and then I'll change

// Get just the protocol and domain of the instance
// note that we are just assuming that the api is at <domain>/api
// since I don't know a better way of finding it
let { origin, pathname } = new URL(status_url);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could maybe add examples here in the comments for newbies like me? :) Like: status_url = "https://origin/@user_id/external_id" where user_id is the OP's user id on the origin instance and external_id is the OP's status id? (dunno if I've got this right tho, lol)

return (dispatch, getState) => {
dispatch(fetchExternalContextRequest(id));

api(getState).get(`${origin}/api/v1/statuses/${external_id}/context`).then(response => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we do a check here whether the protocol property of ${origin} contains https or not? just for security to avoid sending a request to an http server?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ToDo: we'd need to add handlers for non-mastodon softwares

id,
ancestors,
descendants,
statuses: ancestors.concat(descendants),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we concat only those descendants where visibility = public? not sure what the guidelines are for statuses that have opted out of discovery (e.g where visibility = unlisted)?

// since I don't know a better way of finding it
let { origin, pathname } = new URL(status_url);
let paths = pathname.split('/');
let external_id = paths[paths.length - 1];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just wondering is external_id = id also true here?? based on app/javascript/flavours/glitch/features/status/index.js#L470 : this.props.dispatch(fetchExternalContext(status.get('url'), statusId));

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no i don't think so, each instance makes its own local IDs for posts that it uses internally which don't necessarily match the Ids used by other instances.

@github-actions
Copy link

This pull request has merge conflicts that must be resolved before it can be merged.

@sneakers-the-rat
Copy link
Collaborator Author

Closing in favor of: #44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants