From f38e0aef42ee314d866f010a3317884e6761f343 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Mon, 10 Oct 2022 20:11:57 +0100 Subject: [PATCH] integrate Meilisearch into edit keywords functionality (web.lisp). --- src/web.lisp | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/src/web.lisp b/src/web.lisp index cdbe155..91c7d03 100644 --- a/src/web.lisp +++ b/src/web.lisp @@ -1270,22 +1270,33 @@ (utils:set-alert "Keywords not provided. Not updated." "missing-data") (redirect "/user/archive")) - ((null (nera:get-archive-entry :slug archive-slug)) - (utils:set-alert "Cannot file archive entry. Keywords not updated." - "invalid-data") + (utils:set-alert + "Cannot file archive entry. Keywords not updated." + "invalid-data") (redirect "/user/archive")) - - (t (nera:update-archive-entry-property - :slug archive-slug - :property 'archive::keywords-of - :value (utils:format-keywords new-keywords)) - ;; Integrate updating Meilisearch here. - (utils:set-alert "Archive entry updated." "success") - (redirect (format nil "/edit/archive/~a" archive-slug)))) + (t (let ((archive-entry (nera:get-archive-entry :slug archive-slug)) + (keywords (utils:format-keywords new-keywords))) + (nera:update-archive-entry-property + :slug archive-slug + :property 'archive::keywords-of + :value keywords) + (search:submit-entry + (search:build-payload + (archive::search-id-of archive-entry) + (archive::title-of archive-entry) + (format nil "view/archive/~a" + (archive::slug-of archive-entry)) + (format nil "storage/thumb/archive/~a" + (archive::slug-of archive-entry)) + (mito.dao.mixin:object-created-at archive-entry) + keywords)) + (utils:set-alert "Archive entry updated." "success") + (redirect (format nil "/edit/archive/~a" archive-slug))))) ;; Not Authorised - (progn (utils:set-alert "You are not authorised to delete this archive entry." - "error") + (progn (utils:set-alert + "You are not authorised to delete this archive entry." + "error") (redirect "/login"))))))) (defroute ("/edit/archive" :method :POST) ()