From 8d2afab0a4267963a3794030dedb291672561c2d Mon Sep 17 00:00:00 2001 From: "me@ow.nekobit.net" Date: Thu, 24 Feb 2022 03:05:23 +0000 Subject: [PATCH] Redirected post interactions FossilOrigin-Name: d9a930cb6cefa41ab2623d5d1fc0269b6cfd9cfeec3980e2854bc1b4a9a24a6e --- src/status.c | 9 ++++++--- src/status.h | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/status.c b/src/status.c index 3ab62ed..d5362a7 100644 --- a/src/status.c +++ b/src/status.c @@ -58,16 +58,16 @@ int try_post_status(mastodont_t* api) return 0; } -int try_interact_status(mastodont_t* api) +int try_interact_status(mastodont_t* api, char* id) { struct mstdnt_storage storage; - if (!(post.itype && post.id)) return 1; + if (!(post.itype && id)) return 1; // Pretty up the type if (strcmp(post.itype, "like") == 0) { mastodont_favourite_status(api, - post.id, + id, &storage); // TODO Cleanup when errors handled // mastodont_storage_cleanup(&storage); @@ -117,6 +117,9 @@ char* construct_statuses(struct mstdnt_status* statuses, size_t size, size_t* re void status_interact(mastodont_t* api, char** data, size_t data_size) { char* referer = getenv("HTTP_REFERER"); + + try_interact_status(api, data[0]); + printf("Location: %s\r\n\r\nRedirecting...", referer ? referer : "/"); } diff --git a/src/status.h b/src/status.h index 6c26125..c9c26e2 100644 --- a/src/status.h +++ b/src/status.h @@ -21,7 +21,7 @@ #include int try_post_status(mastodont_t* api); -int try_interact_status(mastodont_t* api); +int try_interact_status(mastodont_t* api, char* id); char* construct_status(struct mstdnt_status* status, int* size); char* construct_statuses(struct mstdnt_status* statuses, size_t size, size_t* ret_size); void content_status(mastodont_t* api, char** data, size_t data_size);