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: use zat.json.extractAt for TAP record parsing

now that extractAt ignores unknown fields, we can use it instead of
manual field-by-field extraction. 25 lines -> 4 lines.

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

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

zzstoatzz 28f39d3d eb8b5c1a

+3 -28
+3 -28
backend/src/tap.zig
··· 183 183 184 184 if (!mem.eql(u8, msg_type, "record")) return; 185 185 186 - // extract record envelope manually (zat.extractAt was failing) 187 - const record_obj = zat.json.getObject(parsed.value, "record") orelse { 188 - std.debug.print("tap: no 'record' object in message\n", .{}); 189 - return; 190 - }; 191 - const record_val: json.Value = .{ .object = record_obj }; 192 - 193 - const collection = zat.json.getString(record_val, "collection") orelse { 194 - std.debug.print("tap: record missing collection\n", .{}); 195 - return; 196 - }; 197 - const action = zat.json.getString(record_val, "action") orelse { 198 - std.debug.print("tap: record missing action\n", .{}); 186 + // extract record envelope (extractAt ignores extra fields like live, rev, cid) 187 + const rec = zat.json.extractAt(TapRecord, allocator, parsed.value, .{"record"}) catch |err| { 188 + std.debug.print("tap: failed to extract record: {}\n", .{err}); 199 189 return; 200 - }; 201 - const did_str = zat.json.getString(record_val, "did") orelse { 202 - std.debug.print("tap: record missing did\n", .{}); 203 - return; 204 - }; 205 - const rkey = zat.json.getString(record_val, "rkey") orelse { 206 - std.debug.print("tap: record missing rkey\n", .{}); 207 - return; 208 - }; 209 - 210 - const rec = TapRecord{ 211 - .collection = collection, 212 - .action = action, 213 - .did = did_str, 214 - .rkey = rkey, 215 190 }; 216 191 217 192 // validate DID