social.plus SDK provides robust comment editing functionality that empowers users to refine their contributions while maintaining community trust. The system enforces strict ownership rules, ensuring users can only edit their own comments, and automatically tracks all modifications for complete transparency.

Text Editing

Update comment text content with full formatting support and validation

Image Management

Add, remove, or replace images with attachment validation

Edit Tracking

Automatic timestamp updates with transparent edit indicators

Permission Control

Strict ownership validation ensures users edit only their content
When editing comments, existing attachments are completely replaced. To preserve existing images, include them in the new attachments array.

Edit Permissions

Comment editing follows strict permission rules to maintain accountability and prevent unauthorized modifications.
Permission RuleDescriptionEnforcement
Owner OnlyUsers can only edit their own commentsVerified through userId comparison
Not DeletedCannot edit comments marked as deletedChecked via isDeleted status
Content ValidationText length and image format validationEnforced before edit submission

Parameters

ParameterTypeRequiredDescription
commentIdStringYesUnique identifier of the comment to edit
textStringNoUpdated text content (max 50,000 characters)
attachmentsArrayNoImage attachments (replaces all existing attachments)
metadataObjectNoCustom metadata object for additional data
When editing with attachments, all existing attachments are replaced. Include existing attachment IDs to preserve them.

Text Editing

Update comment text content while preserving metadata and maintaining edit history.
func updateImageComment() async {
    let updateOptions = AmityCommentUpdateOptions(text: "My updated comment.", attachments: [.image(fileId: "uploaded-image-id1"), .image(fileId: "uploaded-image-id1.1")])
    do {
        let comment = try await commentRepository.editComment(withId: "comment-id", options: updateOptions)
    } catch {
        // Handle error here
    }
}

Image Editing

Update comment attachments by replacing existing images with new ones. All images must be uploaded before editing.
Image editing replaces ALL existing attachments. To preserve existing images, include their file IDs in the new attachments array.
func updateImageComment() async {
    let updateOptions = AmityCommentUpdateOptions(text: "My updated comment.", attachments: [.image(fileId: "uploaded-image-id1"), .image(fileId: "uploaded-image-id1.1")])
    do {
        let comment = try await commentRepository.editComment(withId: "comment-id", options: updateOptions)
    } catch {
        // Handle error here
    }
}

Best Practices

Permission Validation

Always validate ownership and edit permissions before allowing users to modify comments.

Content Preservation

When editing with attachments, include existing file IDs to preserve desired media.

Error Handling

Implement comprehensive error handling for network, permission, and validation failures.

User Feedback

Provide clear feedback about edit status, limitations, and any validation errors.

Edit Indicators

Display edit timestamps and indicators to maintain transparency in conversations.

Offline Support

Queue edit operations for execution when connectivity is restored.