| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
use chrono::{DateTime, Utc}; |
| 7 |
use sqlx::SqlitePool; |
| 8 |
|
| 9 |
use bb_interface::{ErrorCategory, StructuredError}; |
| 10 |
|
| 11 |
use crate::TIMESTAMP_FMT; |
| 12 |
use crate::id_types::{BookmarkId, BusserStateId, FeedId, ItemId, QueryFeedId}; |
| 13 |
use crate::models::{ |
| 14 |
CreateBookmark, CreateFeed, CreateFeedItem, CreateQueryFeed, DbBookmark, DbBusserState, DbFeed, |
| 15 |
DbFeedItem, DbQueryFeed, QueryCondition, UpdateBookmark, |
| 16 |
}; |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
fn sanitize_fts_query(query: &str) -> String { |
| 32 |
query |
| 33 |
.split_whitespace() |
| 34 |
.map(|word| { |
| 35 |
|
| 36 |
let escaped = word.replace('"', "\"\""); |
| 37 |
|
| 38 |
let escaped = escaped.trim_start_matches('^'); |
| 39 |
let escaped = escaped.trim_end_matches('*'); |
| 40 |
format!("\"{escaped}\"") |
| 41 |
}) |
| 42 |
|
| 43 |
.filter(|token| token != "\"\"") |
| 44 |
.collect::<Vec<_>>() |
| 45 |
.join(" ") |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
const MAX_SEARCH_QUERY_LENGTH: usize = 500; |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
pub const CIRCUIT_BREAKER_THRESHOLD: i64 = 10; |
| 61 |
|
| 62 |
mod bookmarks; |
| 63 |
mod config; |
| 64 |
mod feeds; |
| 65 |
mod items; |
| 66 |
mod query_feeds; |
| 67 |
mod state; |
| 68 |
mod tags; |
| 69 |
|
| 70 |
pub use bookmarks::*; |
| 71 |
pub use config::*; |
| 72 |
pub use feeds::*; |
| 73 |
pub use items::*; |
| 74 |
pub use query_feeds::*; |
| 75 |
pub use state::*; |
| 76 |
pub use tags::*; |
| 77 |
|
| 78 |
#[cfg(test)] |
| 79 |
mod tests; |
| 80 |
|