|
|
@@ -62,7 +62,7 @@
|
|
|
|
|
|
(defmethod %to-json ((track track))
|
|
|
(let ((album-artist (album-artist (track-album track)))
|
|
|
- (track-artist (track-artist track)))
|
|
|
+ (track-artist (track-artist track)))
|
|
|
(with-object
|
|
|
(maybe-key-value "artist" track-artist)
|
|
|
(maybe-key-value "album_artist" (unless (equal track-artist album-artist) album-artist))
|
|
|
@@ -136,7 +136,7 @@
|
|
|
|
|
|
(defmacro with-user ((info) &body body)
|
|
|
(with-gensyms (auth bearer headers)
|
|
|
- `(let* ((,headers (getf myway:*env* :headers)
|
|
|
+ `(let* ((,headers (getf myway:*env* :headers))
|
|
|
(,auth (ignore-errors (gethash "authorization" ,headers)))
|
|
|
(,bearer (when (and ,auth
|
|
|
(> (length (the string ,auth)) 7)
|
|
|
@@ -144,9 +144,9 @@
|
|
|
(subseq (the string ,auth) 7)))
|
|
|
(,info (when ,bearer (gethash ,bearer (server-token-user *server*)))))
|
|
|
(when (and (null ,info) (null (gethash "x-real-ip" ,headers)))
|
|
|
- (setf ,info `(:|username| "admin" :|id| 0 :|first_name| "cli" :|last_name| "admin")))
|
|
|
+ (setf ,info `(:|username| "admin" :|id| 0 :|first_name| "cli" :|last_name| "admin")))
|
|
|
(if ,info (handler-case (progn ,@body) (error (e) (log:error e) (print e)))
|
|
|
- +401+))))
|
|
|
+ +401+))))
|
|
|
|
|
|
(defun get-category-list (params)
|
|
|
(declare #.*standard-optimize-settings* (ignore params))
|
|
|
@@ -222,7 +222,7 @@
|
|
|
(bt:condition-wait *rescan-cond* *rescan-lock*)
|
|
|
(setf *rescan-active* t)
|
|
|
(handler-case (update-db)
|
|
|
- (error (e) (format t "Error updating db: ~a" e)))
|
|
|
+ (error (e) (format t "Error updating db: ~a" e)))
|
|
|
(setf *rescan-active* nil))))
|
|
|
|
|
|
(defun request-rescan (params)
|
|
|
@@ -239,18 +239,18 @@
|
|
|
(format-interval (getf stats :|duration|)))
|
|
|
(200-json (append stats
|
|
|
(list :|rescans| (subseq (the list *rescans*)
|
|
|
- 0 (min (length (the list *rescans*)) 10))))))))
|
|
|
+ 0 (min (length (the list *rescans*)) 10))))))))
|
|
|
|
|
|
(defvar *bot-token* nil "Login bot token")
|
|
|
(defun validate-user (info)
|
|
|
(let ((hash (prog1 (getf info :|hash|)
|
|
|
- (remf info :|hash|)))
|
|
|
- (check-string (format nil "~{~a=~a~^~%~}"
|
|
|
- (alist-plist
|
|
|
- (sort (plist-alist info) #'string-lessp
|
|
|
- :key #'(lambda (p) (symbol-name (car p)))))))
|
|
|
- (hmac (crypto:make-hmac
|
|
|
- (crypto:digest-sequence :sha256 (crypto:ascii-string-to-byte-array *bot-token*)) :sha256)))
|
|
|
+ (remf info :|hash|)))
|
|
|
+ (check-string (format nil "~{~a=~a~^~%~}"
|
|
|
+ (alist-plist
|
|
|
+ (sort (plist-alist info) #'string-lessp
|
|
|
+ :key #'(lambda (p) (symbol-name (car p)))))))
|
|
|
+ (hmac (crypto:make-hmac
|
|
|
+ (crypto:digest-sequence :sha256 (crypto:ascii-string-to-byte-array *bot-token*)) :sha256)))
|
|
|
(crypto:update-hmac hmac (trivial-utf-8:string-to-utf-8-bytes check-string))
|
|
|
(string-equal hash (crypto:byte-array-to-hex-string (crypto:hmac-digest hmac)))))
|
|
|
|
|
|
@@ -275,7 +275,7 @@
|
|
|
(defparameter +token-length+ 16)
|
|
|
(defun user-token (info)
|
|
|
(let ((token (crypto:byte-array-to-hex-string
|
|
|
- (crypto:random-data +token-length+))))
|
|
|
+ (crypto:random-data +token-length+))))
|
|
|
(setf (gethash token (server-token-user *server*)) info)
|
|
|
(save-server)
|
|
|
token))
|
|
|
@@ -329,8 +329,8 @@
|
|
|
;; Set up debug file server
|
|
|
(when serve-files
|
|
|
(loop for (path-prefix . url-prefix) in *path-url-mappings*
|
|
|
- do (myway:connect *mapper* (concatenate 'string url-prefix "*")
|
|
|
- (file-server path-prefix))))
|
|
|
+ do (myway:connect *mapper* (concatenate 'string url-prefix "*")
|
|
|
+ (file-server path-prefix))))
|
|
|
|
|
|
;; Start rescan processor
|
|
|
(setf *rescan-thread* (bt:make-thread 'rescanner :name "DB rescanner"))
|