Skip to content

Commit 8206242

Browse files
committed
fix: removed typo from updateSms
1 parent 26a8a1c commit 8206242

File tree

3 files changed

+24
-37
lines changed

3 files changed

+24
-37
lines changed

examples/messaging/messages/createSms.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ int main() {
88

99
Appwrite appwrite(projectId, apiKey);
1010

11-
std::string messageId = "6b309gbdfjhfjsk4016e14b8";
12-
std::string subject = "Hello from C++ Appwrite SDK!";
13-
std::string content =
14-
"Testing SMS message creation with topics, users, and targets.";
11+
std::string messageId = "msg001";
12+
std::string content = "Testing SMS message creation.";
1513

1614
std::vector<std::string> topics = {};
1715
std::vector<std::string> users = {};

examples/messaging/messages/updateSms.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ int main() {
88

99
Appwrite appwrite(projectId, apiKey);
1010

11-
std::string messageId = "6b309gbdfjhfjsk4016e14b8";
12-
std::string subject = "Hello from C++ Appwrite SDK!";
13-
std::string content =
14-
"Testing SMS message updation with topics, users, and targets.";
11+
std::string messageId = "msg001";
12+
std::string content = "Testing SMS message updation.";
1513

1614
std::vector<std::string> topics = {};
1715
std::vector<std::string> users = {};
@@ -24,10 +22,7 @@ int main() {
2422
future_time.time_since_epoch()) %
2523
1000;
2624

27-
std::stringstream ss;
28-
ss << std::put_time(std::gmtime(&time_t), "%Y-%m-%dT%H:%M:%S");
29-
ss << "." << std::setfill('0') << std::setw(3) << ms.count() << "+00:00";
30-
std::string scheduled_at = ss.str();
25+
std::string scheduled_at = "";
3126

3227
bool draft = true;
3328

src/services/Messaging.cpp

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -565,37 +565,31 @@ std::string Messaging::updateSms(const std::string &messageId,
565565

566566
std::string payload = "{";
567567

568-
if (!topics.empty()) {
569-
payload += R"("topics":[)";
570-
for (size_t i = 0; i < topics.size(); ++i) {
571-
payload += "\"" + Utils::escapeJsonString(topics[i]) + "\"";
572-
if (i != topics.size() - 1)
573-
payload += ",";
574-
}
575-
payload += "]";
568+
payload += R"("topics":[)";
569+
for (size_t i = 0; i < topics.size(); ++i) {
570+
payload += "\"" + Utils::escapeJsonString(topics[i]) + "\"";
571+
if (i != topics.size() - 1)
572+
payload += ",";
576573
}
574+
payload += "]";
577575

578-
if (!users.empty()) {
579-
payload += R"(,"users":[)";
580-
for (size_t i = 0; i < users.size(); ++i) {
581-
payload += "\"" + Utils::escapeJsonString(users[i]) + "\"";
582-
if (i != users.size() - 1)
583-
payload += ",";
584-
}
585-
payload += "]";
576+
payload += R"(,"users":[)";
577+
for (size_t i = 0; i < users.size(); ++i) {
578+
payload += "\"" + Utils::escapeJsonString(users[i]) + "\"";
579+
if (i != users.size() - 1)
580+
payload += ",";
586581
}
582+
payload += "]";
587583

588-
if (!targets.empty()) {
589-
payload += R"(,"targets":[)";
590-
for (size_t i = 0; i < targets.size(); ++i) {
591-
payload += "\"" + Utils::escapeJsonString(targets[i]) + "\"";
592-
if (i != targets.size() - 1)
593-
payload += ",";
594-
}
595-
payload += "]";
584+
payload += R"(,"targets":[)";
585+
for (size_t i = 0; i < targets.size(); ++i) {
586+
payload += "\"" + Utils::escapeJsonString(targets[i]) + "\"";
587+
if (i != targets.size() - 1)
588+
payload += ",";
596589
}
590+
payload += "]";
597591

598-
payload += R"(","content":")" + Utils::escapeJsonString(content) + R"(")";
592+
payload += R"(,"content":")" + Utils::escapeJsonString(content) + R"(")";
599593

600594
payload += std::string(R"(,"draft":)") + (draft ? "true" : "false");
601595

0 commit comments

Comments
 (0)