3 Commits

Author SHA1 Message Date
6d34fde8ca Merge pull request #43 from flibusta-apps/dependabot/github_actions/github/codeql-action-4
Some checks failed
Build docker image / Build-Docker-Image (push) Has been cancelled
rust-clippy analyze / Run rust-clippy analyzing (push) Has been cancelled
Bump github/codeql-action from 3 to 4
2025-10-14 18:04:28 +02:00
ea8290f74c Clean up code formatting and error handling
The commit includes better handling of API errors, cleaner match
patterns, and consistent whitespace/formatting in file_utils.rs.
2025-10-14 17:52:23 +02:00
dependabot[bot]
8336c8598e Bump github/codeql-action from 3 to 4
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3 to 4.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v3...v4)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: '4'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-08 09:04:39 +00:00
2 changed files with 9 additions and 14 deletions

View File

@@ -49,7 +49,7 @@ jobs:
continue-on-error: true
- name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v3
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: rust-clippy-results.sarif
wait-for-processing: true

View File

@@ -1,6 +1,7 @@
use std::error::Error;
use axum::body::Bytes;
use moka::future::Cache;
use once_cell::sync::Lazy;
use serde::Serialize;
use teloxide::{
@@ -9,7 +10,6 @@ use teloxide::{
};
use tokio::fs::File;
use tracing::log;
use moka::future::Cache;
use super::bot::ROUND_ROBIN_BOT;
use crate::config::CONFIG;
@@ -44,7 +44,6 @@ pub static TEMP_FILES_CACHE: Lazy<Cache<i32, MessageId>> = Lazy::new(|| {
.build()
});
pub async fn upload_file(
file: Bytes,
filename: String,
@@ -70,7 +69,6 @@ pub async fn upload_file(
}
}
pub async fn download_file(chat_id: i64, message_id: i32) -> Result<Option<File>, Box<dyn Error>> {
let bot = ROUND_ROBIN_BOT.get_bot();
@@ -84,16 +82,12 @@ pub async fn download_file(chat_id: i64, message_id: i32) -> Result<Option<File>
{
Ok(v) => v,
Err(err) => {
if let teloxide::RequestError::Api(ref err) = err {
if let teloxide::ApiError::MessageToForwardNotFound = err {
return Ok(None);
}
if let teloxide::RequestError::Api(teloxide::ApiError::MessageToForwardNotFound) = err {
return Ok(None);
}
if let teloxide::RequestError::Api(ref err) = err {
if let teloxide::ApiError::MessageIdInvalid = err {
return Ok(None);
}
if let teloxide::RequestError::Api(teloxide::ApiError::MessageIdInvalid) = err {
return Ok(None);
}
log::error!("Error: {}", err);
@@ -103,7 +97,9 @@ pub async fn download_file(chat_id: i64, message_id: i32) -> Result<Option<File>
let file_id = forwarded_message.document().unwrap().file.id.clone();
TEMP_FILES_CACHE.insert(message_id, forwarded_message.id).await;
TEMP_FILES_CACHE
.insert(message_id, forwarded_message.id)
.await;
let path = match bot.get_file(file_id.clone()).await {
Ok(v) => v.path,
@@ -116,7 +112,6 @@ pub async fn download_file(chat_id: i64, message_id: i32) -> Result<Option<File>
Ok(Some(File::open(path).await?))
}
pub async fn clean_files() -> Result<(), Box<dyn Error>> {
let bots_folder = "/var/lib/telegram-bot-api/";
let documents_folder_name = "documents";