Edit Post
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
- Use the
editPost()
function provided by thelmFeedClient
object created earlier. - Create an instance of
EditPostRequest
, as shown in the snippet and pass it to the above method. - Use the response as per your requirement
try {
const attachments = [];
const editPostRequest = EditPostRequest.builder()
.setPostId("<ENTER_POST_ID>") // id of the post to be edited
.setText("Updated post text") // updated text of the post
.setAttachments(attachments) // updated attachments of the post
.setHeading("Heading of the post") // heading of the post
.setTopicIds("Updated Topic ids") // updated topic ids of the post
.build();
const response = await lmFeedClient.editPost(editPostRequest);
// Use the response as per your requirement.
} catch (error) {
// Use the error as per your requirement.
}
You must send the text
, heading
, and attachments
as it is if you don't want to update them, otherwise the text
, heading
, 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 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 EditPostRequest
with the topics you have fetched using the getTopics().
Models
EditPostRequest
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
text | string | Text content of the post | ✔ |
attachments | Attachment | List of attached medias in the post. Maximum size is 10. | ✔ |
heading | string | Heading of the post | ✔ |
topicIds | string[] | List of Topics user want to add in the post | ✔ |
EditPostResponse
Variable | Type | Description | Optional |
---|---|---|---|
post | Post | Object of the created post. | ✔️ |
users | Map<string,User> | Map of user unique id to user object. | |
topics | Map<string,Topic> | Map of topic id to topic object. | ✔️ |
widget | IWidget | Widget data for the post. |