Skip to content

Limit Bootstrap payload number of users, posts #696

@ok300

Description

@ok300

The first time https://pubky.app is opened, it fetches certain data to bootstrap the app, using /v0/bootstrap/{user_id} in the Nexus API.

The same data can be fetched by firing different other calls, like "fetch posts" + "fetch hot tags" + "fetch user details" + "fetch tag counts" etc, but the goal of this endpoint is to avoid this and simplify the bootstrapping of the app.

The issue is described in this TODO:

// TODO: If the user list is too big, we could do in batches

However there is a better and simpler solution than the proposed batching, namely limiting the max number (in this case of UserViews).

Please address the above TODO by limiting the max number of users and posts a Bootstrap object can contain.

pub struct Bootstrap {
/// The user objects shown to the given user ID
pub users: UserStream,
/// The posts objects shown to the given user ID
pub posts: PostStream,
/// IDs of objects shown to this user on the home page of the FE
pub ids: BootstrapIds,
/// Whether or not this user is already indexed
pub indexed: bool,
}

The idea is the Bootstrap payload should not be allowed to be that big that a few simple DB lookups cannot handle, but still big enough that it is useful for bootstrapping Pubky App.

To achieve this, introduce some limits, similarly to how it's done for other API endpoints, like

const MAX_POSTS: usize = 100;

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions