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
- Create a EditPostRequest object using
EditPostRequest.Builder
class by passing all the required parameters. - Call
editComment()
function using the instance ofLMFeedClient
. - Process the response (LMResponse<EditPostResponse>) as per your requirement.
CoroutineScope(Dispatchers.IO).launch {
// create a list of the attachments of type [Attachment](../Models/post-model/#attachment)
val attachments = createAttachments(mediasPicked)
// object of EditPostRequest
val editPostRequest = EditPostRequest.Builder()
.postId("ENTER POST ID") // id of the post to be edited
.text("ENTER POST TEXT") // updated text of the post
.attachments(attachments) // updated attachments of the post
.heading("ENTER POST HEADING") // heading of the post
.build()
// get response (LMResponse<Nothing>)
val response = LMFeedClient.getInstance().editPost(editPostRequest)
if (response.success) {
// your function to process the response data
processEditPostResponse(response.data)
} else {
// your function to process error message
processError(response.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 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 | List<Attachment> | List of attached medias in the post. Maximum size is 10. | ✔ |
heading | String | Heading of the post. | ✔ |
tempId | String | Temporary ID of post. | ✔ |
topicIds | List<String> | List of ids of the topics added in the post. | ✔ |
EditPostResponse
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
post | Post | Object of the edited post. | |
users | Map<String, User> | Map of user unique id to user object. | |
topics | Map<String, Topic> | Map of topic id to topic object. | |
widgets | Map<String, Widget> | Map of widget id to widget object. |