Compare commits

..

No commits in common. "develop" and "main" have entirely different histories.

4 changed files with 13 additions and 8 deletions

View File

@ -1,2 +0,0 @@
[alias]
t="test -- --test-threads=1"

View File

@ -1,8 +1,11 @@
[package] [package]
name = "mastodon-image-uploader-bot" name = "mastodon-image-uploader-bot"
version = "0.3.1" version = "0.3.0"
edition = "2021" edition = "2021"
[alias]
test = "cargo test -- --test-threads=1"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]

View File

@ -10,13 +10,13 @@ spec:
spec: spec:
containers: containers:
- name: bot-job - name: bot-job
image: git.fai.st/fedi-image-bot/mastodon-image-uploader-bot:v1.0.0 image: git.fai.st/fedi-image-bot/mastodon-image-uploader-bot:latest
volumeMounts: volumeMounts:
- name: config-toml - name: config-toml
mountPath: /app/config.toml mountPath: /app/
readOnly: true readOnly: true
- name: mastodon-token - name: mastodon-token
mountPath: /app/mastodon-data.toml mountPath: /app/
readOnly: true readOnly: true
restartPolicy: Never restartPolicy: Never
volumes: volumes:

View File

@ -1,11 +1,15 @@
use async_std;
use log;
use mastodon_async::entities::visibility::Visibility; use mastodon_async::entities::visibility::Visibility;
use mastodon_async::helpers::{cli, toml as masto_toml}; use mastodon_async::helpers::{cli, toml as masto_toml};
use mastodon_async::prelude::*; use mastodon_async::prelude::*;
use reqwest;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::collections::HashSet; use std::collections::HashSet;
use std::io::{Cursor, Write}; use std::io::{Cursor, Write};
use std::process::exit; use std::process::exit;
use std::time::Duration; use std::time::Duration;
use toml;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
struct AccountUpdate { struct AccountUpdate {
@ -172,7 +176,7 @@ fn set_url_as_posted(config: &Config, url: &String) -> DynResult<()> {
.write(true) .write(true)
.append(true) // This is needed to append to file .append(true) // This is needed to append to file
.open(&config.files.posted)?; //.expect("Cannot open posted file"); // Maybe we should retry just in case .open(&config.files.posted)?; //.expect("Cannot open posted file"); // Maybe we should retry just in case
writeln!(file, "{}", url)?; //.expect("Cannot write to posted file"); // maybe we should retry tbh write!(file, "{}\n", url)?; //.expect("Cannot write to posted file"); // maybe we should retry tbh
log::info!("Set url {} as posted", url); log::info!("Set url {} as posted", url);
Ok(()) Ok(())
} }
@ -280,7 +284,7 @@ mod tests {
let client = reqwest::Client::new(); let client = reqwest::Client::new();
let config = get_config(); let config = get_config();
let account = get_account(&config).await; let account = get_account(&config).await;
let msg = "Test!".to_string(); let msg = format!("Test!");
let status = post(&account, &msg, Visibility::Direct).await.unwrap(); let status = post(&account, &msg, Visibility::Direct).await.unwrap();
let response = client let response = client