Skip to content

Commit 8285692

Browse files
authored
Merge branch 'develop' into list_provider_logs
2 parents 5d0c44b + 6ba2b75 commit 8285692

11 files changed

Lines changed: 378 additions & 13 deletions

File tree

.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: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,28 @@ getMessages: $(SRCS) $(EXAMPLES_DIR)/messaging/messages/getMessages.cpp
254254
createMessage: $(SRCS) $(EXAMPLES_DIR)/messaging/messages/createMessage.cpp
255255
@mkdir -p ./$(TESTS_DIR)
256256
$(CXX) $(CXXFLAGS) -o ./$(TESTS_DIR)/createMessage $(SRCS) $(EXAMPLES_DIR)/messaging/messages/createMessage.cpp $(LDFLAGS)
257+
createFcmProvider: $(SRCS) $(EXAMPLES_DIR)/messaging/messages/createFcmProvider.cpp
258+
@mkdir -p ./$(TESTS_DIR)
259+
$(CXX) $(CXXFLAGS) -o ./$(TESTS_DIR)/createFcmProvider $(SRCS) $(EXAMPLES_DIR)/messaging/messages/createFcmProvider.cpp $(LDFLAGS)
260+
deleteProvider: $(SRCS) $(EXAMPLES_DIR)/messaging/messages/deleteProvider.cpp
261+
@mkdir -p ./$(TESTS_DIR)
262+
$(CXX) $(CXXFLAGS) -o ./$(TESTS_DIR)/deleteProvider $(SRCS) $(EXAMPLES_DIR)/messaging/messages/deleteProvider.cpp $(LDFLAGS)
263+
getProvider: $(SRCS) $(EXAMPLES_DIR)/messaging/messages/getProvider.cpp
264+
@mkdir -p ./$(TESTS_DIR)
265+
$(CXX) $(CXXFLAGS) -o ./$(TESTS_DIR)/getProvider $(SRCS) $(EXAMPLES_DIR)/messaging/messages/getProvider.cpp $(LDFLAGS)
266+
listProviders: $(SRCS) $(EXAMPLES_DIR)/messaging/messages/listProviders.cpp
267+
@mkdir -p ./$(TESTS_DIR)
268+
$(CXX) $(CXXFLAGS) -o ./$(TESTS_DIR)/listProviders $(SRCS) $(EXAMPLES_DIR)/messaging/messages/listProviders.cpp $(LDFLAGS)
269+
listMessageLogs: $(SRCS) $(EXAMPLES_DIR)/messaging/messages/listMessageLogs.cpp
270+
@mkdir -p ./$(TESTS_DIR)
271+
$(CXX) $(CXXFLAGS) -o ./$(TESTS_DIR)/listMessageLogs $(SRCS) $(EXAMPLES_DIR)/messaging/messages/listMessageLogs.cpp $(LDFLAGS)
272+
deleteMessages: $(SRCS) $(EXAMPLES_DIR)/messaging/messages/deleteMessages.cpp
273+
@mkdir -p ./$(TESTS_DIR)
274+
$(CXX) $(CXXFLAGS) -o ./$(TESTS_DIR)/deleteMessages $(SRCS) $(EXAMPLES_DIR)/messaging/messages/deleteMessages.cpp $(LDFLAGS)
275+
listTargets: $(SRCS) $(EXAMPLES_DIR)/messaging/messages/listTargets.cpp
276+
@mkdir -p ./$(TESTS_DIR)
277+
$(CXX) $(CXXFLAGS) -o ./$(TESTS_DIR)/listTargets $(SRCS) $(EXAMPLES_DIR)/messaging/messages/listTargets.cpp $(LDFLAGS)
278+
257279

258280
listProviderLogs: $(SRCS) $(EXAMPLES_DIR)/messaging/messages/listProviderLogs.cpp
259281
@mkdir -p ./$(TESTS_DIR)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include "Appwrite.hpp"
2+
#include <filesystem>
3+
#include <fstream>
4+
#include <iostream>
5+
#include <sstream>
6+
int main() {
7+
std::string projectId = "68853010003a3f4fc106";
8+
std::string apiKey = "";
9+
std::string providerId = "68a22c7b00325882e4e5";
10+
std::string name = "";
11+
std::ifstream file("");
12+
std::stringstream buffer;
13+
buffer << file.rdbuf();
14+
std::string service_account_json = buffer.str();
15+
bool enabled = true;
16+
try {
17+
Messaging messaging(projectId, apiKey);
18+
std::string response = messaging.createFcmProvider(
19+
providerId, name, service_account_json, enabled);
20+
std::cout << "FCM Provider Created!\nResponse: " << response << std::endl;
21+
} catch (const AppwriteException &ex) {
22+
std::cerr << "Exception: " << ex.what() << std::endl;
23+
}
24+
return 0;
25+
}
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+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "Appwrite.hpp"
2+
#include <iostream>
3+
int main() {
4+
std::string projectId = "68853010003a3f4fc106";
5+
std::string apiKey = "";
6+
std::string providerId = "68a22c7b00325882e4e5";
7+
try {
8+
Messaging messaging(projectId, apiKey);
9+
std::string response = messaging.deleteProvider(providerId);
10+
std::cout << "provider deleted!\nResponse: " << response << std::endl;
11+
} catch (const AppwriteException &ex) {
12+
std::cerr << "Exception: " << ex.what() << std::endl;
13+
}
14+
return 0;
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "Appwrite.hpp"
2+
#include <iostream>
3+
int main() {
4+
std::string projectId = "68853010003a3f4fc106";
5+
std::string apiKey = "";
6+
std::string providerId = "689a4547001864da9330";
7+
try {
8+
Messaging messaging(projectId, apiKey);
9+
std::string response = messaging.getProvider(providerId);
10+
std::cout << "provider Fetched!\nResponse: " << response << std::endl;
11+
} catch (const AppwriteException &ex) {
12+
std::cerr << "Exception: " << ex.what() << std::endl;
13+
}
14+
return 0;
15+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include "Appwrite.hpp"
2+
#include <iostream>
3+
int main() {
4+
std::string projectId = "66fbb5a100070a3a1d19";
5+
std::string apiKey = "";
6+
std::string messageId = "688e98ba00107a10f041";
7+
8+
Appwrite appwrite(projectId, apiKey);
9+
Queries queries;
10+
11+
queries.queryLimit(50);
12+
try {
13+
std::string response =
14+
appwrite.getMessaging().listMessageLogs(messageId, queries);
15+
std::cout << "Message logs fetched! \nResponse: " << response
16+
<< std::endl;
17+
} catch (const AppwriteException &ex) {
18+
std::cerr << "Exception: " << ex.what() << std::endl;
19+
}
20+
return 0;
21+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include "Appwrite.hpp"
2+
#include <iostream>
3+
int main() {
4+
std::string projectId = "68853010003a3f4fc106";
5+
std::string apiKey = "";
6+
Appwrite appwrite(projectId, apiKey);
7+
Queries queries;
8+
queries.queryLimit(50);
9+
try {
10+
std::string response = appwrite.getMessaging().listProviders(queries);
11+
std::cout << "providers fetched! \nResponse: " << response << std::endl;
12+
} catch (const AppwriteException &ex) {
13+
std::cerr << "Exception: " << ex.what() << std::endl;
14+
}
15+
return 0;
16+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include "Appwrite.hpp"
2+
#include "classes/Messaging.hpp"
3+
#include <iostream>
4+
5+
int main() {
6+
std::string projectId = "";
7+
std::string apiKey = "";
8+
std::string messageId = "";
9+
10+
std::vector<std::string> queries = {};
11+
12+
Appwrite appwrite(projectId, apiKey);
13+
14+
try {
15+
std::string response = appwrite.getMessaging().listTargets(messageId, queries);
16+
std::cout << "Message targets retrieved successfully:\n" << response << std::endl;
17+
} catch (const AppwriteException &e) {
18+
std::cerr << "Appwrite error: " << e.what() << std::endl;
19+
}
20+
21+
return 0;
22+
}

include/classes/Messaging.hpp

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,16 +173,73 @@ class Messaging {
173173
const std::string &body,
174174
const std::vector<std::string> &topicId = {},
175175
const std::vector<std::string> &userId = {});
176+
177+
/**
178+
* @brief List all providers.
179+
* @param queries Optional query filters
180+
* @return JSON string of providers list
181+
*/
182+
std::string listProviders(Queries &queries);
176183

177-
/**
184+
/**
178185
* @brief List all provider logs.
179-
* @param topicId ID of the provider
186+
* @param providerId ID of the provider
180187
* @param queries Optional query filters
181188
* @return JSON string of provider logs list
182189
*/
183190
std::string listProviderLogs(const std::string &providerId,
184191
Queries &queries);
192+
193+
/**
194+
* @brief Create a new Firebase Cloud Messaging provider.
195+
* @param providerId A unique Id for the provider.
196+
* @param name provider name.
197+
* @param service_account_json FCM service account JSON..
198+
* @param enabled Whether the provider should be active immediately after creation.
199+
* @return JSON response.
200+
*/
201+
std::string createFcmProvider(std::string &providerId, std::string name,
202+
std::string service_account_json,
203+
bool enabled);
204+
205+
/**
206+
* @brief Delete a provider.
207+
* @param providerId ID of the provider
208+
* @return JSON response
209+
*/
210+
std::string deleteProvider(const std::string &providerId);
211+
212+
/**
213+
* @brief Get a specific provider by ID.
214+
* @param providerId ID of the provider
215+
* @return JSON string of the provider details
216+
*/
217+
std::string getProvider(const std::string &providerId);
218+
219+
/**
220+
* @brief List all message logs with optional filters.
221+
* @param messageId ID of the message
222+
* @param queries Query parameters for filtering
223+
* @return JSON string of messageLog list
224+
*/
225+
std::string listMessageLogs(const std::string &messageId, Queries &queries);
226+
227+
/**
228+
* @brief Delete a message by its ID.
229+
* @param messageId ID of the message.
230+
* @return JSON response.
231+
*/
232+
std::string deleteMessages(const std::string &messageId);
185233

234+
/**
235+
* @brief List all targets for a given message.
236+
* @param messageId ID of the message.
237+
* @param queries Optional query filters.
238+
* @return JSON response.
239+
*/
240+
std::string listTargets(const std::string &messageId,
241+
const std::vector<std::string> &queries = {});
242+
186243
private:
187244
std::string projectId; ///< Project ID
188245
std::string apiKey; ///< API Key

0 commit comments

Comments
 (0)