From 3f69dca8bd78a299cdcacdf5757853e7261e77ee Mon Sep 17 00:00:00 2001 From: Jaidyn Ann <10477760+JadedCtrl@users.noreply.github.com> Date: Mon, 9 Dec 2024 21:23:25 -0600 Subject: [PATCH] Add :INBOX-PATH option, and start inbox requests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The inbox endpoint is just a stub, and doesn’t do anything yet. --- src/activity-servist.lisp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/activity-servist.lisp b/src/activity-servist.lisp index 8eb9a3f..1545d58 100644 --- a/src/activity-servist.lisp +++ b/src/activity-servist.lisp @@ -29,12 +29,18 @@ ;;; Globals ;;; ———————————————————————————————————————— -(defvar *config* '(:host "http://localhost:8080" :address "127.0.0.1" :port 8080) +(defvar *config* '(:host "http://localhost:8080" :address "127.0.0.1" :port 8080 + :inbox-path "inbox") "Configuration for the server, a property-list. There are three optional properties: • :HOST, the public-facing URI of the server. • :ADDRESS, the address the server is exposed on. • :PORT, the port the server is exposed on. +• :INBOX-PATH, the URI for your server’s shared/private inboxes. + +:INBOX-PATH is relative to :HOST; by default, it is “inbox”, which corresponds to +“http://localhost:8080/inbox”. The recipient(s) of any objects sent to the +inbox should be deduced by the objects’ contents. There is one required property: • :FETCH, a function used as a callback by activity-servist. @@ -45,9 +51,10 @@ The URI parameter is going to be either an @ID or an account-URI of the form “ (defun directories () "Alist of the server's paths and their response functions." - '((".well-known/webfinger" . http-webfinger) - (".well-known/host-meta" . http-host-meta) - ("" . http-object))) ; By default, assume object. + `((".well-known/webfinger" . http-webfinger) + (".well-known/host-meta" . http-host-meta) + ("inbox" . http-inbox) + ("" . http-object))) ; By default, assume object. (defvar *privkey* (alexandria:read-file-into-string @@ -134,6 +141,15 @@ can be found). Uses the callback :FETCH, defined in *CONFIG*." ("Such an object doesn’t exist!"))))) + +;;; Inbox requests +;;; ———————————————————————————————————————— +(defun http-inbox (env path-items params) + (let* ((raw-contents (alexandria:read-stream-content-into-byte-vector (getf env :raw-body))) + (contents (babel:octets-to-string raw-contents))) + '(400 (:content-type "text/plain") ("You tried!")))) + + ;;; Sending a note ;;; ————————————————————————————————————————