Renamed FETCH to RETRIEVE

This commit is contained in:
Jaidyn Ann 2024-12-18 13:08:34 -06:00
parent 258315b0d7
commit a84872309c
2 changed files with 12 additions and 12 deletions

View File

@ -31,7 +31,7 @@
"Our inbox, a simple list containing all received objects.") "Our inbox, a simple list containing all received objects.")
(defvar *config* (defvar *config*
'(:host "http://localhost:8080" :address "0.0.0.0" :port 8080 :fetch fetch)) '(:host "http://localhost:8080" :address "0.0.0.0" :port 8080 :retrieve retrieve))
(defvar *user-id-format* "~A/users/~A" (defvar *user-id-format* "~A/users/~A"
"The format we use for users @IDs/URIs. "The format we use for users @IDs/URIs.
@ -62,7 +62,7 @@ For example: “https://localhost:8080/users/lena”.")
;;; Activity-Servist callbacks ;;; Activity-Servist callbacks
;;; ———————————————————————————————————————— ;;; ————————————————————————————————————————
(defun fetch (uri) (defun retrieve (uri)
"activity-servist callback: Returns the JSON-LD OBJECT of the given @ID or URI "activity-servist callback: Returns the JSON-LD OBJECT of the given @ID or URI
from our object-store. from our object-store.
This example server simply stores objects in a hash-table mapping IDs to objects." This example server simply stores objects in a hash-table mapping IDs to objects."

View File

@ -45,9 +45,9 @@ There are three optional properties:
inbox should be deduced by the objects contents. inbox should be deduced by the objects contents.
There is one required property: There is one required property:
:FETCH, a function used as a callback by activity-servist. :RETRIEVE, a function used as a callback by activity-servist.
:FETCH should be a function of (FETCH URI) :RETRIEVE should be a function of (RETRIEVE URI)
This function should simply return an object from your storage, queried by a URI. This function should simply return an object from your storage, queried by a URI.
The URI parameter is going to be either an @ID or an account-URI of the form acct:username@hostname.") The URI parameter is going to be either an @ID or an account-URI of the form acct:username@hostname.")
@ -69,13 +69,13 @@ The URI parameter is going to be either an @ID or an account-URI of the form “
;;; Callbacks ;;; Callbacks
;;; ———————————————————————————————————————— ;;; ————————————————————————————————————————
(defun fetch (uri) (defun retrieve (uri)
"Runs the user-defined callback FETCH, as stored in *CONFIG*. "Runs the user-defined callback RETRIEVE, as stored in *CONFIG*.
Returns the ActivityPub object associated with the given URI." Returns the object associated with the given URI from our object-store."
(let ((func (getf *config* :fetch))) (let ((func (getf *config* :retrieve)))
(if func (if func
(funcall func uri) (funcall func uri)
(error "No FETCH function found in ACTIVITY-SERVIST:*CONFIG*.")))) (error "No RETRIEVE function found in ACTIVITY-SERVIST:*CONFIG*."))))
(defgeneric receive (obj) (defgeneric receive (obj)
(:documentation (:documentation
@ -110,7 +110,7 @@ method will cause an error when an object is sent to the inbox."))
(defun webfinger-resource-info (resource) (defun webfinger-resource-info (resource)
"Given a Webfinger RESOURCE, return a property-list of data on the given resource. "Given a Webfinger RESOURCE, return a property-list of data on the given resource.
Will " Will "
(let ((obj (fetch resource))) (let ((obj (retrieve resource)))
(and obj (webfinger-info resource obj)))) (and obj (webfinger-info resource obj))))
(defgeneric webfinger-info (resource obj) (defgeneric webfinger-info (resource obj)
@ -141,10 +141,10 @@ For information on the property-lists format, see the dosctring of WEBTENTACL
;;; ———————————————————————————————————————— ;;; ————————————————————————————————————————
(defun http-object (env path-items params) (defun http-object (env path-items params)
"If an ActivityPub object is requested, serve it (if such an object "If an ActivityPub object is requested, serve it (if such an object
can be found). Uses the callback :FETCH, defined in *CONFIG*." can be found). Uses the callback :RETRIEVE, defined in *CONFIG*."
(let* ((uri (reduce (lambda (a b) (format nil "~A/~A" a b)) (let* ((uri (reduce (lambda (a b) (format nil "~A/~A" a b))
(append (list (getf *config* :host)) path-items))) (append (list (getf *config* :host)) path-items)))
(obj (fetch uri))) (obj (retrieve uri)))
(if obj (if obj
(list 200 '(:content-type "application/activity+json") (list 200 '(:content-type "application/activity+json")
(list (yason:with-output-to-string* () (yason:encode-object obj)))) (list (yason:with-output-to-string* () (yason:encode-object obj))))