Try interact status
FossilOrigin-Name: 93df0b275019b31e976f67ca127abf4c96f433cdf638a055fc75e4f7ef97da45
This commit is contained in:
parent
da2de57feb
commit
c633d81f10
4 changed files with 53 additions and 1 deletions
|
@ -50,6 +50,7 @@ void content_index(mastodont_t* api)
|
|||
}
|
||||
|
||||
try_post_status(api);
|
||||
try_interact_status(api);
|
||||
|
||||
easprintf(&output, "%s %s", data_post_html, status_format);
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ char* try_handle_post(void (*call)(struct http_query_info*, void*), void* arg)
|
|||
}
|
||||
read(STDIN_FILENO, post_query, content_length);
|
||||
post_query[content_length] = '\0';
|
||||
|
||||
|
||||
// For parse_query to shift through, so we can still free the original
|
||||
p_query_read = post_query;
|
||||
|
|
51
src/status.c
51
src/status.c
|
@ -24,13 +24,53 @@
|
|||
#include "cookie.h"
|
||||
#include "../static/status.chtml"
|
||||
|
||||
enum post_interact_type
|
||||
{
|
||||
POST_INTERACT_NONE,
|
||||
POST_INTERACT_LIKE,
|
||||
POST_INTERACT_REBLOG
|
||||
};
|
||||
|
||||
struct interact_args
|
||||
{
|
||||
mastodont_t* api;
|
||||
enum post_interact_type type;
|
||||
};
|
||||
|
||||
static void status_interact(struct http_query_info* info, void* _arg)
|
||||
{
|
||||
struct interact_args* arg = _arg;
|
||||
|
||||
if (strcmp(info->key, "itype") == 0)
|
||||
{
|
||||
if (strcmp(info->val, "like") == 0)
|
||||
{
|
||||
arg->type = POST_INTERACT_LIKE;
|
||||
}
|
||||
}
|
||||
else if (strcmp(info->key, "id") == 0)
|
||||
{
|
||||
struct mstdnt_storage storage;
|
||||
switch (arg->type)
|
||||
{
|
||||
case POST_INTERACT_LIKE:
|
||||
mastodont_favourite_status(arg->api,
|
||||
info->val,
|
||||
&storage);
|
||||
// mastodont_storage_cleanup(&storage);
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void status_post(struct http_query_info* info, void* arg)
|
||||
{
|
||||
mastodont_t* api = arg;
|
||||
|
||||
if (strcmp(info->key, "content") == 0)
|
||||
{
|
||||
struct http_cookie_info ck;
|
||||
struct mstdnt_storage storage;
|
||||
|
||||
// Cookie copy and read
|
||||
|
@ -61,6 +101,15 @@ int try_post_status(mastodont_t* api)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int try_interact_status(mastodont_t* api)
|
||||
{
|
||||
struct interact_args args;
|
||||
args.api = api;
|
||||
|
||||
char* post_query = try_handle_post(status_interact, &args);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char* construct_statuses(struct mstdnt_status* statuses, size_t size, size_t* ret_size)
|
||||
{
|
||||
char* stat_html, *result = NULL;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <mastodont.h>
|
||||
|
||||
int try_post_status(mastodont_t* api);
|
||||
int try_interact_status(mastodont_t* api);
|
||||
char* construct_statuses(struct mstdnt_status* statuses, size_t size, size_t* ret_size);
|
||||
|
||||
#endif // STATUS_H
|
||||
|
|
Loading…
Reference in a new issue