diff --git a/constellation/src/server/mod.rs b/constellation/src/server/mod.rs index 2d5d9d7..7e55a9f 100644 --- a/constellation/src/server/mod.rs +++ b/constellation/src/server/mod.rs @@ -251,9 +251,13 @@ struct GetLinkItemsQuery { /// /// deprecated: use `did`, which can be repeated multiple times from_dids: Option, // comma separated: gross - limit: Option, + #[serde(default = "get_default_limit")] + limit: u64, // TODO: allow reverse (er, forward) order as well } +fn get_default_limit() -> u64 { + DEFAULT_CURSOR_LIMIT +} #[derive(Template, Serialize)] #[template(path = "links.html.j2")] struct GetLinkItemsResponse { @@ -278,12 +282,19 @@ fn get_links( .transpose()? .map(|c| c.next); - let limit = query.limit.unwrap_or(DEFAULT_CURSOR_LIMIT); + let limit = query.limit; if limit > DEFAULT_CURSOR_LIMIT_MAX { return Err(http::StatusCode::BAD_REQUEST); } - let mut filter_dids: HashSet = HashSet::from_iter(query.did.iter().map(|d| Did(d.to_string()))); + let mut filter_dids: HashSet = HashSet::from_iter( + query + .did + .iter() + .map(|d| d.trim()) + .filter(|d| !d.is_empty()) + .map(|d| Did(d.to_string())), + ); if let Some(comma_joined) = &query.from_dids { if !filter_dids.is_empty() { diff --git a/constellation/templates/hello.html.j2 b/constellation/templates/hello.html.j2 index ce75a6a..faeabcf 100644 --- a/constellation/templates/hello.html.j2 +++ b/constellation/templates/hello.html.j2 @@ -20,10 +20,10 @@

This server has indexed {{ stats.linking_records|human_number }} links between {{ stats.targetables|human_number }} targets and sources from {{ stats.dids|human_number }} identities over {{ days_indexed|human_number }} days.
- (indexing new records in real time, backfill still TODO) + (indexing new records in real time, backfill coming soon!)

-

The API is currently unstable. But feel free to use it! If you want to be nice, put your project name and bsky username (or email) in your user-agent header for api requests.

+

But feel free to use it! If you want to be nice, put your project name and bsky username (or email) in your user-agent header for api requests.

API Endpoints

@@ -35,13 +35,16 @@

Query parameters:

    -
  • target: required, must url-encode. Example: at://did:plc:vc7f4oafdgxsihk4cry2xpze/app.bsky.feed.post/3lgwdn7vd722r
  • -
  • collection: required. Example: app.bsky.feed.like
  • -
  • path: required, must url-encode. Example: .subject.uri
  • +
  • target: required, must url-encode. Example: at://did:plc:vc7f4oafdgxsihk4cry2xpze/app.bsky.feed.post/3lgwdn7vd722r

  • +
  • collection: required. Example: app.bsky.feed.like

  • +
  • path: required, must url-encode. Example: .subject.uri

  • +
  • did: optional, filter links to those from specific users. Include multiple times to filter by multiple users. Example: did=did:plc:vc7f4oafdgxsihk4cry2xpze&did=did:plc:vc7f4oafdgxsihk4cry2xpze

  • +
  • from_dids [deprecated]: optional. Use did instead. Example: from_dids=did:plc:vc7f4oafdgxsihk4cry2xpze,did:plc:vc7f4oafdgxsihk4cry2xpze

  • +
  • limit: optional. Default: 16. Maximum: 100

Try it:

- {% call try_it::links("at://did:plc:vc7f4oafdgxsihk4cry2xpze/app.bsky.feed.post/3lgwdn7vd722r", "app.bsky.feed.like", ".subject.uri") %} + {% call try_it::links("at://did:plc:a4pqq234yw7fqbddawjo7y35/app.bsky.feed.post/3m237ilwc372e", "app.bsky.feed.like", ".subject.uri", [""], 16) %}

GET /links/distinct-dids

diff --git a/constellation/templates/links.html.j2 b/constellation/templates/links.html.j2 index b293f02..ee27d92 100644 --- a/constellation/templates/links.html.j2 +++ b/constellation/templates/links.html.j2 @@ -6,7 +6,7 @@ {% block content %} - {% call try_it::links(query.target, query.collection, query.path) %} + {% call try_it::links(query.target, query.collection, query.path, query.did, query.limit) %}

Links to {{ query.target }} diff --git a/constellation/templates/try-it-macros.html.j2 b/constellation/templates/try-it-macros.html.j2 index a9da1f0..9b0aff5 100644 --- a/constellation/templates/try-it-macros.html.j2 +++ b/constellation/templates/try-it-macros.html.j2 @@ -1,10 +1,28 @@ -{% macro links(target, collection, path) %} +{% macro links(target, collection, path, dids, limit) %}
GET /links
   ?target=     
   &collection= 
-  &path=        
+ &path= + {%- for did in dids %}{% if !did.is_empty() %} + &did= {% endif %}{% endfor %} + + &limit=
+ {% endmacro %}