From 2842fdc55fba5b0a94565e8e80c709614632f5a4 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 21 Mar 2020 18:45:45 +0100 Subject: [PATCH] Can get language settings --- src/controllers/Routes.ts | 2 ++ src/controllers/SettingsController.ts | 15 +++++++++++++++ src/entities/User.ts | 8 +++++++- src/helpers/UserHelper.ts | 1 + 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/controllers/Routes.ts b/src/controllers/Routes.ts index ad6bb70..1c7961b 100644 --- a/src/controllers/Routes.ts +++ b/src/controllers/Routes.ts @@ -87,6 +87,8 @@ export const Routes : Route[] = [ {path: "/settings/check_user_directory_availability", cb: (h) => SettingsController.CheckDirectoryAvailability(h)}, + {path: "/settings/get_language", cb: (h) => SettingsController.GetLanguage(h)}, + // Friends controller {path: "/friends/getList", cb: (h) => FriendsController.GetList(h)}, diff --git a/src/controllers/SettingsController.ts b/src/controllers/SettingsController.ts index da89050..b684fd0 100644 --- a/src/controllers/SettingsController.ts +++ b/src/controllers/SettingsController.ts @@ -103,4 +103,19 @@ export class SettingsController { h.success("The directory is available!"); } + /** + * Get language settings + * + * @param h Request handler + */ + public static async GetLanguage(h: RequestHandler) { + + const userInfo = await UserHelper.GetUserInfo(h.getUserId()); + + h.send({ + lang: userInfo.lang + }); + + } + } \ No newline at end of file diff --git a/src/entities/User.ts b/src/entities/User.ts index 8bcb99c..0f12525 100644 --- a/src/entities/User.ts +++ b/src/entities/User.ts @@ -44,6 +44,11 @@ export interface GeneralSettings { publicNote ?: string } +export interface LangSettings { + id: number, + lang: string, +} + export interface SecuritySettings { id: number, security_question_1 ?: string, @@ -53,7 +58,7 @@ export interface SecuritySettings { } -export interface UserBuilder extends UserInfo, SecuritySettings, GeneralSettings { +export interface UserBuilder extends UserInfo, SecuritySettings, LangSettings, GeneralSettings { } @@ -72,6 +77,7 @@ export class User implements UserBuilder { blockComments: boolean; allowPostsFromFriends: boolean; allowMails: boolean; + lang: string; security_question_1?: string; security_answer_1?: string; security_question_2?: string; diff --git a/src/helpers/UserHelper.ts b/src/helpers/UserHelper.ts index 808e8dc..59f00c6 100644 --- a/src/helpers/UserHelper.ts +++ b/src/helpers/UserHelper.ts @@ -206,6 +206,7 @@ export class UserHelper { blockComments: row.bloquecommentaire == 1, allowPostsFromFriends: row.autoriser_post_amis == 1, allowMails: row.autorise_mail == 1, + lang: row.lang, security_question_1: row.question1, security_answer_1: row.reponse1, security_question_2: row.question2,