mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-06-20 16:45:16 +00:00
Can get information about a single post
This commit is contained in:
@ -11,6 +11,8 @@ import { GroupsAccessLevel } from "./Group";
|
||||
import { GroupsHelper } from "../helpers/GroupsHelper";
|
||||
import { checkVirtualDirectory } from "../utils/VirtualDirsUtils";
|
||||
import { FriendsHelper } from "../helpers/FriendsHelper";
|
||||
import { PostsHelper } from "../helpers/PostsHelper";
|
||||
import { PostAccessLevel } from "./Post";
|
||||
|
||||
/**
|
||||
* Response to a request
|
||||
@ -274,6 +276,37 @@ export class RequestHandler {
|
||||
return groupID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ID of post included in a POST request
|
||||
*
|
||||
* @param name The name of the POST field containing the id of the target post
|
||||
*/
|
||||
public async postPostID(name: string) : Promise<number> {
|
||||
const postID = this.postInt(name);
|
||||
|
||||
if(postID < 1)
|
||||
this.error(400, "Invalid post ID!");
|
||||
|
||||
if(!await PostsHelper.Exists(postID))
|
||||
this.error(404, "Specified post does not exists!");
|
||||
|
||||
return postID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ID of a post a user has access to
|
||||
*
|
||||
* @param name The name of the POST field containing the ID of the target post
|
||||
*/
|
||||
public async postPostIDWithAccess(name: string) : Promise<number> {
|
||||
const postID = await this.postPostID(name);
|
||||
|
||||
if(await PostsHelper.GetAccessLevelFromPostID(this.optionnalUserID, postID) == PostAccessLevel.NO_ACCESS)
|
||||
this.error(401, "Your are not allowed to access this post information!");
|
||||
|
||||
return postID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a virtual directory included in a POST request
|
||||
*
|
||||
|
Reference in New Issue
Block a user