diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a49a324..977dff3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: run: cargo +nightly fmt --all -- --check - name: Run Clippy - run: cargo clippy --all-targets --all-features -- -D warnings + run: cargo clippy --workspace --all-features -- -D warnings - name: Run tests - run: cargo test --all + run: cargo test --workspace --all-features diff --git a/bot-utils/src/broadcasting.rs b/bot-utils/src/broadcasting.rs index eaaafe0..2bf6d40 100644 --- a/bot-utils/src/broadcasting.rs +++ b/bot-utils/src/broadcasting.rs @@ -82,6 +82,7 @@ type SendMessage = (ScheduledMessage, oneshot::Sender>) pub enum NextUpdate { Ready { id: B::UpdateId, msg: B::Message }, Skipped { id: B::UpdateId }, + OutOfSync, Pending { previous: B::UpdateId }, Migrated { to: ChatId }, Stopped, @@ -281,13 +282,8 @@ async fn try_process_next( let (id, message) = match shared.backend.next_update(chat_id).await? { NextUpdate::Ready { id, msg: next } => (id, next), - NextUpdate::Skipped { id } => { - if shared.backend.acknowledge(chat_id, id).await? { - return Ok(ChatStatus::Processed(id)); - } else { - return Ok(ChatStatus::OutOfSync); - } - } + NextUpdate::Skipped { id } => return Ok(ChatStatus::Processed(id)), + NextUpdate::OutOfSync => return Ok(ChatStatus::OutOfSync), NextUpdate::Pending { previous: last } => return Ok(ChatStatus::Processed(last)), NextUpdate::Migrated { to } => return Ok(ChatStatus::MigratedTo(to)), NextUpdate::Stopped => return Ok(ChatStatus::Stopped), diff --git a/src/allris/mod.rs b/src/allris/mod.rs index 4543fd3..8c1cc04 100644 --- a/src/allris/mod.rs +++ b/src/allris/mod.rs @@ -7,7 +7,9 @@ use std::time::Duration; use chrono::Utc; use frankenstein::methods::SendMessageParams; -use frankenstein::types::{InlineKeyboardButton, InlineKeyboardMarkup, ReplyMarkup}; +use frankenstein::types::{ + InlineKeyboardButton, InlineKeyboardMarkup, LinkPreviewOptions, ReplyMarkup, +}; use futures_util::{Stream, TryStreamExt}; use oparl::{Consultation, Paper, get_organization}; use reqwest::{Client, Response}; @@ -236,6 +238,7 @@ async fn generate_notification(client: &Client, paper: &Paper) -> Option { - self.acknowledge(chat, msg.0).await?; - NextUpdate::Skipped { id: msg.0 } + if self.acknowledge(chat, msg.0).await? { + NextUpdate::Skipped { id: msg.0 } + } else { + NextUpdate::OutOfSync + } } None => NextUpdate::Pending { previous: last_sent, @@ -165,7 +167,6 @@ impl Backend for RedisBackend { let message = &message.1; let mut params = message.request.clone(); params.chat_id = chat_id.into(); - params.link_preview_options = Some(LinkPreviewOptions::builder().is_disabled(true).build()); self.bot.send_message(¶ms).await?;