Remove layer of actor*, to avoid out-of-context field access; switch from 201 to 202 for posts

This commit is contained in:
Tony Garnock-Jones 2016-11-22 13:32:32 +13:00
parent 7dc47f53ff
commit d2c161fd3e
2 changed files with 25 additions and 27 deletions

View File

@ -86,10 +86,9 @@
(current-content body) (current-content body)
(current-content-type content-type) (current-content-type content-type)
(last-modified-seconds (current-seconds)) (last-modified-seconds (current-seconds))
(actor* (send! (notification self-url
(send! (notification self-url hub-url
hub-url self-url
self-url body
body content-type))
content-type)) (web-respond/status! id 202 #"Accepted")))))
(web-respond/status! id 201 #"Created"))))))

View File

@ -178,23 +178,22 @@
(on (web-request-incoming (id req) (vh host-name port) 'post ("sub" (,sub-id ())) $body) (on (web-request-incoming (id req) (vh host-name port) 'post ("sub" (,sub-id ())) $body)
;; TODO: verify the use of the shared secret ;; TODO: verify the use of the shared secret
(actor* (define parsed-link-headers (parse-link-headers (web-request-header-headers req)))
(define parsed-link-headers (parse-link-headers (web-request-header-headers req))) (define upstream-hub (link-header-ref parsed-link-headers 'hub #f))
(define upstream-hub (link-header-ref parsed-link-headers 'hub #f)) (define upstream-topic (link-header-ref parsed-link-headers 'self #f))
(define upstream-topic (link-header-ref parsed-link-headers 'self #f)) (define content-type (web-request-header-content-type req))
(define content-type (web-request-header-content-type req)) (web-respond/status! id 202 #"Accepted")
(log-info "Remote topic ~a got ~v message ~v; upstream hub ~v, topic ~v" (log-info "Remote topic ~a got ~v message ~v; upstream hub ~v, topic ~v"
full-topic full-topic
content-type content-type
body body
upstream-hub upstream-hub
upstream-topic) upstream-topic)
(current-content-hash (sha1 (open-input-bytes body))) (current-content-hash (sha1 (open-input-bytes body)))
(current-content-type content-type) (current-content-type content-type)
(current-upstream-hub upstream-hub) (current-upstream-hub upstream-hub)
(send! (notification full-topic (send! (notification full-topic
upstream-hub upstream-hub
upstream-topic upstream-topic
body body
content-type)) content-type))))))
(web-respond/status! id 201 #"Created"))))))