chibipub

experimental activitypub node in C
git clone git://jb55.com/chibipub
Log | Files | Refs | README | LICENSE

commit e3b60baadf56938bb91ce80aa36cd10dee9e7308
parent 2e7e41c8ed2c5374fa5cfdcd0a137bd32b263fab
Author: William Casarin <jb55@jb55.com>
Date:   Sat,  6 Mar 2021 13:12:47 -0800

activity: separate host from id

so we can host chibipub on a subdomain but still have our TLD be our ID

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Msrc/chibipub.c | 21+++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/chibipub.c b/src/chibipub.c @@ -41,6 +41,17 @@ static inline const char *get_hostname() return getenv("CHIBIPUB_HOST"); } +static inline const char *get_id() +{ + const char *ret; + ret = getenv("CHIBIPUB_ID"); + + if (!ret) + return get_hostname(); + + return ret; +} + #define SCHEMA "https://" @@ -259,10 +270,17 @@ static void test_profile(struct profile *p) make_cursor(buf, buf + sizeof(buf), &c); const char *host = get_hostname(); + const char *id = get_id(); + assert(host); p->id = (char*)c.p; assert( + push_str(&c, SCHEMA) && push_str(&c, id) && push_c_str(&c, "/") + ); + + p->url = (char*)c.p; + assert( push_str(&c, SCHEMA) && push_str(&c, host) && push_c_str(&c, "/") ); @@ -270,7 +288,6 @@ static void test_profile(struct profile *p) p->username = "jb55"; p->name = "William Casarin"; p->summary = "chibipub prototype"; - p->url = p->id; p->manually_approves_followers = 0; p->image_mime_type = "image/jpeg"; p->image_url = "https://jb55.com/s/blue-me.jpg"; @@ -309,7 +326,7 @@ static int handle_self(struct http_req *req) "\"publicKeyPem\": \"%s\"" "}" "}\n", - profile.id, + profile.url, profile.id, profile.type, profile.username,