mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-07-10 12:02:49 +00:00
Can update post content
This commit is contained in:
src
@ -310,9 +310,30 @@ export class PostsController {
|
||||
|
||||
await PostsHelper.SetLevel(postID, newVisibility);
|
||||
|
||||
// TODO : depending on new level, delete (or not) notifications about the post
|
||||
|
||||
h.success("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the content of a post
|
||||
*
|
||||
* @param h Request handler
|
||||
*/
|
||||
public static async UpdateContent(h: RequestHandler) {
|
||||
const postID = await h.postPostIDWithAccess("postID", PostAccessLevel.FULL_ACCESS);
|
||||
const content = h.postContent("new_content");
|
||||
|
||||
if(!check_string_before_insert(content))
|
||||
h.error(401, "Given content is invalid!");
|
||||
|
||||
await PostsHelper.SetContent(postID, content);
|
||||
|
||||
// TODO : delete notifications targetting current user about the post
|
||||
|
||||
h.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send multiple posts to the API
|
||||
*
|
||||
|
@ -196,6 +196,8 @@ export const Routes : Route[] = [
|
||||
|
||||
{path: "/posts/set_visibility_level", cb: (h) => PostsController.SetVisibilityLevel(h)},
|
||||
|
||||
{path: "/posts/update_content", cb: (h) => PostsController.UpdateContent(h)},
|
||||
|
||||
|
||||
|
||||
// Notifications controller
|
||||
|
Reference in New Issue
Block a user