this repo has no description
0
fork

Configure Feed

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

documentation: Added popular feed example

Signed-off-by: Nick Gerakines <12125+ngerakines@users.noreply.github.com>

+62
+8
examples/popular/README.md
··· 1 + # Example: Popular 2 + 3 + This configuration file includes a feed that watches for posts with a tag. The feed is then sorted by a simple "popular" algorithm that takes into account the number of likes, replies, and quotes. 4 + 5 + ## Instructions 6 + 7 + 1. Create the feed and replace `ATURI` with the full record AT-URI. Should look like `at://YOUR_DID/app.bsky.feed.generator/some_rkey` 8 + 2. Review the `popular.rhai` file to see how the algorithm works.
+7
examples/popular/config.yml
··· 1 + feeds: 2 + - uri: "ATURI" 3 + name: "Popular" 4 + description: "Popular posts with the tag #Supercell." 5 + matchers: 6 + - type: rhai 7 + script: "/path/to/popular.rhai"
+47
examples/popular/popular.rhai
··· 1 + let rtype = event?.commit?.record?["$type"]; 2 + 3 + // If the event is for a like, use the AT-URI in the record subject to 4 + // increment the score of any existing feed_content records. 5 + if rtype == "app.bsky.feed.like" { 6 + return update_match(build_aturi(event)); 7 + } 8 + 9 + // Ignore any record types that aren't posts. 10 + if rtype != "app.bsky.feed.post" { 11 + return false; 12 + } 13 + 14 + // Reject posts where the created at is more than 8 days ago. 15 + // See https://docs.rs/duration-str/latest/duration_str/ 16 + if matcher_before_duration("-8d", event?.commit?.record?.createdAt ?? "") { 17 + return false; 18 + } 19 + 20 + // This feed only includes posts that are not replies themselves, but does 21 + // look at replies to adjust the score of root posts. 22 + let parent_uri = event?.commit?.record?.reply?.root?.uri ?? ""; 23 + if !parent_uri.is_empty() { 24 + return parent_uri; 25 + } 26 + 27 + for facet in event?.commit?.record?.facets ?? [] { 28 + for feature in facet?.features ?? [] { 29 + switch feature?["$type"] { 30 + "app.bsky.richtext.facet#tag" => { 31 + let tag = feature?["tag"] ?? ""; 32 + let tag_normalized = tag.to_lower(); 33 + if tag_normalized == "supercell" { 34 + 35 + // If the post is not a reply and has the "#supercell" tag then add 36 + // it to the feed. 37 + 38 + return build_aturi(event); 39 + 40 + } 41 + } 42 + _ => {} 43 + } 44 + } 45 + } 46 + 47 + false