Reblog, notification header

FossilOrigin-Name: d52136c10ff0debd125cbfea3bdf9de4b6b3fff36c56c4935cc706760307ecc6
This commit is contained in:
me@ow.nekobit.net 2022-03-02 15:30:38 +00:00
parent 4e2ae058e6
commit ec2cd08e7e
4 changed files with 88 additions and 0 deletions

View file

@ -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 <https://www.gnu.org/licenses/>.
*/
#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

View file

@ -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 */

17
src/notification.c Normal file
View file

@ -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 <https://www.gnu.org/licenses/>.
*/
#include <mastodont_notification.h>

View file

@ -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,