Add the STORE callback method
So activity-servist can ask the server to cache objects.
This commit is contained in:
parent
a37fc2bbfe
commit
fe188a8aa7
|
@ -76,6 +76,12 @@ inbox, and decide what to do with it!"
|
|||
(setq *inbox* (append *inbox* (list obj))))
|
||||
|
||||
|
||||
(defmethod as:store ((obj json-ld:object))
|
||||
"activity-servist callback: Store a foreign JSON-LD OBJECT (fetched during
|
||||
operation of the server) in our object-store."
|
||||
(setf (gethash (json-ld:@id obj) *store*) obj))
|
||||
|
||||
|
||||
|
||||
;;; ID-management
|
||||
;;; ————————————————————————————————————————
|
||||
|
@ -115,14 +121,6 @@ Otherwise, assume “https”."
|
|||
(format nil "https://~A" hostname))))
|
||||
|
||||
|
||||
|
||||
;;; Data-management
|
||||
;;; ————————————————————————————————————————
|
||||
(defun save (obj)
|
||||
"Save an object to our object-store, *STORE*."
|
||||
(setf (gethash (json-ld:@id obj) *store*) obj))
|
||||
|
||||
|
||||
|
||||
;;; Users
|
||||
;;; ————————————————————————————————————————
|
||||
|
|
|
@ -22,11 +22,12 @@
|
|||
;; Functions
|
||||
:server :start-server
|
||||
;; Methods
|
||||
:receive
|
||||
:receive :store
|
||||
;; Globals
|
||||
*config*))
|
||||
|
||||
(in-package #:activity-servist)
|
||||
(defvar *last* nil)
|
||||
|
||||
|
||||
;;; Globals
|
||||
|
@ -98,9 +99,18 @@ Actors, and then calls RECEIVE on them in turn."))
|
|||
(let* ((actor-uri (ignore-errors (activity-vocabulary:actor obj))))
|
||||
(when actor-uri
|
||||
(or (retrieve actor-uri)
|
||||
(fetch-and-receive actor-uri)))))
|
||||
(fetch-and-store actor-uri)))))
|
||||
|
||||
|
||||
(defgeneric store (obj)
|
||||
(:documentation
|
||||
"Stores an object in a object-store accessible with the callback function
|
||||
RETRIEVE, likely for caching purposes.
|
||||
|
||||
You should overload this generic with a method accepting JSON-LD:OBJECTs, as it
|
||||
is necessary for activity-servist to function. When called by activity-servist,
|
||||
this is solely used to store fetched foreign objects."))
|
||||
|
||||
|
||||
|
||||
;;; Fetching foreign objects
|
||||
|
|
Ŝarĝante…
Reference in New Issue