Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions apps/site/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Tracks, albums and single listens multiply into far more pages than are worth
# crawling, and every one is a fresh database query. Artists, profiles and the
# home page stay open.
User-agent: *
Disallow: /track/
Disallow: /album/
Disallow: /listen/
Disallow: /oauth/
Disallow: /_serverFn/
Disallow: /*?
13 changes: 11 additions & 2 deletions apps/site/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,25 @@ export const getListen = createServerFn({ method: "GET" })
const doc = await resolveActor(data.actor);
if (!doc) throw notFound();

const records = await Promise.all(
// Slingshot answers some PDSes' missing records with a 500, so one
// collection failing mustn't hide the play from the other.
const results = await Promise.allSettled(
PLAY_COLLECTIONS.map((collection) =>
cached(`rec:${doc.did}/${collection}/${data.rkey}`, 15, () =>
getRecord(doc.did, collection, data.rkey),
),
),
);
const records = results.map((result) =>
result.status === "fulfilled" ? result.value : undefined,
);
const index = records.findIndex((record) => record !== undefined);
const record = records[index];
if (!record) throw notFound();
if (!record) {
const failed = results.find((result) => result.status === "rejected");
if (failed) throw failed.reason;
throw notFound();
}

const uri = `at://${doc.did}/${PLAY_COLLECTIONS[index]}/${data.rkey}`;
const play = playOf(uri, doc.did, record, tidTime(data.rkey));
Expand Down
Loading