diff --git a/docs/examples/simple-server.lisp b/docs/examples/simple-server.lisp index b6a2dbb..f7b0b75 100644 --- a/docs/examples/simple-server.lisp +++ b/docs/examples/simple-server.lisp @@ -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 ;;; ———————————————————————————————————————— diff --git a/src/activity-servist.lisp b/src/activity-servist.lisp index 6079bfe..c427852 100644 --- a/src/activity-servist.lisp +++ b/src/activity-servist.lisp @@ -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