1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const std = @import("std");
const livedecode = @import("livedecode.zig");
pub fn collectionMatches(collections: []const []const u8, collection: []const u8) bool {
if (collections.len == 0 or collection.len == 0) return true;
for (collections) |pattern| {
if (std.mem.eql(u8, pattern, collection)) return true;
// Keep the dot: app.bsky.graph.* must not match app.bsky.graphient.
if (std.mem.endsWith(u8, pattern, ".*") and
std.mem.startsWith(u8, collection, pattern[0 .. pattern.len - 1])) return true;
}
return false;
}
pub fn wants(event: livedecode.Event, kinds: []const livedecode.Kind, dids: []const []const u8, collections: []const []const u8) bool {
if (kinds.len > 0) {
for (kinds) |kind| {
if (kind == std.meta.activeTag(event.payload)) break;
} else return false;
}
if (dids.len > 0) {
for (dids) |did| {
if (std.mem.eql(u8, did, event.did)) break;
} else return false;
}
// DID-level markers remain visible under collection filters.
return event.payload != .commit or collectionMatches(collections, event.payload.commit.collection);
}