Skip to content
This repository has been archived by the owner on Jul 3, 2023. It is now read-only.

Commit

Permalink
Favourite a toot after indexing it.
Browse files Browse the repository at this point in the history
  • Loading branch information
berkes committed Aug 5, 2022
1 parent 16a3a67 commit 6c8ea89
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn main() -> Result<(), Box<dyn Error>> {
let mastodon = Mastodon::from(data);

let (tx, rx): (Sender<Message>, Receiver<Message>) = mpsc::channel();
let messages_thread = handle_messages(rx, output);
let messages_thread = handle_messages(rx, output, mastodon.clone());

if cli_opts.past {
// TODO: This method will return duplicates. So we should deduplicate
Expand Down Expand Up @@ -130,7 +130,7 @@ fn capture_updates(mastodon: elefren::Mastodon, tx: Sender<Message>) -> thread::
})
}

fn handle_messages(rx: Receiver<Message>, output: Output) -> thread::JoinHandle<()> {
fn handle_messages(rx: Receiver<Message>, output: Output, client: Mastodon) -> thread::JoinHandle<()> {
debug!("opening message handler");
thread::spawn(move || loop {
if let Ok(received) = rx.try_recv() {
Expand All @@ -139,7 +139,8 @@ fn handle_messages(rx: Receiver<Message>, output: Output) -> thread::JoinHandle<
Message::Vacancy(status) => {
if may_index(&status.account.url) {
debug!("Handling vacancy: {:#?}", status);
output.handle_vacancy(status.into());
output.handle_vacancy(&status.clone().into());
client.favourite(&status.id).expect("Favourite failed");
}
}
Message::Generic(msg) => info!("{}", msg),
Expand Down
6 changes: 3 additions & 3 deletions src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ impl Output {
}
}

pub(crate) fn handle_vacancy(&self, vacancy: Vacancy) {
self.write_into_file(&vacancy);
self.write_into_meili(&vacancy);
pub(crate) fn handle_vacancy(&self, vacancy: &Vacancy) {
self.write_into_file(vacancy);
self.write_into_meili(vacancy);
}

fn write_into_file<T>(&self, status: &T)
Expand Down

0 comments on commit 6c8ea89

Please sign in to comment.