2021-11-20 12:17:22 +01:00
|
|
|
;; tinmop module to delete multiple posts matching a regular expression
|
|
|
|
;; Copyright © 2021 cage
|
|
|
|
|
|
|
|
;; This program is free software: you can redistribute it and/or modify
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
;; 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 General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
(in-package :modules)
|
|
|
|
|
|
|
|
(defun mark-message-deleted-by-regex (regex)
|
2022-09-06 18:33:20 +02:00
|
|
|
(a:when-let ((scanner (ignore-errors (create-scanner regex))))
|
2021-11-20 12:17:22 +01:00
|
|
|
(with-accessors ((row-selected-index row-selected-index)
|
|
|
|
(timeline-type thread-window:timeline-type)
|
|
|
|
(timeline-folder thread-window:timeline-folder)) *thread-window*
|
2021-11-26 10:59:50 +01:00
|
|
|
|
2021-11-20 12:17:22 +01:00
|
|
|
(let ((event-payload
|
|
|
|
(lambda ()
|
2021-11-26 10:59:50 +01:00
|
|
|
(db-utils:with-ready-database (:connect nil)
|
|
|
|
(let ((rows (db:all-messages-timeline-folder timeline-type
|
|
|
|
timeline-folder)))
|
|
|
|
(mapcar (lambda (row)
|
|
|
|
(let* ((user (db:row-message-username row))
|
|
|
|
(subject (db:row-message-subject row))
|
|
|
|
(status-id (db:row-message-status-id row)))
|
|
|
|
(when (or (scan scanner user)
|
|
|
|
(scan scanner subject))
|
2021-11-30 21:18:09 +01:00
|
|
|
(db:mark-status-read timeline-type
|
|
|
|
timeline-folder
|
|
|
|
status-id)
|
|
|
|
(db:mark-status-deleted timeline-type
|
|
|
|
timeline-folder
|
|
|
|
status-id))))
|
2021-11-26 10:59:50 +01:00
|
|
|
rows)
|
|
|
|
(line-oriented-window:resync-rows-db *thread-window* :redraw t))))))
|
2021-11-20 12:17:22 +01:00
|
|
|
(push-event (make-instance 'function-event
|
|
|
|
:payload event-payload))))))
|
|
|
|
|
|
|
|
(defun delete-post-using-regex ()
|
2021-11-26 10:59:50 +01:00
|
|
|
"Delete all posts matching (in field username or subject) a regular expression."
|
2021-11-20 12:17:22 +01:00
|
|
|
(flet ((on-input-complete (regex)
|
|
|
|
(mark-message-deleted-by-regex regex)))
|
|
|
|
(ask-string-input #'on-input-complete
|
2024-05-24 09:38:08 +02:00
|
|
|
:prompt (_ "Delete posts that match regex: "))))
|