From 659ef8ebccb97eecede22c5e43d9f9bb3f35bdee Mon Sep 17 00:00:00 2001 From: "Jakob L. Kreuze" Date: Tue, 23 Jul 2024 19:37:01 -0400 Subject: [dynamic] Add "end time" for events --- api.scm | 6 ++++-- jakob/dynamic/capabilities/rsvp.scm | 5 +++-- jakob/dynamic/schema-rsvp.sql | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/api.scm b/api.scm index fdc70ee..e3b121d 100644 --- a/api.scm +++ b/api.scm @@ -56,7 +56,7 @@ (define (clearnet-only handler) (lambda (request body) - (if (and (from-darknet? request) (not (%debug-enabled))) + (if (and (not (%debug-enabled)) (from-darknet? request)) (panic "This API is only available on the clearnet." #:code 403) (handler request body)))) @@ -77,7 +77,9 @@ (define (handle-api-request request body endpoint) "Route handler for the API server." (let ((method (request-method request)) - (originating-ip (assoc-ref (request-headers request) 'x-forwarded-for)) + (originating-ip (if (%debug-enabled) + "127.0.0.1" + (assoc-ref (request-headers request) 'x-forwarded-for))) (args (uri-query (request-uri request)))) (log-append! 'info (if args (format #f "~a ~a (~a) (~a)" method endpoint args originating-ip) diff --git a/jakob/dynamic/capabilities/rsvp.scm b/jakob/dynamic/capabilities/rsvp.scm index 4a7ada2..437f90a 100644 --- a/jakob/dynamic/capabilities/rsvp.scm +++ b/jakob/dynamic/capabilities/rsvp.scm @@ -220,7 +220,7 @@ It is a base64 string, encoding `%vanity-length' bytes of randomness." (invitation-code (or invitation-code code)) (invitation (invitation->event-id invitation-code)) (capabilities (cadr invitation)) - (((i_ title description date location)) + (((i_ title description date location end-date)) (exec-query conn "SELECT * FROM events WHERE id = $1" (list (car invitation)))) (rsvps (exec-query conn "SELECT fullname, email, attending, guests FROM rsvps WHERE event_id = $1" (list (car invitation))))) (values @@ -231,7 +231,8 @@ It is a base64 string, encoding `%vanity-length' bytes of randomness." (img (@ (src ,(format #f "data:image/webp;base64, ~a" (get-event-image (car invitation)))) (style "float: right; margin: 16px;"))) (p "Where: " ,location) - (p "When: " ,date) + (p "When: " ,date ) + (p "Ends at: " ,end-date) (p ,@(cdr (xml->sxml (format #f "
~a
" description))))) (form (@ (id "rsvp-input") (action "/apps/rsvp") diff --git a/jakob/dynamic/schema-rsvp.sql b/jakob/dynamic/schema-rsvp.sql index 3e6a21f..b56f9b5 100644 --- a/jakob/dynamic/schema-rsvp.sql +++ b/jakob/dynamic/schema-rsvp.sql @@ -4,6 +4,7 @@ CREATE TABLE IF NOT EXISTS events ( description varchar(16384) NOT NULL, datetime timestamp with time zone NOT NULL, location varchar(128) NOT NULL, + endtime timestamp with time zone NOT NULL, PRIMARY KEY (id) ); -- cgit v1.3