mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-06-20 16:45:16 +00:00
Move method postConversationId
This commit is contained in:
@ -14,6 +14,7 @@ import { PostsHelper } from "../helpers/PostsHelper";
|
||||
import { PostAccessLevel } from "./Post";
|
||||
import { CommentsHelper } from "../helpers/CommentsHelper";
|
||||
import { checkVirtualDirectory } from "../utils/VirtualDirsUtils";
|
||||
import { ConversationsHelper } from "../helpers/ConversationsHelper";
|
||||
|
||||
export abstract class BaseRequestsHandler {
|
||||
|
||||
@ -387,4 +388,20 @@ export abstract class BaseRequestsHandler {
|
||||
if(!await AccountHelper.CheckUserPassword(this.getUserId(), password))
|
||||
this.error(401, "Invalid password!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get and return safely a conversation ID specified in a $_POST Request
|
||||
*
|
||||
* @param name The name of the POST field containing the ID of the conversation
|
||||
* @param handler
|
||||
*/
|
||||
public async postConversationId(name : string) : Promise<number> {
|
||||
const convID = this.postInt(name);
|
||||
|
||||
// Check out whether the user belongs to the conversation or not
|
||||
if(!await ConversationsHelper.DoesUsersBelongsTo(this.getUserId(), convID))
|
||||
this.error(401, "You are not allowed to perform queries on this conversation!");
|
||||
|
||||
return convID;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user