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

Document tail api #79

Open
shiimizu opened this issue Apr 14, 2020 · 1 comment
Open

Document tail api #79

shiimizu opened this issue Apr 14, 2020 · 1 comment

Comments

@shiimizu
Copy link

shiimizu commented Apr 14, 2020

Document tail_size and tail_id. #46 (comment)

From what I understand, this endpoint ({thread-id}-tail.json) is exclusively used by the JavaScript extension but would be a great asset to developers wanting to reduce bandwidth by knowing how & when it's emitted.

Furthermore, tail_size seems to appear randomly in threads ({thread-id}.json), no matter how big or small the thread. Maybe with {thread-id}-tail.json, is there a way to reliably get a list of posts past a specified If-Modified-Since?

@catamphetamine
Copy link
Contributor

catamphetamine commented May 4, 2021

@shiimizu Doesn't the following tactics work?

  • Query full thread
  • Store the latest comment ID as latestCommentId

On auto-refresh timer:

  1. Query -tail.json. If it doesn't exist, then perform a full thread refresh and go to step 5.
  2. Check if posts[0].tail_id is less than or equal to the current latestCommentId.
  3. If it is, then there're no missed comments. Append new comments starting from id > latestCommentId.
  4. If it's not, then it means that since the last "auto-refresh" there have been too much new comments and some of them are missing in -tail.json, so perform a full thread refresh.
  5. Update the latestCommentId and wait for the next auto-refresh.
posts[0] = {
	// Thread id.
	"no": 185776347,

	// Is "bump limit" reached?
	"bumplimit": 0,

	// Is "image limit" reached?
	"imagelimit": 0,

	// Total comments count in the thread,
	// not including the "main" ("original") comment.
	"replies": 195,

	// Total attachments count in the thread.
	"images": 82,

	// Unique poster IPs count.
	"unique_ips": 44,

	// The length of the `posts[]` array
	// (minus one for the opening post)
	// in this API response.
	"tail_size": 50,

	// The `id` of the comment which comes before
	// the first comment of the "tail".
	// In other words, the `id` of the last comment
	// not included in the "tail" API response.
	"tail_id": 185788827
}

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

No branches or pull requests

2 participants