From a84872309c7774b8928ca8ba882b8fc1d49fbcd4 Mon Sep 17 00:00:00 2001 From: Jaidyn Ann <10477760+JadedCtrl@users.noreply.github.com> Date: Wed, 18 Dec 2024 13:08:34 -0600 Subject: [PATCH] Renamed FETCH to RETRIEVE --- docs/examples/simple-server.lisp | 4 ++-- src/activity-servist.lisp | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/examples/simple-server.lisp b/docs/examples/simple-server.lisp index 755a66c..b6a2dbb 100644 --- a/docs/examples/simple-server.lisp +++ b/docs/examples/simple-server.lisp @@ -31,7 +31,7 @@ "Our inbox, a simple list containing all received objects.") (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" "The format we use for user’s @IDs/URIs. @@ -62,7 +62,7 @@ For example: “https://localhost:8080/users/lena”.") ;;; Activity-Servist callbacks ;;; ———————————————————————————————————————— -(defun fetch (uri) +(defun retrieve (uri) "activity-servist callback: Returns the JSON-LD OBJECT of the given @ID or URI from our object-store. This example server simply stores objects in a hash-table mapping IDs to objects." diff --git a/src/activity-servist.lisp b/src/activity-servist.lisp index 06e18d2..0bb2d6e 100644 --- a/src/activity-servist.lisp +++ b/src/activity-servist.lisp @@ -45,9 +45,9 @@ There are three optional properties: inbox should be deduced by the objects’ contents. 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. 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 ;;; ———————————————————————————————————————— -(defun fetch (uri) - "Runs the user-defined callback FETCH, as stored in *CONFIG*. -Returns the ActivityPub object associated with the given URI." - (let ((func (getf *config* :fetch))) +(defun retrieve (uri) + "Runs the user-defined callback RETRIEVE, as stored in *CONFIG*. +Returns the object associated with the given URI from our object-store." + (let ((func (getf *config* :retrieve))) (if func (funcall func uri) - (error "No FETCH function found in ACTIVITY-SERVIST:*CONFIG*.")))) + (error "No RETRIEVE function found in ACTIVITY-SERVIST:*CONFIG*.")))) (defgeneric receive (obj) (:documentation @@ -110,7 +110,7 @@ method will cause an error when an object is sent to the inbox.")) (defun webfinger-resource-info (resource) "Given a Webfinger RESOURCE, return a property-list of data on the given resource. Will " - (let ((obj (fetch resource))) + (let ((obj (retrieve resource))) (and obj (webfinger-info resource obj)))) (defgeneric webfinger-info (resource obj) @@ -141,10 +141,10 @@ For information on the property-list’s format, see the dosctring of WEBTENTACL ;;; ———————————————————————————————————————— (defun http-object (env path-items params) "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)) (append (list (getf *config* :host)) path-items))) - (obj (fetch uri))) + (obj (retrieve uri))) (if obj (list 200 '(:content-type "application/activity+json") (list (yason:with-output-to-string* () (yason:encode-object obj))))