alright, after like a year of halfheartedly trying on and off, #FetchAllReplies is pretty much finished - the problem of not being able to see all replies to a post is one of the largest complaints that people have with mastodon in particular but also ...
-
kouhai, Breaker of Cachesreplied to jonny (good kind) last edited by
@jonny @thisismissem some of this feels like โit dependsโ. polling will be chattier, especially without connection reuse via H2/etc. websockets will make state management after disconnect a minor issue complexity wise
note that depending on implementation, polling may also incur the expense of a round trip vs half trip
-
@kouhai
@thisismissem
I am thinking it might be nice to just make a streaming endpoint for when one is in a thread both for this and in general. On a given instance, the thread ancestors are always known (I think?) From the threadresolveservice, or at least wouldnt mutate in the client (?). A new status can similarly always resolve its thread root on the server. So if there was a streaming feed for every root post, that might be a reasonably efficient way to do it, so eg. Multiple viewers with different points in a broad and deep thread could all sub to the same feed, and every new post has exactly one feed it would need to be added to.Since the context endpoint is unpaginated and you always get the full parent tree when you mount a thread view from any point in a thread, I think you could mount and unmount the stream w/relatively low complexity in the client? Gonna give it a shot
-
Jonreplied to :PUA: Shlee fucked around and last edited by
yeah really, very cool work @[email protected] !
@[email protected] -
Emelia ๐ธ๐ปreplied to jonny (good kind) last edited by
@jonny well yeah, there's no functionality in streaming for updates to replies on a single status so both approaches are about as "good" โ iirc your intention isn't to upstream this?
-
Emelia ๐ธ๐ปreplied to jonny (good kind) last edited by
@jonny @kouhai that'd probably put a lot of extra load on the streaming server as you'd need to check authorization as you navigate into and out of the channels per thread (e.g., checking blocks/mutes, checking thread visibility, checking the streaming user is within the set membership for the thread posters' followers, etc)
Currently all that authorization happens in rails pretty much beside the public feeds which only need blocks & mutes checked.
-
jonny (good kind)replied to Emelia ๐ธ๐ป last edited by
@thisismissem
@kouhai
Im restructuring it rn and im finding that patching into the distribution worker is letting me basically reuse everything there, ill perf test it once this restructuring is done -
Emelia ๐ธ๐ปreplied to jonny (good kind) last edited by
-
jonny (good kind)replied to Emelia ๐ธ๐ป last edited by
@thisismissem
@kouhai
I was thinking of just making a new kind of redis channeltimelines:thread:{thread_root.id}
and copying/reusing whats already in place for feed streams, but ill check that out tomorrow (I gotta sleep rn) -
Code of Amor ๐replied to jonny (good kind) last edited by
@jonny How does this differ from something like fedifetcher?
-
jonny (good kind)replied to Code of Amor ๐ last edited by
@codeofamor
Happens automatically when you expand a post, no external script needed.
Uses activitypub collections, so can get posts from any AP instance instead of the 4 fedifetcher can do
Can get complete contexts (that the servers will give you) instead of the 40 post cap with logged out contexts requests against masto
Not messy - doesnt download the entire fediverse
Not slow - fedifetcher uses the search api which does a ton of other stuff when it fetches a post (like fetch the entire profile and resolve all their links and so on) -
Emelia ๐ธ๐ปreplied to jonny (good kind) last edited by [email protected]
@jonny @kouhai right, the problem is that when a client subscribes to that topic, you need to assert all the ACL policies to check โcan you actually subscribe to this topicโ
That's potentially expensive and complex, since we don't currently have anything like that in streaming at the moment.
I'm not saying I'd be against streaming supporting updates for a given thread, but we need to make sure it enforces all the same authorisation logic that exists in rails.
-
kouhai, Breaker of Cachesreplied to Emelia ๐ธ๐ป last edited by
@thisismissem @jonny okay, so the solution that I was thinking:
- websocket event channel that exists solely to notify of an update to public / unlisted posts
reducing the scope to public/unlisted also reduces the ACL overhead to "is this incoming reply public/unlisted?โ
not sure what's ideal for private/followers visibility thread roots, though; perhaps that could be a later patch
-
@kouhai @jonny right, so the complexity of public/unlisted is the same as for private/followers to a decent degree. (followers does have an additional check via the database required)
You need to load the status from the database for the thread, and then check it's visibility (also keep in mind visibility can change mid-thread)
-
kouhai, Breaker of Cachesreplied to Emelia ๐ธ๐ป last edited by
@thisismissem @jonny still waking up, but i was thinking of doing this near the distribution worker, actually. the uh, fan out service, i think?
so maybe it looks like:
"ThreadUpdates:#{PublicThreadRoot}:Public" -> public replies to thread with given PublicThreadRoot
"ThreadUpdates:#{PublicThreadRoot}:Unlistedโ -> unlisted replies to thread with given PublicThreadRoot. may want to require โauth'd user for this instanceโ (not familiar with streaming)
"ThreadUpdates:#{PublicThreadRoot}:OutOfBandโ -> management messages, i.e. a Resubscribe payload, and a Close payload (if thatโs necessary?)but admittedly, yeah. this is starting to look less appealing versus polling. alas!
-
Erin Kissanereplied to jonny (good kind) last edited by
@jonny YAY thank you for all this work, fair winds and following seas for the last stretch of dev
-
-
kouhai, Breaker of Cachesreplied to Emelia ๐ธ๐ป last edited by
@thisismissem @jonny yeah. alas! my efficient websocket push
-
@kouhai
@thisismissem
Thanks for thinking through all this complexity yall, you probably saved me several days of bafflement here. For curiosity's sake I still want to see what would be different from eg. The public feeds, where we need to do what seems like similar filtering for blocks, etc. But we can all subscribe to it, bur it sounds like polling will have to be the way.I think I'll have to make a separate worked after all to prevent a maliciously crafted infinitely expanding thread tree with global recursion limits anyway, so polling might be good there too so we can have a progress indicator rather than just popping posts in as they come
-
kouhai, Breaker of Cachesreplied to jonny (good kind) last edited by
@jonny @thisismissem fairness: should there be a per-user throttle so that we donโt have someone opening 100000 tabs and causing a bunch of work
(Iโd argue that this endpoint may need to be authgated for that reason, to make it easier to throttle)
-
Emelia ๐ธ๐ปreplied to jonny (good kind) last edited by
@jonny @kouhai yeah, the UI side would certainly need to "buffer" new posts.
I think having the ability to subscribe to a thread in the streaming server would be good, but it has some complexities in the authorization layer which make it potentially difficult.
With https://github.com/mastodon/mastodon/pull/30965 we do lift some database interactions up outside of the message handling loop, and https://github.com/mastodon/mastodon/pull/30978 goes further here.