From 6c36357f24d1aeb537bfa2add1555e27c8fc7700 Mon Sep 17 00:00:00 2001 From: bru Date: Mon, 10 Jul 2023 17:07:50 -0300 Subject: Funcionalidad de borrar mensajes --- clients/emacs/bbj.el | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/clients/emacs/bbj.el b/clients/emacs/bbj.el index fe9ab7e..8b45461 100644 --- a/clients/emacs/bbj.el +++ b/clients/emacs/bbj.el @@ -74,6 +74,7 @@ obnoxious things for the sake of education ;)") (local-set-key (kbd "C-h SPC") 'bbj-pop-help) (local-set-key (kbd "?") 'bbj-pop-help) (local-set-key (kbd "e") 'bbj-edit-post) + (local-set-key (kbd "d") 'bbj-delete-post) (local-set-key (kbd "C-c C-c") 'bbj-aux) (local-set-key (kbd "r") 'bbj-quote-current-post)) @@ -109,7 +110,7 @@ obnoxious things for the sake of education ;)") ;; cuando lo único que tenía que hacer era redifinirla ;; para mi propio favor. ;; Lección aprendida. Aguante Emacs Lisp. -(defun url-http-create-request () +(defun bbj-url-http-create-request () (let* ((extra-headers) (request nil) (no-cache (cdr-safe (assoc "Pragma" url-http-extra-headers))) @@ -234,8 +235,11 @@ or can be ommitted to send no data." (url-request-method "POST") (url-request-data (when alist (json-encode-alist alist))) - (response (url-retrieve-synchronously - (format "http://%s:%s/api/%s" bbj-host bbj-port endpoint) t))) + (response + (cl-letf (((symbol-function 'url-http-create-request) + #'bbj-url-http-create-request)) + (url-retrieve-synchronously + (format "http://%s:%s/api/%s" bbj-host bbj-port endpoint) t)))) (when bbj-debug (switch-to-buffer response)) @@ -825,6 +829,25 @@ Eso es todo por ahora. (insert body) (goto-char (point-min)))) +(defun bbj-delete-post () + "Ask confirmation to delete the thread/post pointed by mark." + (interactive) + (let* ((data (bbj-post-prop 'data)) + (is-thread (or (eq bbj-buffer-type 'index) + (= (alist-get 'post_id data) 0)))) + (when (y-or-n-p (format "¿Seguro que quieres borrar permanentemente el %s?" + (if is-thread + "hilo entero" "post"))) + (bbj-request 'delete_post + 'thread_id (alist-get 'thread_id data) + 'post_id (or (alist-get 'post_id data) 0))) + (if is-thread + (progn + (message "hilo borrado") + (quit-window) + (bbj-browse-index)) + (message "post borrado") + (bbj-refresh)))) (defun bbj-browse-index () (interactive) -- cgit v1.2.3