this repo has no description
0
fork

Configure Feed

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

feature: optionally display deny post

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

+30 -19
+3 -9
README.md
··· 13 13 * `DATABASE_URL` - The URL of the database to use. 14 14 * `JETSTREAM_HOSTNAME` - The hostname of the JetStream server to consume events from. 15 15 * `ZSTD_DICTIONARY` - The path to the ZSTD dictionary to use. 16 - * `CONSUMER_TASK_ENABLE` - Whether or not to enable the consumer tasks. 16 + * `CONSUMER_TASK_ENABLE` - Whether or not to enable the consumer tasks. Default `true`. 17 + * `VMC_TASK_ENABLE` - Whether or not to enable the VMC (verification method cache) tasks. Default `true`. 18 + * `PLC_HOSTNAME` - The hostname of the PLC server to use for VMC tasks. Default `plc.directory`. 17 19 * `FEEDS` - The path to the feeds configuration file. 18 20 * `RUST_LOG` - Logging configuration. Defaults to `supercell=debug,info` 19 21 ··· 68 70 The site [https://jsonpath.com/](https://jsonpath.com/) is a great resource for testing JSONPath queries. 69 71 70 72 See the `config.example.yml` file for additional examples. 71 - 72 - # TODO 73 - 74 - * use i64, it's fine 75 - * possible scoring function for queries 76 - * add likes 77 - * support deletes 78 - * document how to register a feed 79 73 80 74 # License 81 75
+1 -1
src/bin/supercell.rs
··· 48 48 let pool = SqlitePool::connect(&config.database_url).await?; 49 49 sqlx::migrate!().run(&pool).await?; 50 50 51 - let feeds: HashMap<String, (String, HashSet<String>)> = config 51 + let feeds: HashMap<String, (Option<String>, HashSet<String>)> = config 52 52 .feeds 53 53 .feeds 54 54 .iter()
+6 -1
src/config.rs
··· 13 13 pub uri: String, 14 14 pub name: String, 15 15 pub description: String, 16 + 17 + #[serde(default)] 16 18 pub allow: HashSet<String>, 17 - pub deny: String, 19 + 20 + #[serde(default)] 21 + pub deny: Option<String>, 22 + 18 23 pub matchers: Vec<Matcher>, 19 24 } 20 25
+2 -2
src/http/context.rs
··· 9 9 10 10 #[derive(Clone, Debug)] 11 11 pub(crate) struct FeedControl { 12 - pub(crate) deny: String, 12 + pub(crate) deny: Option<String>, 13 13 pub(crate) allowed: HashSet<String>, 14 14 } 15 15 ··· 34 34 pub fn new( 35 35 pool: StoragePool, 36 36 external_base: &str, 37 - feeds: HashMap<String, (String, HashSet<String>)>, 37 + feeds: HashMap<String, (Option<String>, HashSet<String>)>, 38 38 ) -> Self { 39 39 let feeds = feeds 40 40 .into_iter()
+18 -6
src/http/handle_get_feed_skeleton.rs
··· 72 72 tracing::error!(error = ?err, "failed to validate JWT"); 73 73 return Ok(Json(FeedItemsView { 74 74 cursor: None, 75 - feed: vec![FeedItemView { 76 - post: feed_control.deny.clone(), 77 - }], 75 + feed: feed_control 76 + .deny 77 + .as_ref() 78 + .map(|value| { 79 + vec![FeedItemView { 80 + post: value.clone(), 81 + }] 82 + }) 83 + .unwrap_or(vec![]), 78 84 }) 79 85 .into_response()); 80 86 } ··· 84 90 if !feed_control.allowed.contains(&did) { 85 91 return Ok(Json(FeedItemsView { 86 92 cursor: None, 87 - feed: vec![FeedItemView { 88 - post: feed_control.deny.clone(), 89 - }], 93 + feed: feed_control 94 + .deny 95 + .as_ref() 96 + .map(|value| { 97 + vec![FeedItemView { 98 + post: value.clone(), 99 + }] 100 + }) 101 + .unwrap_or(vec![]), 90 102 }) 91 103 .into_response()); 92 104 }