Skip to main content

Edit Post

The editPost() function enables users to modify and update the content of a previously published post, ensuring the accuracy and relevance of shared information.

note

Community Managers can edit other members posts as well.

Steps to Edit a Post

  1. Create an instance of EditPostRequest with the required parameters: postId, postText, attachments, topicIds, and optional isRepost.
  2. Call the editPost() function using the instance of the LMFeedClient class, passing the request as a parameter.
  3. Use the response as per your requirement.
// Create an instance of EditPostRequest
EditPostRequest request = (EditPostRequestBuilder()
..postId("post_id")
..postText("post_text_editted")
..attachments([])
..topicIds([])
..isRepost(false)) // send true, if editing a reposted post
.build();

// Get the response from calling the function
final EditPostResponse editPostResponse = await lmFeedClient.editPost(editPostRequest);

// Process the response, as per requirement
if (editPostResponse.success) {
// your function to handle successful post editing
handleEditPostSuccess();
} else {
// your function to handle error message
handleEditPostError(editPostResponse.errorMessage);
}
danger

You must send the text and attachments as it is if you don't want to update them, otherwise the text and attachments will be set to empty.

Additional Features

Tag a User

To tag a user, use the getTaggingList() function to fetch the list of users that can be tagged, and use the format <<[user.name]|route://user_profile/[user.sdkClientInfo.uuid]>> to embed it inside the text of the post.

Decode a URL

To decode a URL, use the decodeUrl() function to decode a URL and get its OGTags. Use those to add an attachment of type 4.

Add a Topic

Topics are keywords related to a post, they can be considered having the same use case as hashtags. You can add a topic to the post by sending the topicIds list in the AddPostRequest with the topics you have fetched using the getTopics().

Models

EditPostRequest

List of parameters for the EditPostRequest class

VariableTypeDescriptionOptional
postIdStringID of the post to be edited
postTextStringNew text for the post
attachmentsList<Attachment>List of attachments for the post
topicIdsList<String>List of topic IDs for the post
isRepostboolIndicates if the post is a repost

EditPostResponse

List of parameters for the EditPostResponse class

VariableTypeDescriptionOptional
successboolAPI success status
errorMessageStringError message in case of failure
postPostEdited post details
userMap<String, User>Map of user UUIDs to User entities
topicsMap<String, Topic>Map of topic IDs to Topic entities
widgetsMap<String, WidgetModel>Map of widget IDs to WidgetModel entities
repostedPostsMap<String, Post>Map of reposted post IDs to Post entities