diff options
| author | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2022-12-03 12:57:43 -0500 |
|---|---|---|
| committer | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2022-12-03 12:57:43 -0500 |
| commit | 59f3b1b7899e11a7b6c117e25041245c8acf65d6 (patch) | |
| tree | cb96437088dd2779b32f10f53c0f30e75ff180e6 | |
| parent | cce41bf0df30a52a32daedb717c3a21181635dcf (diff) | |
[dynamic] Reach out to API instead of PostgreSQL
| -rw-r--r-- | haunt/jakob/dynamic/capabilities/comments.scm | 1 | ||||
| -rw-r--r-- | haunt/jakob/dynamic/rate-limiter.scm | 5 | ||||
| -rw-r--r-- | haunt/jakob/utils/comments.scm | 10 |
3 files changed, 14 insertions, 2 deletions
diff --git a/haunt/jakob/dynamic/capabilities/comments.scm b/haunt/jakob/dynamic/capabilities/comments.scm index ee4172c..1346ee4 100644 --- a/haunt/jakob/dynamic/capabilities/comments.scm +++ b/haunt/jakob/dynamic/capabilities/comments.scm @@ -33,6 +33,7 @@ put-comment put-reaction + json->internal-comment internal-comment? internal-comment-id internal-comment-name diff --git a/haunt/jakob/dynamic/rate-limiter.scm b/haunt/jakob/dynamic/rate-limiter.scm index d6ef28c..fb251a1 100644 --- a/haunt/jakob/dynamic/rate-limiter.scm +++ b/haunt/jakob/dynamic/rate-limiter.scm @@ -35,7 +35,10 @@ (define active-rate-limits (make-hash-table)) -(define (rate-limit-for-endpoint name) 32) +(define (rate-limit-for-endpoint name) + (case name + ((get-comments) 1024) + (else 32))) (define (increment-key! hash-table key) (let ((new-value (if (hash-ref hash-table key) diff --git a/haunt/jakob/utils/comments.scm b/haunt/jakob/utils/comments.scm index e228a6d..8678a3a 100644 --- a/haunt/jakob/utils/comments.scm +++ b/haunt/jakob/utils/comments.scm @@ -213,7 +213,15 @@ (define (fetch-comments slug) "Blocking call to webmention.io to retrieve a vector of all Webmentions for `slug'" - (get-comments-by-slug slug)) + (let ((url (format #f "https://jakob.space/api/comments?p=~a" slug))) + (receive (response-status response-body) + (http-request url) + (chain response-body + (bytevector->string _ "UTF-8") + (json-string->scm _) + (vector->list _) + (map scm->json-string _) + (map (lambda (x) (call-with-input-string x json->internal-comment)) _))))) (define (fetch-webmentions slug) "Blocking call to webmention.io to retrieve a vector of all Webmentions for `slug'" |