Status emoji react

FossilOrigin-Name: 0511a25748258626977a6f20dcc0b4ecead6a65cb4c0f9b9c7556c1b9c669b6a
This commit is contained in:
me@ow.nekobit.net 2022-05-08 06:11:56 +00:00
parent 0c68fb61bb
commit 9c7918ef68
6 changed files with 28 additions and 0 deletions

View file

@ -25,6 +25,7 @@
#include <mastodont_attachment.h>
#include <mastodont_scrobbles.h>
#include <mastodont_search.h>
#include <mastodont_announcement.h>
/* Functions required form curl */
void mastodont_global_curl_init();

View file

@ -34,6 +34,10 @@ struct mstdnt_emoji_reaction
char* name;
size_t count;
mstdnt_bool me;
// The following below are for custom emoji reactions
// They do not exist in Pleroma :^)
char* url;
char* static_url;
/* TODO Accounts */
};

View file

@ -104,6 +104,8 @@ int mstdnt_status_from_result(struct mstdnt_fetch_results* results,
struct mstdnt_status* status);
int mstdnt_status_from_json(struct mstdnt_status* status, cJSON* js);
int mastodont_status_emoji_react(mastodont_t* api, char* id, char* emoji,
struct mstdnt_storage* storage, struct mstdnt_status* status);
// Generated function
int mstdnt_statuses_json(struct mstdnt_status* statuses[],

View file

@ -150,3 +150,4 @@ int mastodont_obtain_oauth_token(mastodont_t* data,
return mastodont_request(data, &req_args);
}

View file

@ -46,6 +46,8 @@ void load_emoji_react_from_json(struct mstdnt_emoji_reaction* emo, cJSON* emo_js
struct _mstdnt_val_ref refs[] = {
{ "name", &(emo->name), _mstdnt_val_string_call },
{ "url", &(emo->url), _mstdnt_val_string_call },
{ "static_url", &(emo->static_url), _mstdnt_val_string_call },
{ "count", &(emo->count), _mstdnt_val_uint_call },
{ "me", &(emo->me), _mstdnt_val_bool_call },
};

View file

@ -528,6 +528,24 @@ int mastodont_get_favourites(mastodont_t* data,
return mastodont_request(data, &req_args);
}
int mastodont_status_emoji_react(mastodont_t* api, char* id, char* emoji,
struct mstdnt_storage* storage, struct mstdnt_status* status)
{
char url[MSTDNT_URLSIZE];
snprintf(url, MSTDNT_URLSIZE, "api/v1/pleroma/statuses/%s/reactions/%s", id, emoji);
struct mastodont_request_args req_args = {
storage,
url,
NULL, 0,
NULL, 0,
CURLOPT_PUT,
&status,
_mstdnt_status_from_result_callback
};
return mastodont_request(api, &req_args);
}
void mstdnt_cleanup_status(struct mstdnt_status* status)
{