Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rss): draft rss feature #78

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 129 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ juniper_rocket_multipart_handler = "0.1.0"
infer = "0.8.1"
base64 = "0.13.0"
juniper_relay_connection = "0.1.1"
rss = "2.0"

[dependencies.tokio-util]
version = "0.7.1"
Expand Down

This file was deleted.

3 changes: 0 additions & 3 deletions juniper_rocket_multipart_handler/src/lib.rs

This file was deleted.

5 changes: 3 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use dotenv::dotenv;
use juniper::EmptySubscription;
use rocket::Rocket;
use rocket::{fairing::AdHoc, Route};
use routes::{auth::login, file::get_file, utils::graphiql, utils::static_index};
use routes::{auth::login, file::get_file, rss::get_rss, utils::graphiql, utils::static_index};
use std::env;

use app::{
Expand Down Expand Up @@ -92,7 +92,8 @@ fn routes_builder() -> Vec<Route> {
payable_post_graphql_handler,
upload,
login,
get_file
get_file,
get_rss
];

let enable_dev_tools = env::var("ENABLE_DEV_TOOLS").unwrap_or("false".to_string());
Expand Down
1 change: 1 addition & 0 deletions src/routes/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod auth;
pub mod file;
pub mod rss;
pub mod utils;
32 changes: 32 additions & 0 deletions src/routes/rss.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use crate::db::{models::media::Media, PostgresConn};
use rocket::http::ContentType;
use rocket::response::{content, Response};
use rss::{Channel, ChannelBuilder, Item, ItemBuilder};
use std::io::Cursor;

/// A route to retrieve files behind the paywall.
#[rocket::get("/rss")]
pub async fn get_rss(db: PostgresConn) -> content::RawXml<String> {
let results = db.run(move |c| Media::find_all_published(c)).await;
let items: Vec<Item> = results
.iter()
.map(|media| {
let mut item = Item::default();
item.set_title(media.title.clone());
item.set_description(media.description.clone());
// .set_description(media.description)
// .link(item.link.as_str())
item
})
.collect();

let channel = ChannelBuilder::default()
.title("LNFileStore RSS Feed".to_string())
.description("This RSS feed provides the list of available medias".to_string())
// .link("https://example.com".to_string())
.items(items)
.build()
.to_string();

content::RawXml(channel)
}