1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2025-09-19 21:58:48 +00:00

Can get general settings

This commit is contained in:
2020-03-21 17:16:30 +01:00
parent beafd7a26b
commit 46dce030d7
4 changed files with 59 additions and 0 deletions

View File

@@ -15,6 +15,7 @@ import { PostsController } from "./PostsController";
import { CommentsController } from "./CommentsController";
import { LikesController } from "./LikesController";
import { SurveyController } from "./SurveyController";
import { SettingsController } from "./SettingsController";
/**
* Controllers routes
@@ -79,6 +80,10 @@ export const Routes : Route[] = [
{path: "/user/getAdvancedUserInfos", cb: (h) => UserController.GetAdvancedInfo(h), needLogin: false}, // Legacy
// Settings controller
{path: "/settings/get_general", cb: (h) => SettingsController.GetGeneral(h)},
// Friends controller
{path: "/friends/getList", cb: (h) => FriendsController.GetList(h)},

View File

@@ -0,0 +1,39 @@
/**
* Settings controller
*
* @author Pierre HUBERT
*/
import { RequestHandler } from "../entities/RequestHandler";
import { UserHelper } from "../helpers/UserHelper";
import { UserController } from "./UserController";
export class SettingsController {
/**
* Get general account settings
*
* @param h Request handler
*/
public static async GetGeneral(h: RequestHandler) {
const userInfo = await UserHelper.GetUserInfo(h.getUserId());
h.send({
id: userInfo.id,
email: userInfo.email,
firstName: userInfo.firstName,
lastName: userInfo.lastName,
is_public: userInfo.isPublic,
is_open: userInfo.isOpen,
allow_comments: !userInfo.blockComments,
allow_posts_from_friends: userInfo.allowPostsFromFriends,
allow_comunic_mails: userInfo.allowMails,
public_friends_list: userInfo.friendsListPublic,
virtual_directory: userInfo.virtualDirectory,
personnal_website: userInfo.personnalWebsite,
publicNote: userInfo.publicNote,
})
}
}