Skip to content

feat: updateEmail #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from

Conversation

aritracodes-69
Copy link
Contributor

πŸš€ Feature: Add updateMessage API to Messaging Module
βœ… Summary
This PR introduces the updateMessage method in the Messaging class, allowing users to update an existing email message using Appwrite's Messaging API. It aligns with the structure of other official Appwrite SDKs and provides full parameter validation, error handling, and testing via an example.

πŸ“„ Description
✨ Public Method Added in Messaging.hpp
cpp
Copy
Edit
/**

  • @brief Update an email message by its ID.
  • @param messageId Unique message identifier
  • @param subject New subject of the email
  • @param content Updated content/body of the email
  • @return JSON response string from the server
  • @throws AppwriteException if parameters are invalid or request fails
    */
    std::string updateMessage(
    const std::string& messageId,
    const std::string& subject,
    const std::string& content
    );
    πŸ”§ Implementation in Messaging.cpp
    Validates parameters (messageId, subject, content)

Constructs the JSON payload manually

Makes a PATCH request to the endpoint:

swift
Copy
Edit
/messaging/messages/email/{messageId}
Handles response and throws exception with details if request fails

πŸ’‘ Example Added
examples/messaging/messages/updateMessage.cpp

Demonstrates:

Creating an Appwrite instance

Calling updateMessage(...) with real inputs

Proper error catching and output

πŸ› οΈ Makefile Updated
Added target to build and run updateMessage.cpp:

bash
Copy
Edit
make updateMessage
make run-updateMessage
πŸ§ͺ Tested With
βœ… Valid messageId (success)

⚠️ Invalid/expired messageId (handled 400 & 404 errors)

βœ… Windows/Linux curl compatibility

❗ Handles failure if message is already delivered/failed (per Appwrite docs)

πŸ“š Reference
Appwrite Messaging API Docs

@aritracodes-69 aritracodes-69 changed the title feat: update email message feat: updateMessage Jul 30, 2025
@aritracodes-69
Copy link
Contributor Author

Screenshot from 2025-07-30 09-15-25 Screenshot from 2025-07-30 09-15-55

screenshots

@pooranjoyb pooranjoyb added mild-mayhem purple litmus paper (pH 7) gssoc25 Issue under Girlscript Summer Of Code 2025 level 2 GSSOC level 2 labels Jul 30, 2025
@pooranjoyb pooranjoyb linked an issue Jul 30, 2025 that may be closed by this pull request
@pooranjoyb
Copy link
Owner

pooranjoyb commented Jul 30, 2025

Can you rename the method to updateEmailMessage or can please check the existing naming convention for this api in python/js sdk ?
And show snapshots of executions? @aritracodes-69

@aritracodes-69
Copy link
Contributor Author

Snapshots are provided above

@aritracodes-69
Copy link
Contributor Author

aritracodes-69 commented Jul 30, 2025

In python SDK the function is defined as update_email, In Javascript SDK it is defined as update-email
@pooranjoyb

@pooranjoyb
Copy link
Owner

In python SDK the function is defined as update_email, In Javascript SDK it is defined as update-email
@pooranjoyb

Yes so we'll have to maintain the convention, rename it as it is.

Copy link
Collaborator

@sristy17 sristy17 left a comment

Choose a reason for hiding this comment

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

Screenshot from 2025-07-30 21-01-09

@aritracodes-69
Copy link
Contributor Author

Screenshot from 2025-07-30 21-01-09

you can't do while the message has failed, it needs to be in draft

@pooranjoyb pooranjoyb changed the title feat: updateMessage feat: updateEmail Jul 30, 2025
Makefile Outdated
@@ -249,7 +249,9 @@ listMessages: $(SRCS) $(EXAMPLES_DIR)/messaging/messages/listMessages.cpp
getMessages: $(SRCS) $(EXAMPLES_DIR)/messaging/messages/getMessages.cpp
@mkdir -p ./$(TESTS_DIR)
$(CXX) $(CXXFLAGS) -o ./$(TESTS_DIR)/getMessages $(SRCS) $(EXAMPLES_DIR)/messaging/messages/getMessages.cpp $(LDFLAGS)

updateMessage: $(SRCS) $(EXAMPLES_DIR)/messaging/messages/updateEmail.cpp
Copy link
Owner

Choose a reason for hiding this comment

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

rename it to updateEmail

@pooranjoyb
Copy link
Owner

Please resolve the conflicts ://

@pooranjoyb
Copy link
Owner

Update? @aritracodes-69

@aritracodes-69
Copy link
Contributor Author

Update? @aritracodes-69

Will get it done by Tommorow

@pooranjoyb
Copy link
Owner

update?

@aritracodes-69
Copy link
Contributor Author

Doing it now

Copy link
Collaborator

@sristy17 sristy17 left a comment

Choose a reason for hiding this comment

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

Screenshot from 2025-08-16 13-04-41

@aritracodes-69
Copy link
Contributor Author

Screenshot from 2025-08-16 13-04-41

working on it now

@aritracodes-69
Copy link
Contributor Author

@sristy17 we cant update the messages that have been failed, only drafted messages can be twiked

Copy link
Collaborator

@sristy17 sristy17 left a comment

Choose a reason for hiding this comment

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

Screenshot from 2025-08-24 20-29-23

also resolve conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gssoc25 Issue under Girlscript Summer Of Code 2025 level 2 GSSOC level 2 mild-mayhem purple litmus paper (pH 7)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: update_email [messaging]
3 participants