diff --git a/include/mastodont_notification.h b/include/mastodont_notification.h new file mode 100644 index 0000000..8108b82 --- /dev/null +++ b/include/mastodont_notification.h @@ -0,0 +1,48 @@ +/* + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +#ifndef MASTODONT_NOTIFICATION +#define MASTODONT_NOTIFICATION +#include "mastodont_types.h" + +enum mstdnt_notification_type +{ + MSTDNT_NOTIFICATION_FOLLOW, + MSTDNT_NOTIFICATION_FOLLOW_REQUEST, + MSTDNT_NOTIFICATION_MENTION, + MSTDNT_NOTIFICATION_REBLOG, + MSTDNT_NOTIFICATION_FAVOURITE, + MSTDNT_NOTIFICATION_POLL, + MSTDNT_NOTIFICATION_STATUS, + MSTDNT_NOTIFICATION_EMOJI_REACT, + MSTDNT_NOTIFICATION_CHAT_MENTION, + MSTDNT_NOTIFICATION_REPORT +}; + +struct mstdnt_notification +{ + char* id; + enum mstdnt_notification_type type; +}; + +int mastodont_notifications(mastodont_t* data, + struct mstdnt_notification** notifs, + stuct mstdnt_storage* storage, + size_t* size); + +int mstdnt_load_account_from_json(struct mstdnt_notification* notif, cJSON* js); +void _mstdnt_val_notifications_call(cJSON* v, void* _type); + +#endif // MASTODONT_NOTIFICATION diff --git a/include/mastodont_status.h b/include/mastodont_status.h index 54c70f0..d27a7cc 100644 --- a/include/mastodont_status.h +++ b/include/mastodont_status.h @@ -152,4 +152,8 @@ int mastodont_favourite_status(mastodont_t* data, char* id, struct mstdnt_storage* storage); +int mastodont_reblog_status(mastodont_t* data, + char* id, + struct mstdnt_storage* storage); + #endif /* MASTODONT_STATUS */ diff --git a/src/notification.c b/src/notification.c new file mode 100644 index 0000000..c99eb2e --- /dev/null +++ b/src/notification.c @@ -0,0 +1,17 @@ +/* + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +#include + diff --git a/src/status.c b/src/status.c index 3f0be36..de7daf2 100644 --- a/src/status.c +++ b/src/status.c @@ -232,6 +232,25 @@ int mastodont_favourite_status(mastodont_t* data, return 0; } + +int mastodont_reblog_status(mastodont_t* data, + char* id, + struct mstdnt_storage* storage) +{ + char url[MSTDNT_URLSIZE]; + struct mstdnt_fetch_results results = { 0 }; + snprintf(url, MSTDNT_URLSIZE, + "api/v1/statuses/%s/reblog", id); + + storage->needs_cleanup = 0; + + if (mastodont_fetch_curl(data, url, &results, CURLOPT_POST) != CURLE_OK) + return 1; + + mastodont_fetch_results_cleanup(&results); + return 0; +} + int mastodont_view_status(mastodont_t* data, char* id, struct mstdnt_storage* storage,