Redirected post interactions

FossilOrigin-Name: d9a930cb6cefa41ab2623d5d1fc0269b6cfd9cfeec3980e2854bc1b4a9a24a6e
This commit is contained in:
me@ow.nekobit.net 2022-02-24 03:05:23 +00:00
parent 9f7ba4b13b
commit 8d2afab0a4
2 changed files with 7 additions and 4 deletions

View file

@ -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 : "/");
}

View file

@ -21,7 +21,7 @@
#include <mastodont.h>
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);