@@ -53,7 +53,6 @@ class UserInfoService implements IUserInfoService {
5353 let result : Partial < UserInformation & SettingsPayload > = { uid : id }
5454
5555 const userIdLocalPart = getLocalPart ( id )
56- // If the local part is null, return null (invalid Matrix ID)
5756 if ( userIdLocalPart == null ) {
5857 return null
5958 }
@@ -63,21 +62,17 @@ class UserInfoService implements IUserInfoService {
6362 visible_fields : [ ]
6463 }
6564
66- // By default all fields are visible (user viewing his own profile)
6765 let visibilitySettings = {
6866 visibility : ProfileVisibility . Public ,
6967 visible_fields : [ ProfileField . Email ]
7068 }
7169
7270 if ( viewer ) {
73- // ensure viewer is a well‑formed matrix id
7471 const viewerLocalPart = getLocalPart ( viewer )
7572 if ( viewerLocalPart == null ) {
76- // treat malformed viewer as “not allowed”
7773 throw new ForbiddenError ( 'Invalid viewer identifier.' )
7874 }
7975
80- // If it's another user requesting someone else's profile
8176 if ( id !== viewer ) {
8277 const { visibilitySettings : userVisibilitySettings } =
8378 await this . _getOrCreateUserSettings (
@@ -86,14 +81,10 @@ class UserInfoService implements IUserInfoService {
8681 )
8782 visibilitySettings = userVisibilitySettings
8883
89- // if the profile is private then return nothing
9084 if ( visibilitySettings . visibility === ProfileVisibility . Private ) {
91- // 403 forbidden
9285 throw new ForbiddenError ( 'This profile is private.' )
9386 }
9487
95- // if the profile is visible to contacts only, check if the viewer is
96- // an existing contact
9788 if ( visibilitySettings . visibility === ProfileVisibility . Contacts ) {
9889 const { contacts : userContacts } =
9990 await this . addressBookService . list ( id )
@@ -105,7 +96,6 @@ class UserInfoService implements IUserInfoService {
10596
10697 const isContact = contactSet . has ( viewer )
10798 if ( ! isContact ) {
108- // 403 forbidden
10999 throw new ForbiddenError (
110100 'This profile is visible to contacts only.'
111101 )
@@ -124,7 +114,12 @@ class UserInfoService implements IUserInfoService {
124114 } ) ( )
125115
126116 const directoryPromise = ( async ( ) => {
127- if ( ! this . enableAdditionalFeatures ) return null
117+ if (
118+ ! this . enableAdditionalFeatures &&
119+ process . env . ADDITIONAL_FEATURES !== 'true'
120+ ) {
121+ return null
122+ }
128123 const rows = ( await this . userDb . db . get (
129124 'users' ,
130125 [ 'cn' , 'sn' , 'givenname' , 'givenName' , 'mail' , 'mobile' ] ,
@@ -134,7 +129,12 @@ class UserInfoService implements IUserInfoService {
134129 } ) ( )
135130
136131 const settingsPromise = ( async ( ) => {
137- if ( ! this . enableCommonSettings ) return null
132+ if (
133+ ! this . enableCommonSettings &&
134+ process . env . FEATURE_COMMON_SETTINGS_ENABLED !== 'true'
135+ ) {
136+ return null
137+ }
138138 const rows = ( await this . db . get ( 'usersettings' , [ '*' ] , {
139139 matrix_id : id
140140 } ) ) as unknown as UserSettings [ ]
@@ -177,14 +177,12 @@ class UserInfoService implements IUserInfoService {
177177 }
178178
179179 if ( settingsRow ) {
180- // Use Object.assign to avoid an extra spread allocation
181180 Object . assign ( result , {
182181 language : settingsRow . settings . language ?? '' ,
183182 timezone : settingsRow . settings . timezone ?? ''
184183 } )
185184 }
186185
187- // if only uid is present in the result, return null
188186 if ( Object . keys ( result ) . length === 1 && result . uid != null ) {
189187 return null
190188 }
@@ -201,14 +199,12 @@ class UserInfoService implements IUserInfoService {
201199 userId : string ,
202200 visibilitySettings : UserProfileSettingsPayloadT
203201 ) : Promise < UserProfileSettingsT | undefined > => {
204- // eslint-disable-next-line no-useless-catch
205202 try {
206203 const { visibilitySettings : userVisibilitySettings , created } =
207204 await this . _getOrCreateUserSettings ( userId , visibilitySettings )
208205 if ( created ) {
209206 return userVisibilitySettings
210207 } else {
211- // update the existing user profile settings
212208 await this . db . update (
213209 'profileSettings' ,
214210 // @ts -expect-error typecast
0 commit comments