search for standard sites pub-search.waow.tech
search zig blog atproto
11
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: remove unused PDS fetch fallback

the fetchLeafletContent function was a defensive fallback for when
content.pages extraction failed. now that extraction handles the
nested path correctly, it's never triggered. removing ~40 lines.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

zzstoatzz c42aeb68 c2113e02

-58
-58
backend/src/tap.zig
··· 227 227 }; 228 228 defer doc.deinit(); 229 229 230 - // if content is empty and this is a site.standard.document with pub.leaflet.content, 231 - // fetch the pub.leaflet.document from PDS to get actual content 232 - if (doc.content.len == 0 and mem.eql(u8, collection, STANDARD_DOCUMENT)) { 233 - const record_val: json.Value = .{ .object = record }; 234 - const content_type = zat.json.getString(record_val, "content.$type"); 235 - if (content_type != null and mem.eql(u8, content_type.?, "pub.leaflet.content")) { 236 - if (fetchLeafletContent(allocator, did, rkey)) |leaflet_content| { 237 - allocator.free(doc.content); 238 - doc.content = leaflet_content; 239 - std.debug.print("fetched leaflet content for {s}: {} chars\n", .{ uri, leaflet_content.len }); 240 - } else |err| { 241 - std.debug.print("failed to fetch leaflet content for {s}: {}\n", .{ uri, err }); 242 - } 243 - } 244 - } 245 - 246 230 try indexer.insertDocument( 247 231 uri, 248 232 did, ··· 257 241 doc.path, 258 242 ); 259 243 std.debug.print("indexed document: {s} [{s}] ({} chars, {} tags)\n", .{ uri, doc.platformName(), doc.content.len, doc.tags.len }); 260 - } 261 - 262 - /// fetch content from pub.leaflet.document for a given DID/rkey 263 - fn fetchLeafletContent(allocator: Allocator, did: []const u8, rkey: []const u8) ![]u8 { 264 - // resolve DID to get PDS endpoint 265 - const did_parsed = zat.Did.parse(did) orelse return error.InvalidDid; 266 - var resolver = zat.DidResolver.init(allocator); 267 - defer resolver.deinit(); 268 - 269 - var did_doc = try resolver.resolve(did_parsed); 270 - defer did_doc.deinit(); 271 - 272 - const pds = did_doc.pdsEndpoint() orelse return error.NoPdsEndpoint; 273 - 274 - // fetch pub.leaflet.document from PDS 275 - var client = zat.XrpcClient.init(allocator, pds); 276 - defer client.deinit(); 277 - 278 - const nsid = zat.Nsid.parse("com.atproto.repo.getRecord") orelse return error.InvalidNsid; 279 - 280 - var params = std.StringHashMap([]const u8).init(allocator); 281 - defer params.deinit(); 282 - try params.put("repo", did); 283 - try params.put("collection", LEAFLET_DOCUMENT); 284 - try params.put("rkey", rkey); 285 - 286 - var response = try client.query(nsid, params); 287 - defer response.deinit(); 288 - 289 - if (!response.ok()) return error.PdsRequestFailed; 290 - 291 - // parse response and extract content 292 - var parsed = try response.json(); 293 - defer parsed.deinit(); 294 - 295 - const record_obj = zat.json.getObject(parsed.value, "value") orelse return error.NoValueInResponse; 296 - 297 - // use extractor to get content from pub.leaflet.document 298 - var leaflet_doc = try extractor.extractDocument(allocator, record_obj, LEAFLET_DOCUMENT); 299 - defer leaflet_doc.deinit(); 300 - 301 - return leaflet_doc.takeContent(); 302 244 } 303 245 304 246 fn processPublication(_: Allocator, uri: []const u8, did: []const u8, rkey: []const u8, record: json.ObjectMap) !void {