mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-06-20 16:45:16 +00:00
Start to determine post access level
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import { RequestHandler } from "../entities/RequestHandler";
|
||||
import { UserHelper } from "../helpers/UserHelper";
|
||||
import { PostsHelper } from "../helpers/PostsHelper";
|
||||
import { Post, PostVisibilityLevel, PostKind } from "../entities/Post";
|
||||
import { Post, PostVisibilityLevel, PostKind, PostAccessLevel } from "../entities/Post";
|
||||
import { MoviesController } from "./MoviesController";
|
||||
import { MoviesHelper } from "../helpers/MoviesHelper";
|
||||
import { SurveyHelper } from "../helpers/SurveyHelper";
|
||||
@ -20,6 +20,14 @@ VISIBILITY_LEVELS_API[PostVisibilityLevel.VISIBILITY_FRIENDS] = "friends";
|
||||
VISIBILITY_LEVELS_API[PostVisibilityLevel.VISIBILITY_USER] = "private";
|
||||
VISIBILITY_LEVELS_API[PostVisibilityLevel.VISIBILITY_GROUP_MEMBERS] = "members";
|
||||
|
||||
|
||||
const ACCESS_LEVELS_API = {};
|
||||
ACCESS_LEVELS_API[PostAccessLevel.NO_ACCESS] = "no-access";
|
||||
ACCESS_LEVELS_API[PostAccessLevel.BASIC_ACCESS] = "basic";
|
||||
ACCESS_LEVELS_API[PostAccessLevel.INTERMEDIATE_ACCESS] = "intermediate";
|
||||
ACCESS_LEVELS_API[PostAccessLevel.FULL_ACCESS] = "full";
|
||||
|
||||
|
||||
export class PostsController {
|
||||
|
||||
/**
|
||||
@ -93,6 +101,11 @@ export class PostsController {
|
||||
// Likes information
|
||||
likes: await LikesHelper.Count(p.id, LikesType.POST),
|
||||
userlike: h.signedIn ? await LikesHelper.IsLiking(h.getUserId(), p.id, LikesType.POST) : false,
|
||||
|
||||
// Determine user access level
|
||||
user_access: ACCESS_LEVELS_API[await PostsHelper.GetAccessLevel(h.optionnalUserID, p)],
|
||||
|
||||
// TODO : add comments
|
||||
};
|
||||
|
||||
return data;
|
||||
|
Reference in New Issue
Block a user