summaryrefslogtreecommitdiff
path: root/haunt/jakob/dynamic/capabilities/rsvp.scm
diff options
context:
space:
mode:
Diffstat (limited to 'haunt/jakob/dynamic/capabilities/rsvp.scm')
-rw-r--r--haunt/jakob/dynamic/capabilities/rsvp.scm19
1 files changed, 13 insertions, 6 deletions
diff --git a/haunt/jakob/dynamic/capabilities/rsvp.scm b/haunt/jakob/dynamic/capabilities/rsvp.scm
index 86fc671..60625a0 100644
--- a/haunt/jakob/dynamic/capabilities/rsvp.scm
+++ b/haunt/jakob/dynamic/capabilities/rsvp.scm
@@ -30,6 +30,8 @@
#:use-module (web response)
#:use-module (web uri)
#:export (event-info-internal
+ create-new-event-rsvp
+ update-event-rsvp
get-event-info
post-event-rsvp))
@@ -262,10 +264,15 @@ It is a base64 string, encoding `%vanity-length' bytes of randomness."
(else (panic "invalid invitation or receipt code")))))
(define (event-info-internal invitation-code)
- (unless (valid-invite-code invitation-code)
+ (unless (or (valid-invite-code invitation-code)
+ (valid-receipt-code invitation-code))
(panic "invalid invite or receipt code"))
(let* ((rsvp (exec-query conn "SELECT invitation_id, fullname, email, attending, guests FROM rsvps WHERE vanity = $1" (list invitation-code)))
- (invitation (invitation->event-id invitation-code))
+ ;; If `invitation-code' specifies a valid receipt, use it as such.
+ ;; Otherwise, treat it as an invitation code.
+ (invitation (invitation->event-id (if (positive? (length rsvp))
+ (caar rsvp)
+ invitation-code)))
(capabilities (cadr invitation))
(event (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)))))
@@ -276,10 +283,10 @@ It is a base64 string, encoding `%vanity-length' bytes of randomness."
(image . ,(get-event-image (car invitation)))
(date . ,date)
(location . ,location)
- (name . ,(list-ref (car rsvp) 1))
- (email . ,(list-ref (car rsvp) 2))
- (attending . ,(list-ref (car rsvp) 3))
- (guests . ,(list-ref (car rsvp) 4))
+ (name . ,(and (positive? (length rsvp)) (list-ref (car rsvp) 1)))
+ (email . ,(and (positive? (length rsvp)) (list-ref (car rsvp) 2)))
+ (attending . ,(and (positive? (length rsvp)) (list-ref (car rsvp) 3)))
+ (guests . ,(and (positive? (length rsvp)) (list-ref (car rsvp) 4)))
,@(if (= 1 (logand (string->number capabilities) 1))
`((rsvps . ,(list->vector (map format-rsvp rsvps))))
'()))))))