this repo has no description
0
fork

Configure Feed

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

feature: Added dropsonde to test rhai scripts

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

+369 -1
+70
etc/atmosphere_dev.rhai
··· 1 + let rtype = event?.commit?.record?["$type"]; 2 + 3 + if rtype != "app.bsky.feed.post" { 4 + return false; 5 + } 6 + 7 + const SEARCH = [ 8 + ["bluesky"], 9 + ["bsky"], 10 + ["atproto"], 11 + ["atmosphere"], 12 + ["feed", "generator"], 13 + ["at proto"], 14 + ["pds"], 15 + ]; 16 + 17 + const URLS = [ 18 + "https://atproto.com/", 19 + "https://github.com/bluesky-social/", 20 + ]; 21 + 22 + let text = event?.commit?.record?.text ?? ""; 23 + let text_normalized = text.to_lower(); 24 + 25 + for needle in SEARCH { 26 + if sequence_matches(needle, text_normalized) { 27 + return build_aturi(event); 28 + } 29 + } 30 + 31 + let embed_external_url = event?.commit?.record?.embed?.external?.uri ?? ""; 32 + if !embed_external_url.is_empty() { 33 + for needle in URLS { 34 + if embed_external_url.starts_with(needle) { 35 + return build_aturi(event); 36 + } 37 + } 38 + } 39 + 40 + let links = []; 41 + let tags = []; 42 + for facet in event?.commit?.record?.facets ?? [] { 43 + for feature in facet?.features ?? [] { 44 + switch feature?["$type"] { 45 + "app.bsky.richtext.facet#link" => { 46 + let link = feature?["uri"] ?? ""; 47 + if !link.is_empty() { 48 + for needle in URLS { 49 + if link.starts_with(needle) { 50 + return build_aturi(event); 51 + } 52 + } 53 + } 54 + } 55 + "app.bsky.richtext.facet#tag" => { 56 + let tag = feature?["tag"] ?? ""; 57 + let tag_normalized = tag.to_lower(); 58 + for needle in SEARCH { 59 + if sequence_matches(needle, tag_normalized) { 60 + return build_aturi(event); 61 + } 62 + } 63 + } 64 + _ => {} 65 + } 66 + } 67 + } 68 + 69 + 70 + false
+41
src/bin/dropsonde.rs
··· 1 + use anyhow::{anyhow, Context, Result}; 2 + use supercell::matcher::RhaiMatcher; 3 + use supercell::matcher::Matcher; 4 + 5 + fn main() -> Result<()> { 6 + let mut rhai_input_path: Option<String> = None; 7 + let mut json_input_path: Option<String> = None; 8 + for arg in std::env::args_os().skip(1) { 9 + let arg = arg.to_string_lossy(); 10 + if arg.ends_with(".rhai") { 11 + rhai_input_path = Some(arg.to_string()); 12 + } else if arg.ends_with(".json") { 13 + json_input_path = Some(arg.to_string()); 14 + } 15 + } 16 + 17 + if rhai_input_path.is_none() { 18 + return Err(anyhow!("No rhai input file provided")); 19 + } 20 + let rhai_input_path = rhai_input_path.unwrap(); 21 + 22 + if json_input_path.is_none() { 23 + return Err(anyhow!("No json input file provided")); 24 + } 25 + let json_input_path = json_input_path.unwrap(); 26 + 27 + let json_content = std::fs::read(json_input_path) 28 + .map_err(|err| anyhow::Error::new(err).context(anyhow!("reading input_json failed")))?; 29 + let value: serde_json::Value = 30 + serde_json::from_slice(&json_content).context("parsing input_json failed")?; 31 + 32 + let matcher = RhaiMatcher::new(&rhai_input_path) 33 + .context("could not construct matcher")?; 34 + let result = matcher.matches(&value)?; 35 + 36 + let result = result.ok_or(anyhow!("no matches found"))?; 37 + 38 + println!("{:?} {}", result.0, result.1); 39 + 40 + Ok(()) 41 + }
+1 -1
src/matcher.rs
··· 384 384 } 385 385 386 386 impl RhaiMatcher { 387 - pub(crate) fn new(source: &str) -> Result<Self> { 387 + pub fn new(source: &str) -> Result<Self> { 388 388 let mut engine = Engine::new(); 389 389 engine 390 390 .build_type::<Match>()
+19
testdata/atmosphere_dev1.json
··· 1 + { 2 + "did": "did:plc:cbkjy5n7bk3ax2wplmtjofq2", 3 + "time_us": 1730491093829414, 4 + "kind": "commit", 5 + "commit": { 6 + "rev": "3laadb7behk25", 7 + "operation": "create", 8 + "collection": "app.bsky.feed.post", 9 + "rkey": "3laadb7behk25", 10 + "record": { 11 + "$type": "app.bsky.feed.post", 12 + "createdAt": "2024-11-11T03:54:18.825Z", 13 + "langs": [ 14 + "en" 15 + ], 16 + "text": "An unordered / non-exhaustive list of things that helped scale Bluesky's infra efficiently:\n\n+ Exiting the cloud (colocation)\n+ HAProxy w/many Node backends\n+ Go w/clever code\n+ ScyllaDB\n+ SQLite w/per user databases\n+ Redis w/many instances\n+ AMD servers w/many cores\n+ Purchasing bandwidth directly" 17 + } 18 + } 19 + }
+40
testdata/atmosphere_dev2.json
··· 1 + { 2 + "did": "did:plc:cbkjy5n7bk3ax2wplmtjofq2", 3 + "time_us": 1730491093829414, 4 + "kind": "commit", 5 + "commit": { 6 + "rev": "3laadb7behk25", 7 + "operation": "create", 8 + "collection": "app.bsky.feed.post", 9 + "rkey": "3laadb7behk25", 10 + "record": { 11 + "$type": "app.bsky.feed.post", 12 + "createdAt": "2024-11-12T02:41:36.307Z", 13 + "embed": { 14 + "$type": "app.bsky.embed.record", 15 + "record": { 16 + "cid": "bafyreic7a2ehh5f26pzznqajfcqctoaal3spar35ourqcslkizhivlmdna", 17 + "uri": "at://did:plc:3kqj3ksyfct7pip5j5dnmjcu/app.bsky.feed.post/3lapsm6mmdh2w" 18 + } 19 + }, 20 + "facets": [ 21 + { 22 + "features": [ 23 + { 24 + "$type": "app.bsky.richtext.facet#link", 25 + "uri": "https://atproto.blue/en/latest/" 26 + } 27 + ], 28 + "index": { 29 + "byteEnd": 100, 30 + "byteStart": 77 31 + } 32 + } 33 + ], 34 + "langs": [ 35 + "en" 36 + ], 37 + "text": "The Python SDK is a lot better/easier to follow than the last time I checked atproto.blue/en/latest/" 38 + } 39 + } 40 + }
+61
testdata/atmosphere_dev3.json
··· 1 + { 2 + "did": "did:plc:cbkjy5n7bk3ax2wplmtjofq2", 3 + "time_us": 1730491093829414, 4 + "kind": "commit", 5 + "commit": { 6 + "rev": "3laadb7behk25", 7 + "operation": "create", 8 + "collection": "app.bsky.feed.post", 9 + "rkey": "3laadb7behk25", 10 + "record": { 11 + "$type": "app.bsky.feed.post", 12 + "createdAt": "2024-11-09T15:53:08.025Z", 13 + "embed": { 14 + "$type": "app.bsky.embed.external", 15 + "external": { 16 + "description": "Tools and libraries for Bluesky and ATProto by @mackuba.eu", 17 + "thumb": { 18 + "$type": "blob", 19 + "ref": { 20 + "$link": "bafkreiffszg6nvabkwrh5dm4mrrxt5qe5eezp47gj3kmepsgtpoiaht354" 21 + }, 22 + "mimeType": "image/jpeg", 23 + "size": 255960 24 + }, 25 + "title": "blue.mackuba.eu", 26 + "uri": "https://blue.mackuba.eu" 27 + } 28 + }, 29 + "facets": [ 30 + { 31 + "features": [ 32 + { 33 + "$type": "app.bsky.richtext.facet#tag", 34 + "tag": "Ruby" 35 + } 36 + ], 37 + "index": { 38 + "byteEnd": 50, 39 + "byteStart": 45 40 + } 41 + }, 42 + { 43 + "features": [ 44 + { 45 + "$type": "app.bsky.richtext.facet#tag", 46 + "tag": "rubylang" 47 + } 48 + ], 49 + "index": { 50 + "byteEnd": 160, 51 + "byteStart": 151 52 + } 53 + } 54 + ], 55 + "langs": [ 56 + "en" 57 + ], 58 + "text": "Looks like I've been followed by quite a few #Ruby developers this week for some reason, hello! 👋 Good to have you here, I love finally seeing more #rubylang folks here! ❤️ \n\nI might have something interesting for you 😎 Check out my Ruby open source projects for ATProto here, especially \"Minisky\":" 59 + } 60 + } 61 + }
+45
testdata/atmosphere_dev4.json
··· 1 + { 2 + "did": "did:plc:cbkjy5n7bk3ax2wplmtjofq2", 3 + "time_us": 1730491093829414, 4 + "kind": "commit", 5 + "commit": { 6 + "rev": "3laadb7behk25", 7 + "operation": "create", 8 + "collection": "app.bsky.feed.post", 9 + "rkey": "3laadb7behk25", 10 + "record": { 11 + "$type": "app.bsky.feed.post", 12 + "createdAt": "2024-11-11T23:06:07.159Z", 13 + "embed": { 14 + "$type": "app.bsky.embed.external", 15 + "external": { 16 + "description": "Bluesky PDS (Personal Data Server) container image, compose file, and documentation - bluesky-social/pds", 17 + "thumb": { 18 + "$type": "blob", 19 + "ref": { 20 + "$link": "bafkreicwcswfanybt52jjersamdpdyqydhd555uecwltcod5hoofnmzv6u" 21 + }, 22 + "mimeType": "image/jpeg", 23 + "size": 176818 24 + }, 25 + "title": "GitHub - bluesky-social/pds: Bluesky PDS (Personal Data Server) container image, compose file, and documentation", 26 + "uri": "https://github.com/bluesky-social/pds" 27 + } 28 + }, 29 + "langs": [ 30 + "en" 31 + ], 32 + "reply": { 33 + "parent": { 34 + "cid": "bafyreihuozejrmlvsufm7xw4ugdaplgcof4wnzuebpqd4wzzyue32hsviq", 35 + "uri": "at://did:plc:23gw3yye5avo6vhn3dyowi2b/app.bsky.feed.post/3lapgh65u5k2u" 36 + }, 37 + "root": { 38 + "cid": "bafyreiguzubzibua5tdtgbvznndyblkztdgwfvbhtckw7vmkxulf3ecx6q", 39 + "uri": "at://did:plc:k6acu4chiwkixvdedcmdgmal/app.bsky.feed.post/3lapdsadfiq22" 40 + } 41 + }, 42 + "text": "it’s where your posts are stored on here. \nyou can even self host it if you want to." 43 + } 44 + } 45 + }
+92
testdata/atmosphere_dev5.json
··· 1 + { 2 + "did": "did:plc:cbkjy5n7bk3ax2wplmtjofq2", 3 + "time_us": 1730491093829414, 4 + "kind": "commit", 5 + "commit": { 6 + "rev": "3laadb7behk25", 7 + "operation": "create", 8 + "collection": "app.bsky.feed.post", 9 + "rkey": "3laadb7behk25", 10 + "record": { 11 + "$type": "app.bsky.feed.post", 12 + "createdAt": "2024-11-11T20:42:57.437Z", 13 + "embed": { 14 + "$type": "app.bsky.embed.images", 15 + "images": [ 16 + { 17 + "alt": "PDSls showing pds.ewancroft.uk, the only result is did:plc:ofrbh253gwicbkc5nktqepol, which is this account.", 18 + "aspectRatio": { 19 + "height": 201, 20 + "width": 360 21 + }, 22 + "image": { 23 + "$type": "blob", 24 + "ref": { 25 + "$link": "bafkreie2wl5arr6zyda6zutmycysx7o6n36ca4dvdos7fipmxrvsv2vy6y" 26 + }, 27 + "mimeType": "image/jpeg", 28 + "size": 42510 29 + } 30 + }, 31 + { 32 + "alt": "Patrick Star looking darkly downward something off screen.", 33 + "aspectRatio": { 34 + "height": 478, 35 + "width": 636 36 + }, 37 + "image": { 38 + "$type": "blob", 39 + "ref": { 40 + "$link": "bafkreie3nr7m6savpas6vg4lq4xqzbxsfgccrmsg2qfjgb6rlmhjxkbnau" 41 + }, 42 + "mimeType": "image/jpeg", 43 + "size": 312823 44 + } 45 + } 46 + ] 47 + }, 48 + "facets": [ 49 + { 50 + "features": [ 51 + { 52 + "$type": "app.bsky.richtext.facet#tag", 53 + "tag": "SelfHosting" 54 + } 55 + ], 56 + "index": { 57 + "byteEnd": 12, 58 + "byteStart": 0 59 + } 60 + }, 61 + { 62 + "features": [ 63 + { 64 + "$type": "app.bsky.richtext.facet#tag", 65 + "tag": "PDS" 66 + } 67 + ], 68 + "index": { 69 + "byteEnd": 17, 70 + "byteStart": 13 71 + } 72 + }, 73 + { 74 + "features": [ 75 + { 76 + "$type": "app.bsky.richtext.facet#tag", 77 + "tag": "ATProto" 78 + } 79 + ], 80 + "index": { 81 + "byteEnd": 26, 82 + "byteStart": 18 83 + } 84 + } 85 + ], 86 + "langs": [ 87 + "en" 88 + ], 89 + "text": "Not the original text for testing purposes." 90 + } 91 + } 92 + }
testdata/atmosphere_dev6.json

This is a binary file and will not be displayed.