Instance URL as config var
This commit is contained in:
parent
7a360527f2
commit
8c7ec97637
4 changed files with 11 additions and 10 deletions
|
@ -59,6 +59,7 @@ pub(crate) struct RedditLogin {
|
|||
|
||||
// Config structs
|
||||
pub_struct!(Config {
|
||||
instance: String,
|
||||
reddit_config: RedditConfig,
|
||||
feeds: Vec<FeedSetting>,
|
||||
});
|
||||
|
|
16
src/main.rs
16
src/main.rs
|
@ -52,7 +52,7 @@ impl Bot {
|
|||
};
|
||||
|
||||
let res = CLIENT
|
||||
.post("https://lemmy.neshweb.net/api/v3/user/login")
|
||||
.post(self.config.instance.clone() + "/api/v3/user/login")
|
||||
.json(&login_params)
|
||||
.send()
|
||||
.unwrap();
|
||||
|
@ -70,14 +70,14 @@ impl Bot {
|
|||
|
||||
pub(crate) fn post(&mut self, post_data: CreatePost) {
|
||||
let res = CLIENT
|
||||
.post("https://lemmy.neshweb.net/api/v3/post")
|
||||
.post(self.config.instance.clone() + "/api/v3/post")
|
||||
.json(&post_data)
|
||||
.send()
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
fn list_posts(auth: &Sensitive<String>) -> GetPostsResponse {
|
||||
fn list_posts(auth: &Sensitive<String>, base: String) -> GetPostsResponse {
|
||||
let params = GetPosts {
|
||||
type_: Some(ListingType::Local),
|
||||
sort: Some(SortType::New),
|
||||
|
@ -86,7 +86,7 @@ fn list_posts(auth: &Sensitive<String>) -> GetPostsResponse {
|
|||
};
|
||||
|
||||
let res = CLIENT
|
||||
.get("https://lemmy.neshweb.net/api/v3/post/list")
|
||||
.get(base + "/api/v3/post/list")
|
||||
.query(¶ms)
|
||||
.send()
|
||||
.unwrap()
|
||||
|
@ -105,14 +105,14 @@ impl CommunitiesVector {
|
|||
CommunitiesVector{ids: vec![]}
|
||||
}
|
||||
|
||||
fn load(&mut self, auth: &Sensitive<String>) {
|
||||
fn load(&mut self, auth: &Sensitive<String>, base: &String) {
|
||||
let params = ListCommunities {
|
||||
auth: Some(auth.clone()),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let res = CLIENT
|
||||
.get("https://lemmy.neshweb.net/api/v3/community/list")
|
||||
.get(base.clone() + "/api/v3/community/list")
|
||||
.query(¶ms)
|
||||
.send()
|
||||
.unwrap()
|
||||
|
@ -150,7 +150,7 @@ fn main() {
|
|||
let mut this = Bot::new();
|
||||
println!("{}", this.secrets.lemmy.username);
|
||||
this.login();
|
||||
this.community_ids.load(&this.auth);
|
||||
this.community_ids.load(&this.auth, &this.config.instance);
|
||||
|
||||
// Create empty eTag list
|
||||
println!("TODO: Etag list");
|
||||
|
@ -168,7 +168,7 @@ fn main() {
|
|||
if start.time() - old > chrono::Duration::seconds(6) {
|
||||
old = start.time();
|
||||
this.config = Config::load();
|
||||
this.community_ids.load(&this.auth);
|
||||
this.community_ids.load(&this.auth, &this.config.instance);
|
||||
}
|
||||
|
||||
// Start the polling process
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue