Skip to content

Commit 6e19e71

Browse files
authored
Merge branch 'develop' into listLog_branch
2 parents 8dfae7d + 70a3b33 commit 6e19e71

File tree

5 files changed

+52
-10
lines changed

5 files changed

+52
-10
lines changed

.github/workflows/doxygen.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,48 @@
11
name: "Build & Deploy Doxygen Docs"
22

33
on:
4+
workflow_dispatch:
45
pull_request:
56
types: [closed]
67
branches:
78
- develop
89

910
jobs:
1011
build-and-deploy:
11-
if: github.event.pull_request.merged == true
12+
if: github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true
1213
runs-on: ubuntu-latest
1314

1415
permissions:
15-
contents: write
16-
pages: write
16+
contents: write
17+
pages: write
1718

1819
steps:
1920
- name: Checkout code
2021
uses: actions/checkout@v3
2122
with:
2223
fetch-depth: 0
24+
submodules: false
2325

2426
- name: Install Doxygen
2527
run: sudo apt-get update && sudo apt-get install -y doxygen graphviz
2628

2729
- name: Generate Doxygen HTML
2830
run: doxygen ./Doxyfile
2931

30-
- name: Clone docs branch
32+
- name: Clone docs branch into docs-out/
3133
run: |
32-
git clone --branch docs https://x-access-token:${{ secrets.USER_SECRET }}@github.com/${{ github.repository }} docs-out
34+
git clone --branch docs https://x-access-token:${{ secrets.USER_TOKEN }}@github.com/${{ github.repository }} docs-out
3335
34-
- name: Copy generated HTML
36+
- name: Copy generated HTML into docs-out/
3537
run: |
3638
rm -rf docs-out/*
3739
cp -R docs/html/* docs-out/
3840
39-
- name: Commit & Push
40-
working-directory: docs-out
41+
- name: Commit and push to docs branch
4142
run: |
43+
cd docs-out
4244
git config user.name "github-actions[bot]"
4345
git config user.email "github-actions[bot]@users.noreply.github.com"
4446
git add .
4547
git commit -m "Regenerate Doxygen docs from ${{ github.sha }}" || echo "No changes to commit"
46-
git push
48+
git push --force https://x-access-token:${{ secrets.USER_TOKEN }}@github.com/${{ github.repository }}.git HEAD:docs

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,10 @@ createMessage: $(SRCS) $(EXAMPLES_DIR)/messaging/messages/createMessage.cpp
257257
listMessageLogs: $(SRCS) $(EXAMPLES_DIR)/messaging/messages/listMessageLogs.cpp
258258
@mkdir -p ./$(TESTS_DIR)
259259
$(CXX) $(CXXFLAGS) -o ./$(TESTS_DIR)/listMessageLogs $(SRCS) $(EXAMPLES_DIR)/messaging/messages/listMessageLogs.cpp $(LDFLAGS)
260-
260+
deleteMessages: $(SRCS) $(EXAMPLES_DIR)/messaging/messages/deleteMessages.cpp
261+
@mkdir -p ./$(TESTS_DIR)
262+
$(CXX) $(CXXFLAGS) -o ./$(TESTS_DIR)/deleteMessages $(SRCS) $(EXAMPLES_DIR)/messaging/messages/deleteMessages.cpp $(LDFLAGS)
263+
261264
# Messaging - Topics
262265
getTopic: $(SRCS) $(EXAMPLES_DIR)/messaging/topics/getTopic.cpp
263266
@mkdir -p ./$(TESTS_DIR)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include "Appwrite.hpp"
2+
#include <iostream>
3+
int main() {
4+
std::string projectId = "68853010003a3f4fc106";
5+
std::string apiKey = "";
6+
std::string messageId = "";
7+
try {
8+
Appwrite appwrite(projectId, apiKey);
9+
std::string response =
10+
appwrite.getMessaging().deleteMessages(messageId);
11+
std::cout << "Message deleted successfully! \nResponse: " << response
12+
<< std::endl;
13+
} catch (const AppwriteException &ex) {
14+
std::cerr << "Exception: " << ex.what() << std::endl;
15+
}
16+
return 0;
17+
}

include/classes/Messaging.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ class Messaging {
181181
* @return JSON string of messageLog list
182182
*/
183183
std::string listMessageLogs(const std::string &messageId, Queries &queries);
184+
185+
* @brief Delete a message by its ID.
186+
* @param messageId ID of the message.
187+
* @return JSON response.
188+
*/
189+
std::string deleteMessages(const std::string &messageId);
184190
private:
185191
std::string projectId; ///< Project ID
186192
std::string apiKey; ///< API Key

src/services/Messaging.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,20 @@ std::string Messaging::listMessageLogs(const std::string &messageId,
545545
return response;
546546
} else {
547547
throw AppwriteException("Error listing message logs. Status code: " +
548+
549+
std::string Messaging::deleteMessages(const std::string &messageId) {
550+
if (messageId.empty()) {
551+
throw AppwriteException("Missing required parameter: messageId");
552+
}
553+
std::string url = Config::API_BASE_URL + "/messaging/messages/" + messageId;
554+
std::vector<std::string> headers = Config::getHeaders(projectId);
555+
headers.push_back("X-Appwrite-Key: " + apiKey);
556+
std::string response;
557+
int statusCode = Utils::deleteRequest(url, headers, response);
558+
if (statusCode == HttpStatus::DELETED) {
559+
return "Message deleted.";
560+
} else {
561+
throw AppwriteException("Failed to delete message. Status code: " +
548562
std::to_string(statusCode) +
549563
"\nResponse: " + response);
550564
}

0 commit comments

Comments
 (0)