mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-25 14:59:22 +00:00
Ready to implement comments
This commit is contained in:
parent
90d81c1d7a
commit
5a45096fa6
@ -105,7 +105,8 @@ export class PostsController {
|
|||||||
// Determine user access level
|
// Determine user access level
|
||||||
user_access: ACCESS_LEVELS_API[await PostsHelper.GetAccessLevel(h.optionnalUserID, p)],
|
user_access: ACCESS_LEVELS_API[await PostsHelper.GetAccessLevel(h.optionnalUserID, p)],
|
||||||
|
|
||||||
// TODO : add comments
|
// Load comments (if possible)
|
||||||
|
comments: await PostsHelper.AllowCommentsOnPost(p) ? "to come" : null,
|
||||||
};
|
};
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
@ -133,8 +133,12 @@ export class Post implements PostBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isUserPage() : boolean {
|
||||||
|
return this.kindPage == PostPageKind.PAGE_KIND_USER;
|
||||||
|
}
|
||||||
|
|
||||||
get userPageID() : number {
|
get userPageID() : number {
|
||||||
return this.kindPage == PostPageKind.PAGE_KIND_USER ? this.pageID : 0
|
return this.isUserPage ? this.pageID : 0
|
||||||
}
|
}
|
||||||
|
|
||||||
get groupID() : number {
|
get groupID() : number {
|
||||||
|
@ -181,6 +181,15 @@ export class PostsHelper {
|
|||||||
throw Error("GetAccessLevel reached an unimplemented status!");
|
throw Error("GetAccessLevel reached an unimplemented status!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check out whether comments are allowed on a post or not
|
||||||
|
*
|
||||||
|
* @param post The post to check
|
||||||
|
*/
|
||||||
|
public static async AllowCommentsOnPost(post: Post) : Promise<boolean> {
|
||||||
|
return !post.isUserPage || await UserHelper.AllowComments(post.userPageID);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn a database entry into a row object
|
* Turn a database entry into a row object
|
||||||
*
|
*
|
||||||
|
@ -147,6 +147,16 @@ export class UserHelper {
|
|||||||
return (await this.GetUserInfo(userID)).friendsListPublic;
|
return (await this.GetUserInfo(userID)).friendsListPublic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience function to check out whether comments are
|
||||||
|
* allowed on a page or not
|
||||||
|
*
|
||||||
|
* @param userID Target user ID
|
||||||
|
*/
|
||||||
|
public static async AllowComments(userID: number) : Promise<boolean> {
|
||||||
|
return !(await this.GetUserInfo(userID)).blockComments;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check out whether a user can create a post on another user
|
* Check out whether a user can create a post on another user
|
||||||
* page
|
* page
|
||||||
|
Loading…
Reference in New Issue
Block a user