diff --git a/src/rss_thread_watch/filters.clj b/src/rss_thread_watch/filters.clj new file mode 100644 index 0000000..2df2b06 --- /dev/null +++ b/src/rss_thread_watch/filters.clj @@ -0,0 +1,32 @@ +;; Copyright (C) 2024 Felisp +;; +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU Affero General Public License as published by +;; the Free Software Foundation, version 3 of the License. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU Affero General Public License for more details. +;; +;; You should have received a copy of the GNU Affero General Public License +;; along with this program. If not, see . + +(ns rss-thread-watch.filters + "Functions filtering posts" + (:require [clojure.string :as cs] + [rss-thread-watch.utils :as u]) + (:gen-class)) + +(defn case-sensitive-filter + "Returns true if string [s] is matched by any query. It's case insensitive" + [s queries] + (some (fn [querry] + (cs/includes? s querry)) + queries)) + +(defn case-insensitive-filter + "Returns true if string [s] is case-matched by query" + [s queries] + (basic-filter (cs/lower-case s) (cs/lower-case s))) +