1
0
mirror of https://codeberg.org/cage/tinmop/ synced 2025-02-17 08:10:36 +01:00

- [rpc] returned an error if a gemini stream can not be foud in 'gemini-stream-info'.

This commit is contained in:
cage 2023-01-01 20:05:20 +01:00
parent 5052c21fe3
commit f0862e3903

View File

@ -209,25 +209,24 @@
(defun rearrange-parsed-line-for-encoding (lines)
(flet ((contains-chldren-p (node)
(evenp (length node))))
(cons "lines"
(loop for line in lines
collect
(let ((flattened (mapcar #'rearrange-for-encoding (a:flatten line))))
(when flattened
(if (contains-chldren-p flattened)
(append (list (cons "type" (first flattened)))
(loop for (a b) on (subseq flattened
1
(1- (length flattened)))
by 'cddr
collect
(cons a b))
(list (cons "line" (a:last-elt flattened))))
(append (list (cons "type" (first flattened)))
(loop for (a b) on (subseq flattened 1)
by 'cddr
collect
(cons a b))))))))))
(loop for line in lines
collect
(let ((flattened (mapcar #'rearrange-for-encoding (a:flatten line))))
(when flattened
(if (contains-chldren-p flattened)
(append (list (cons "type" (first flattened)))
(loop for (a b) on (subseq flattened
1
(1- (length flattened)))
by 'cddr
collect
(cons a b))
(list (cons "line" (a:last-elt flattened))))
(append (list (cons "type" (first flattened)))
(loop for (a b) on (subseq flattened 1)
by 'cddr
collect
(cons a b)))))))))
(defmethod rpc::render-as-list ((object gw:gemini-stream))
(with-accessors ((stream-status gw:stream-status)
@ -268,12 +267,13 @@
(>= line-number 0)
(< line-number (length parsed-lines)))
(let ((res (rearrange-parsed-line-for-encoding (list (elt parsed-lines line-number)))))
(misc:dbg "res ~a res")
res))))
(defun gemini-stream-info (iri)
(a:when-let ((stream-wrapper (gw:find-db-stream-url iri)))
(rpc::render-as-list stream-wrapper)))
(let ((stream-wrapper (gw:find-db-stream-url iri)))
(if stream-wrapper
(rpc::render-as-list stream-wrapper)
(error "no such stream"))))
(defmacro prepare-rpc (&body body)
`(let ((rpc:*function-db* '()))