From 93128287314b93c933e2b8abe9ce84ea8e26f096 Mon Sep 17 00:00:00 2001 From: "me@ow.nekobit.net" Date: Tue, 5 Apr 2022 22:57:01 +0000 Subject: [PATCH] Status errors FossilOrigin-Name: e03432b221313a1384210dc09efb6cbe12716d2fc6b23e71293ee16f09785ecd --- src/status.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/status.c b/src/status.c index 93bbb3a..a48a5f9 100644 --- a/src/status.c +++ b/src/status.c @@ -26,6 +26,7 @@ #include "query.h" #include "cookie.h" #include "string_helpers.h" +#include "error.h" #include "reply.h" #include "attachments.h" #include "emoji_reaction.h" @@ -320,21 +321,24 @@ void content_status(struct session* ssn, mastodont_t* api, char** data, int is_r char* before_html = NULL, *stat_html = NULL, *after_html = NULL, *stat_reply = NULL; try_post_status(ssn, api); + mastodont_get_status_context(api, data[0], &storage, &statuses_before, &statuses_after, + &stat_before_len, &stat_after_len); // Get information - mastodont_get_status_context(api, data[0], &storage, &statuses_before, &statuses_after, - &stat_before_len, &stat_after_len); - mastodont_get_status(api, data[0], &status_storage, &status); - - // Before... - before_html = construct_statuses(api, statuses_before, stat_before_len, NULL); - - // Current status - stat_html = construct_status(api, &status, NULL, NULL, STATUS_FOCUSED); - if (is_reply) + if (mastodont_get_status(api, data[0], &status_storage, &status)) { - stat_reply = reply_status(data[0], - &status); + stat_html = construct_error("Status not found", NULL); + } + else { + before_html = construct_statuses(api, statuses_before, stat_before_len, NULL); + + // Current status + stat_html = construct_status(api, &status, NULL, NULL, STATUS_FOCUSED); + if (is_reply) + { + stat_reply = reply_status(data[0], + &status); + } } // After... @@ -366,4 +370,5 @@ void content_status(struct session* ssn, mastodont_t* api, char** data, int is_r mstdnt_cleanup_statuses(statuses_after, stat_after_len); mstdnt_cleanup_status(&status); mastodont_storage_cleanup(&storage); + mastodont_storage_cleanup(&status_storage); }