Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 3 additions & 7 deletions bot-utils/src/broadcasting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ type SendMessage<B> = (ScheduledMessage<B>, oneshot::Sender<OneshotResponse<B>>)
pub enum NextUpdate<B: Backend> {
Ready { id: B::UpdateId, msg: B::Message },
Skipped { id: B::UpdateId },
OutOfSync,
Pending { previous: B::UpdateId },
Migrated { to: ChatId },
Stopped,
Expand Down Expand Up @@ -281,13 +282,8 @@ async fn try_process_next<B: Backend>(

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),
Expand Down
5 changes: 4 additions & 1 deletion src/allris/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -236,6 +238,7 @@ async fn generate_notification(client: &Client, paper: &Paper) -> Option<Message
.chat_id(0)
.text(text)
.entities(entities)
.link_preview_options(LinkPreviewOptions::builder().is_disabled(true).build())
.reply_markup(ReplyMarkup::InlineKeyboardMarkup(keyboard))
.build();

Expand Down
9 changes: 5 additions & 4 deletions src/broadcasting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::time::Duration;
use bot_utils::ChatId;
use bot_utils::broadcasting::{Backend, NextUpdate};
use frankenstein::AsyncTelegramApi as _;
use frankenstein::types::LinkPreviewOptions;
use futures_util::{Stream, StreamExt, stream};
use regex::Regex;
use tokio::time::sleep;
Expand Down Expand Up @@ -119,8 +118,11 @@ impl Backend for RedisBackend {
NextUpdate::Ready { id: msg.0, msg }
}
Some(msg) => {
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,
Expand Down Expand Up @@ -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(&params).await?;

Expand Down
Loading