Skip to content

Commit 2451650

Browse files
Fix: strict schema design
1 parent f1b6cdd commit 2451650

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

apps/meteor/app/api/server/v1/users.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ const usersEndpoints = API.v1
901901
401: validateUnauthorizedErrorResponse,
902902

903903
200: ajv.compile<{
904-
user: IUser & { rooms?: Pick<ISubscription, 'rid' | 'name' | 't' | 'roles' | 'unread'> & { federated?: boolean }[] };
904+
user: IUser & { rooms?: Pick<ISubscription, 'rid' | 'name' | 't' | 'roles' | 'unread'> & { federated?: boolean[] }[] };
905905
success: true;
906906
}>({
907907
type: 'object',
@@ -922,16 +922,16 @@ const usersEndpoints = API.v1
922922
t: { type: 'string' },
923923
roles: { type: 'array', items: { type: 'string' } },
924924
unread: { type: 'number' },
925-
federated: { type: 'boolean' },
925+
federated: { type: 'array', items: { type: 'boolean' } },
926926
},
927927
required: ['rid', 't', 'unread', 'name'],
928928
additionalProperties: false,
929929
},
930930
},
931931
},
932-
additionalProperties: true,
933932
},
934933
],
934+
additionalProperties: false,
935935
},
936936
success: { type: 'boolean', enum: [true] },
937937
},
@@ -956,6 +956,7 @@ const usersEndpoints = API.v1
956956
return API.v1.failure('User not found.');
957957
}
958958
const myself = user._id === this.userId;
959+
959960
if (this.queryParams.includeUserRooms === 'true' && (myself || (await hasPermissionAsync(this.userId, 'view-other-user-channels')))) {
960961
return API.v1.success({
961962
user: {
@@ -982,7 +983,7 @@ const usersEndpoints = API.v1
982983
user,
983984
});
984985
},
985-
);
986+
);
986987

987988
API.v1.addRoute(
988989
'users.getPreferences',

0 commit comments

Comments
 (0)