aboutsummaryrefslogtreecommitdiff
path: root/lib/client.lisp
diff options
context:
space:
mode:
authorColin Okay <colin@cicadas.surf>2022-09-16 09:01:40 -0500
committerColin Okay <colin@cicadas.surf>2022-09-16 09:01:40 -0500
commit6597379eb5b28afefc72b7753aaa959d1b6beef7 (patch)
treeaa52c7d53b825bd8c1ec7343a21b86771460db21 /lib/client.lisp
parentb6c8013cbcd0100266f1bda436aa4075f70beee6 (diff)
Refactor: added assert-logged-in to functions that need itdev
Diffstat (limited to 'lib/client.lisp')
-rw-r--r--lib/client.lisp11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/client.lisp b/lib/client.lisp
index 527a300..0bc7ef8 100644
--- a/lib/client.lisp
+++ b/lib/client.lisp
@@ -142,7 +142,7 @@ running the body. If such a oneliner can be found."
;;; ADDING ONELINERS
(defun add-new-oneliner ()
- (api-token) ;; fails with error if not set.
+ (assert-logged-in)
;; read each field required to make a onelienr in from a prompt.
(let* ((name
(string-trim
@@ -205,7 +205,7 @@ running the body. If such a oneliner can be found."
;;; EDITING ONELINERS
(defun edit-item (ident &optional draftp)
- ;;(unless draftp (api-token)) ;; fails with error if not set.
+ (assert-logged-in)
(let ((ol (if draftp (fetch-draft ident) (the-oneliner ident))))
(let* ((name
(string-trim
@@ -267,6 +267,7 @@ running the body. If such a oneliner can be found."
(format t "Saved draft ~a~%" draft-name))))))
(defun publish-draft (name)
+ (assert-logged-in)
(when-draft (ol name)
(let ((updated
(jonathan:parse
@@ -285,6 +286,7 @@ running the body. If such a oneliner can be found."
;; ;;; ADMIN OF ONELINER ENTRIES
(defun delete-item (ident)
+ (assert-logged-in)
(when-oneliner (ol ident)
(api:delete-oneliner/oneliner ident (api-token) *host*)
;; if we've made it this far no http error has been returned,
@@ -292,24 +294,28 @@ running the body. If such a oneliner can be found."
(remove-from-cache ident)))
(defun flag-item (ident)
+ (assert-logged-in)
(when-oneliner (ol ident)
(api:put-oneliner/entry/flag ident (api-token) "true" *host*)
;; no http error, so we flag the cached version, ol.
(setf (oneliner-isflagged ol) t)))
(defun unflag-item (ident)
+ (assert-logged-in)
(when-oneliner (ol ident)
(api:put-oneliner/entry/flag ident (api-token) "false" *host*)
;; no http error, so we can unflag the cached version, ol
(setf (oneliner-isflagged ol) nil)))
(defun lock-item (ident)
+ (assert-logged-in)
(when-oneliner (ol ident)
(api:put-oneliner/oneliner/locked ident (api-token) "true" *host*)
;; no http error, so we can lock the cached version, ol
(setf (oneliner-islocked ol) t)))
(defun unlock-item (ident)
+ (assert-logged-in)
(when-oneliner (ol ident)
(api:put-oneliner/oneliner/locked ident (api-token) "false" *host*)
;; no http error, so we can unlock the cached version, ol
@@ -380,6 +386,7 @@ running the body. If such a oneliner can be found."
;;TODO: check this .. shouldnt access be a username??? yes!
(defun revoke-access ()
+ (assert-logged-in)
(api:delete-access/access (api-token) (api-token) *host*)
(format t "You were logged out~%"))