mirror of
https://github.com/wassname/talk.git
synced 2026-07-24 13:20:47 +08:00
[CORL 133] API Review (#2197)
* refactor: removed unused subscription code
* refactor: removed management api's
* refactor: cleanup of connections
* refactor: refactored comments edge
* refactor: simplified connection resolving
* feat: added story connection edge
* fix: added story index
* feat: added user pagination and user edge
* fix: added filter to comment query
* fix: removed unused resolvers
* fix: creating a comment reply should require auth
* refactor: cleanup of graph files
* feat: removed display name, made username non-unique
* fix: fixed tests
* fix: fixed tests
* fix: added more api docs
* fix: fixed bug with installer
* refactor: fixes and updates
* fix: added linting for graphql, fixed schema
* feat: added docker build tests
* fix: upped output timeout
* fix: fixed stacktraces in production builds
* fix: removed `git add`
- `git add` was causing issues with
partial staged changs on files
* feat: improved error messaging for auth
* refactor: cleaned up queue names
* fix: merge error
This commit is contained in:
@@ -8,7 +8,6 @@ import {
|
||||
USERNAME_REGEX,
|
||||
} from "talk-common/helpers/validate";
|
||||
import {
|
||||
DisplayNameExceedsMaxLengthError,
|
||||
EmailAlreadySetError,
|
||||
EmailExceedsMaxLengthError,
|
||||
EmailInvalidFormatError,
|
||||
@@ -32,7 +31,6 @@ import {
|
||||
setUserLocalProfile,
|
||||
setUserUsername,
|
||||
updateUserAvatar,
|
||||
updateUserDisplayName,
|
||||
updateUserEmail,
|
||||
updateUserPassword,
|
||||
updateUserRole,
|
||||
@@ -71,25 +69,6 @@ function validateUsername(tenant: Tenant, username: string) {
|
||||
}
|
||||
}
|
||||
|
||||
const DISPLAY_NAME_MAX_LENGTH = USERNAME_MAX_LENGTH;
|
||||
|
||||
/**
|
||||
* validateDisplayName will validate that the username is valid.
|
||||
*
|
||||
* @param tenant tenant where the User is associated with
|
||||
* @param displayName the display name to be tested
|
||||
*/
|
||||
function validateDisplayName(tenant: Tenant, displayName: string) {
|
||||
// TODO: replace these static regex/length with database options in the Tenant eventually
|
||||
|
||||
if (displayName.length > DISPLAY_NAME_MAX_LENGTH) {
|
||||
throw new DisplayNameExceedsMaxLengthError(
|
||||
displayName.length,
|
||||
DISPLAY_NAME_MAX_LENGTH
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* validatePassword will validate that the password is valid. Current
|
||||
* implementation uses a length statically, future versions will expose this as
|
||||
@@ -355,28 +334,6 @@ export async function updateUsername(
|
||||
return updateUserUsername(mongo, tenant.id, userID, username);
|
||||
}
|
||||
|
||||
/**
|
||||
* updateDisplayName will update a given User's display name.
|
||||
*
|
||||
* @param mongo mongo database to interact with
|
||||
* @param tenant Tenant where the User will be interacted with
|
||||
* @param userID the User's ID that we are updating
|
||||
* @param displayName the display name that we are setting on the User
|
||||
*/
|
||||
export async function updateDisplayName(
|
||||
mongo: Db,
|
||||
tenant: Tenant,
|
||||
userID: string,
|
||||
displayName?: string
|
||||
) {
|
||||
if (displayName) {
|
||||
// Validate the display name.
|
||||
validateDisplayName(tenant, displayName);
|
||||
}
|
||||
|
||||
return updateUserDisplayName(mongo, tenant.id, userID, displayName);
|
||||
}
|
||||
|
||||
/**
|
||||
* updateRole will update the given User to the specified role.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user