@@ -17,7 +17,7 @@ void handleCustomRecipePublicationHistoryCQ(
1717
1818 if (data == " backFromRules" ) {
1919 auto history = api.getRecipesApi ().getRecipeRequestHistory (userId, state.recipeId );
20- renderPublicationHistory (userId, chatId, state.recipeName , history, bot);
20+ renderPublicationHistory (userId, chatId, state.recipeName , state. errorReport , history, bot);
2121 bot.answerCallbackQuery (cq.id );
2222 return ;
2323 }
@@ -36,19 +36,25 @@ void handleCustomRecipePublicationHistoryCQ(
3636 }
3737
3838 if (data == " confirm" ) {
39- // Peeking (if button with this data then accepted or pending)
40- auto history = api.getRecipesApi ().getRecipeRequestHistory (userId, state.recipeId );
4139
40+ auto history = api.getRecipesApi ().getRecipeRequestHistory (userId, state.recipeId );
4241 // Here check for emptiness first, thanks to lazy compilator
43- const bool shouldPublish =
44- history. empty () || (history. back (). status == api::models::moderation::PublicationRequestStatus::REJECTED);
42+ const bool shouldPublish = history. empty () || (history. back (). status . status ==
43+ api::models::moderation::PublicationRequestStatus::REJECTED);
4544
4645 if (shouldPublish) {
47- api.getRecipesApi ().publishCustom (userId, state.recipeId );
46+ try {
47+ api.getRecipesApi ().publishCustom (userId, state.recipeId );
48+ state.errorReport = " " ;
49+ } catch (...) {
50+ state.errorReport =
51+ utils::utf8str (u8" ⚠️Что-то пошло не так, вероятно ваш рецепт содержит неопубликованные ингредиенты" );
52+ bot.answerCallbackQuery (cq.id );
53+ }
4854 // Get updated history
4955 history = api.getRecipesApi ().getRecipeRequestHistory (userId, state.recipeId );
5056 }
51- renderPublicationHistory (userId, chatId, state.recipeName , history, bot);
57+ renderPublicationHistory (userId, chatId, state.recipeName , state. errorReport , history, bot);
5258 bot.answerCallbackQuery (cq.id );
5359 return ;
5460 }
0 commit comments