Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ getMessages: $(SRCS) $(EXAMPLES_DIR)/messaging/messages/getMessages.cpp
createMessage: $(SRCS) $(EXAMPLES_DIR)/messaging/messages/createMessage.cpp
@mkdir -p ./$(TESTS_DIR)
$(CXX) $(CXXFLAGS) -o ./$(TESTS_DIR)/createMessage $(SRCS) $(EXAMPLES_DIR)/messaging/messages/createMessage.cpp $(LDFLAGS)
listMessageLogs: $(SRCS) $(EXAMPLES_DIR)/messaging/messages/listMessageLogs.cpp
@mkdir -p ./$(TESTS_DIR)
$(CXX) $(CXXFLAGS) -o ./$(TESTS_DIR)/listMessageLogs $(SRCS) $(EXAMPLES_DIR)/messaging/messages/listMessageLogs.cpp $(LDFLAGS)
deleteMessages: $(SRCS) $(EXAMPLES_DIR)/messaging/messages/deleteMessages.cpp
@mkdir -p ./$(TESTS_DIR)
$(CXX) $(CXXFLAGS) -o ./$(TESTS_DIR)/deleteMessages $(SRCS) $(EXAMPLES_DIR)/messaging/messages/deleteMessages.cpp $(LDFLAGS)
Expand Down
21 changes: 21 additions & 0 deletions examples/messaging/messages/listMessageLogs.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "Appwrite.hpp"
#include <iostream>
int main() {
std::string projectId = "66fbb5a100070a3a1d19";
std::string apiKey = "";
std::string messageId = "688e98ba00107a10f041";

Appwrite appwrite(projectId, apiKey);
Queries queries;

queries.queryLimit(50);
try {
std::string response =
appwrite.getMessaging().listMessageLogs(messageId, queries);
std::cout << "Message logs fetched! \nResponse: " << response
<< std::endl;
} catch (const AppwriteException &ex) {
std::cerr << "Exception: " << ex.what() << std::endl;
}
return 0;
}
9 changes: 9 additions & 0 deletions include/classes/Messaging.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,20 @@ class Messaging {
const std::vector<std::string> &userId = {});

/**
* @brief List all message logs with optional filters.
* @param messageId ID of the message
* @param queries Query parameters for filtering
* @return JSON string of messageLog list
*/
std::string listMessageLogs(const std::string &messageId, Queries &queries);

/**
* @brief Delete a message by its ID.
* @param messageId ID of the message.
* @return JSON response.
*/
std::string deleteMessages(const std::string &messageId);

private:
std::string projectId; ///< Project ID
std::string apiKey; ///< API Key
Expand Down
19 changes: 19 additions & 0 deletions src/services/Messaging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,25 @@ std::string Messaging::updatePush(const std::string &messageId,
}
}


std::string Messaging::listMessageLogs(const std::string &messageId,
Queries &queries) {
if (messageId.empty()) {
throw AppwriteException("Missing required parameter: messageId");
}
std::string url =
Config::API_BASE_URL + "/messaging/messages/" + messageId + "/logs";
std::vector<std::string> headers = Config::getHeaders(projectId);
headers.push_back("X-Appwrite-Key: " + apiKey);
std::string response;
int statusCode = Utils::getRequest(url, headers, response);
if (statusCode == HttpStatus::OK) {
return response;
} else {
throw AppwriteException("Error listing message logs. Status code: " +std::to_string(statusCode) + "\nResponse: " + response);
}
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is the } ?

Copy link
Contributor Author

@basant20415 basant20415 Aug 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it might be deleted when i tried to resolve conflicts ,should i create another pull request for this function or how can i add it?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to create another pull request, do your changes in this branch and push into the same branch itself

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this closing brace is already added in my code ,i think it's deleted while i'm trying to resolve the conflicts,i'll try to make any small changes in the function and push it again with the brace

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

std::string Messaging::deleteMessages(const std::string &messageId) {
if (messageId.empty()) {
throw AppwriteException("Missing required parameter: messageId");
Expand Down
Loading