From 49fd32c3a71642dd504ae91cd52cabb822448316 Mon Sep 17 00:00:00 2001 From: nekobit Date: Wed, 6 Jul 2022 02:29:56 +0000 Subject: [PATCH] Get single chat FossilOrigin-Name: 11d28ba7876dec1e732d02559db31aa60fcb603eef462cbfa55786896c0efca2 --- include/mastodont_chats.h | 6 ++++++ src/chats.c | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/include/mastodont_chats.h b/include/mastodont_chats.h index 04a8ed8..033867e 100644 --- a/include/mastodont_chats.h +++ b/include/mastodont_chats.h @@ -73,4 +73,10 @@ int mastodont_get_chat_messages(mastodont_t* data, struct mstdnt_message* chats[], size_t* size); +int mastodont_get_chat(mastodont_t* data, + struct mstdnt_args* m_args, + char* chat_id, + struct mstdnt_storage* storage, + struct mstdnt_chat chat); + #endif // MASTODONT_CHATS_H diff --git a/src/chats.c b/src/chats.c index 675c8cd..4ada50a 100644 --- a/src/chats.c +++ b/src/chats.c @@ -172,3 +172,28 @@ int mastodont_get_chat_messages(mastodont_t* data, return mastodont_request(data, m_args, &req_args); } + +int mastodont_get_chat(mastodont_t* data, + struct mstdnt_args* m_args, + char* chat_id, + struct mstdnt_storage* storage, + struct mstdnt_chat chat) +{ + char url[MSTDNT_URLSIZE]; + snprintf(url, MSTDNT_URLSIZE, "api/v1/pleroma/chats/%s", chat_id); + + struct mastodont_request_args req_args = { + .storage = storage, + .url = url, + .params_query = NULL, + .params_query_len = NULL, + .params_post = NULL, + .params_post_len = 0, + .request_type = CURLOPT_HTTPGET, + .request_type_custom = NULL, + .args = NULL, + .callback = mstdnt_chat_json_callback, + }; + + return mastodont_request(data, m_args, &req_args); +}