Skip to main content
social.plus SDK provides comprehensive post-editing functionality that fosters accountability and user awareness within your application. Users can edit their own posts, and community moderators/admins can edit posts within their communities.

Text Posts

Edit and update text content in existing posts

Image Posts

Add, remove, or replace images in image posts

File Posts

Manage file attachments and add new files

Video Posts

Update video content and add new videos

Supported Post Types

social.plus SDK supports the editing of the following post types:
  • Content Updates: Modify text content and formatting
  • Metadata Changes: Update tags, mentions, and other metadata
  • Character Limits: Respect platform character limits
  • Add Images: Upload and append new images to existing posts
  • Remove Images: Remove specific images from the post
  • Replace Images: Replace existing images with new ones
  • Maximum Limit: Up to 10 images per post
  • Add Files: Upload and append new files to existing posts
  • Remove Files: Remove specific files from the post
  • File Types: Support for all common file formats
  • Maximum Limit: Up to 10 files per post
  • Add Videos: Upload and append new videos to existing posts
  • Remove Videos: Remove specific videos from the post
  • Video Processing: Automatic transcoding and optimization
  • Maximum Limit: Up to 10 videos per post

Permissions and Accountability

Edit Permissions: Users can only edit their own posts, except if you’re an admin or a moderator of a particular community. This functionality encourages responsible interactions and maintains accountability.

Key Features

  • User Posts: Users can edit their own posts
  • Moderator Rights: Community moderators can edit posts within their communities
  • Admin Rights: Platform administrators can edit any post
  • Permission Validation: SDK automatically validates edit permissions
  • editedAt Timestamp: Updated automatically upon edit completion
  • Edit History: Track when posts were last modified
  • UI Indicators: Display “edited” status to other users
Upon completing an edit operation, the SDK updates the editedAt property to the current time, reflecting the changes made by the user. You can leverage this timestamp to create a user interface that informs users of edited posts, fostering transparency.

Update Text Post

To edit a text post, utilize the editPost method in a post repository using AmityTextPostBuilder class to compose new text content.
func updateTextPostExample() async throws {
    // Update your post structure
    let builder = AmityTextPostBuilder()
    builder.setText("new-text")
    
    // Update a post from the builder
    do {
        let post = try await postRepository.editPost(withId: "<post-id>", builder: builder)
        print("Text post updated successfully")
    } catch {
        // Handle error here
        print("Failed to update text post: \(error)")
    }
}

Update File Post

To edit a file post, utilize the editPost method in a post repository using AmityFilePostBuilder class to compose a set of new files. The files parameter should include both the current files (if required) and any newly uploaded files you wish to append to the post.
func updateFilePostExample() async throws {
    guard let post = postRepository.getPost(withId: "postId").object else { return }
    let childrenPosts = post.childrenPosts
    
    Task { @MainActor in
        do {
            // Assume that this is file post, get the current value of files
            var filesData = childrenPosts.compactMap({ $0.getFileInfo() })

            // Upload a new file
            let fileData = try await fileRepository.uploadFile(yourFile, progress: nil)
            // Add newly uploaded file to array
            filesData.append(fileData)
            
            let filePostBuilder = AmityFilePostBuilder()
            filePostBuilder.setFiles(filesData)
            let _ = try await postRepository.editPost(withId: "postId", builder: filePostBuilder)
            
            print("File post updated successfully")
        } catch {
            print("error: \(error.localizedDescription)")
        }
    }
}

File Management Strategy

  • Current Files: Retrieve existing files using getFileInfo() from child posts
  • File Array: Maintain current files in the filesData array
  • Selective Updates: Choose which files to keep or remove
  • Upload Process: Use fileRepository.uploadFile() for new files
  • Progress Tracking: Monitor upload progress with progress callback
  • Append Strategy: Add new files to existing array
  • Maximum Limit: Ensure total files don’t exceed 10 per post

Update Image Post

To edit an image post, utilize the editPost method in a post repository using AmityImagePostBuilder class to compose a set of new images. The images parameter should include both the current images (if required) and any newly uploaded images you wish to append to the post.
func updateImagePostExample() {
    guard let post = postRepository.getPost(withId: "postId").object else { return }
    let childrenPosts = post.childrenPosts
    
    Task { @MainActor in
        do {
            // Assume that this is image post, get the current value of images
            var imagesData = childrenPosts.compactMap({ $0.getImageInfo() })

            // Upload a new image
            let imageData = try await fileRepository.uploadImage(yourImage, progress: nil)
            // Add newly uploaded image to array
            imagesData.append(imageData)
            
            let imagePostBuilder = AmityImagePostBuilder()
            imagePostBuilder.setImages(imagesData)
            let _ = try await postRepository.editPost(withId: "postId", builder: imagePostBuilder)
            
            print("Image post updated successfully")
        } catch {
            print("error: \(error.localizedDescription)")
        }
    }
}

Image Processing Features

  • Automatic Resizing: Images are automatically resized for different viewing contexts
  • Format Support: JPEG, PNG, and WebP formats supported
  • Quality Compression: Optimized for storage and bandwidth efficiency
  • Multiple Resolutions: Generated thumbnails for faster loading
  • Progress Callbacks: Real-time upload progress monitoring
  • Error Handling: Robust error handling for failed uploads
  • Retry Logic: Automatic retry for temporary failures
  • Validation: File size and format validation before upload

Update Video Post

To edit a video post, utilize the editPost method in a post repository using AmityVideoPostBuilder class to compose a set of new videos. The videos parameter should include both the current videos (if required) and any newly uploaded videos you wish to append to the post.
func updateVideoPostExample() async throws {
    guard let post = postRepository.getPost(withId: "postId").object else { return }
    let childrenPosts = post.childrenPosts
    
    Task { @MainActor in
        do {
            // Assume that this is video post, we need to get the current value of videos
            var videosData = childrenPosts.compactMap({ $0.getVideoInfo() })

            // Upload a new video
            let videoData = try await fileRepository.uploadVideo(with: yourVideo, progress: nil)
            // Add newly uploaded video to array
            videosData.append(videoData)
            
            let videoPostBuilder = AmityVideoPostBuilder()
            videoPostBuilder.setVideos(videosData)
            let _ = try await postRepository.editPost(withId: "postId", builder: videoPostBuilder)
            
            print("Video post updated successfully")
        } catch {
            print("error: \(error.localizedDescription)")
        }
    }
}

Video Processing

  • Multiple Resolutions: Automatic transcoding to multiple resolutions (1080p, 720p, 480p, 360p)
  • Format Optimization: Conversion to web-optimized formats
  • Thumbnail Generation: Automatic thumbnail creation for video previews
  • Streaming Support: Optimized for adaptive streaming playback
  • File Size Limits: Maximum 1GB per video file
  • Processing Time: Transcoding may take time based on video length and quality
  • Progress Monitoring: Real-time upload and processing progress
  • Quality Settings: Configurable quality and compression settings

Limitations and Best Practices

Maximum Media Limit: You can upload a maximum of 10 images/files/videos in a single post. Plan your content accordingly to stay within these limits.
  • Batch Uploads: Upload multiple files efficiently using batch operations
  • Progress Indicators: Show upload progress to users for better UX
  • Error Recovery: Implement retry logic for failed uploads
  • Memory Management: Properly dispose of large media files after upload
  • Edit Indicators: Clearly show when a post has been edited
  • Preview Changes: Allow users to preview changes before saving
  • Undo Functionality: Consider implementing undo for recent edits
  • Loading States: Show appropriate loading states during edit operations
  • Version Control: Keep track of post edit history where needed
  • Moderation: Review edited posts if they require re-approval
  • Validation: Validate content before allowing edits
  • Backup: Consider backing up original content before edits

Common Use Cases

Typo Corrections

Quick text corrections and spelling fixes

Content Updates

Adding new information or updating outdated content

Moderation Edits

Community moderators correcting or improving posts