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.
Community Managers can edit other members posts as well.
Steps to Edit a Post
- Create an instance of
EditPostRequestwith the required parameters:postId,postText,attachments,topicIds, and optionalisRepost. - Call the
editPost()function using the instance of theLMFeedClientclass, passing the request as a parameter. - 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);
}
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
| Variable | Type | Description | Optional |
|---|---|---|---|
| postId | String | ID of the post to be edited | |
| postText | String | New text for the post | |
| attachments | List<Attachment> | List of attachments for the post | |
| topicIds | List<String> | List of topic IDs for the post | |
| isRepost | bool | Indicates if the post is a repost | ✔ |
EditPostResponse
List of parameters for the EditPostResponse class
| Variable | Type | Description | Optional |
|---|---|---|---|
| success | bool | API success status | |
| errorMessage | String | Error message in case of failure | ✔ |
| post | Post | Edited post details | |
| user | Map<String, User> | Map of user UUIDs to User entities | |
| topics | Map<String, Topic> | Map of topic IDs to Topic entities | |
| widgets | Map<String, WidgetModel> | Map of widget IDs to WidgetModel entities | |
| repostedPosts | Map<String, Post> | Map of reposted post IDs to Post entities | |
| userTopics | Map<String, List<String>> | Map of user topics (key: user ID) | ✔ |