aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.lisp26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/main.lisp b/src/main.lisp
index 9145a8a..2c5f466 100644
--- a/src/main.lisp
+++ b/src/main.lisp
@@ -69,8 +69,9 @@
(defun can-invite-p (contributor)
"Returns T if the contributor is currently allowed to make more invites."
- (with-plist (limit made) (contributor-invites contributor)
- (< made limit)))
+ (or (adminp contributor)
+ (with-plist (limit made) (contributor-invites contributor)
+ (< made limit))))
(defclass api-access (db:store-object)
((token
@@ -328,12 +329,14 @@
:brief brief
:runstyle (or runstyle :auto))))
-(defun flag-oneliner (oneliner &optional contributor)
- "Flag a oneliner for review. If locked, ensure that CONTRIBUTOR is an admin. Returns T or NIL."
- (when (or (not (lockedp oneliner)) (and contributor (adminp contributor)))
- (db:with-transaction ()
- (setf (flagged-by oneliner) (or contributor :anonymous))
- t)))
+
+(defun unflag-oneliner (oneliner)
+ (db:with-transaction ()
+ (setf (flagged-by oneliner) nil)))
+
+(defun flag-oneliner (oneliner contributor)
+ (db:with-transaction ()
+ (setf (flagged-by oneliner) contributor)))
(defun lock-oneliner (oneliner contributor)
"Locks a oneliner. Only admins can lock and unlock."
@@ -534,12 +537,15 @@ admin privileges are allowed to perform this action."
(apply 'edit-oneliner entry (api-contributor token) (lzb:request-body))
"true")
-(defendpoint* :put "/oneliner/:entry a-oneliner-id:/flag" ((token an-api-token))
+(defendpoint* :put "/oneliner/:entry a-oneliner-id:/flag" ((token an-api-token)
+ (value a-boolean))
(:auth t)
"Flag the oneliner for review."
(when (and (lockedp entry) (not (adminp (api-contributor token))))
(http-err 403))
- (flag-oneliner entry (api-contributor token))
+ (if value
+ (flag-oneliner entry (api-contributor token))
+ (unflag-oneliner entry))
"true")
(defendpoint* :get "/oneliners" ((tags a-csl)