mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-23 12:33:09 +02:00
Refactor
This commit is contained in:
parent
6b6adeaa68
commit
21ebd9a367
1 changed files with 3 additions and 1 deletions
|
@ -34,6 +34,7 @@ type IUserBase = {
|
||||||
pinnedPostId: mongo.ObjectID;
|
pinnedPostId: mongo.ObjectID;
|
||||||
isSuspended: boolean;
|
isSuspended: boolean;
|
||||||
keywords: string[];
|
keywords: string[];
|
||||||
|
host: string;
|
||||||
hostLower: string;
|
hostLower: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -71,7 +72,6 @@ export interface ILocalUser extends IUserBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IRemoteUser extends IUserBase {
|
export interface IRemoteUser extends IUserBase {
|
||||||
host: string;
|
|
||||||
account: {
|
account: {
|
||||||
inbox: string;
|
inbox: string;
|
||||||
uri: string;
|
uri: string;
|
||||||
|
@ -90,6 +90,7 @@ export const isLocalUser = (user: any): user is ILocalUser =>
|
||||||
export const isRemoteUser = (user: any): user is IRemoteUser =>
|
export const isRemoteUser = (user: any): user is IRemoteUser =>
|
||||||
!isLocalUser(user);
|
!isLocalUser(user);
|
||||||
|
|
||||||
|
//#region Validators
|
||||||
export function validateUsername(username: string): boolean {
|
export function validateUsername(username: string): boolean {
|
||||||
return typeof username == 'string' && /^[a-zA-Z0-9\-]{3,20}$/.test(username);
|
return typeof username == 'string' && /^[a-zA-Z0-9\-]{3,20}$/.test(username);
|
||||||
}
|
}
|
||||||
|
@ -113,6 +114,7 @@ export function isValidLocation(location: string): boolean {
|
||||||
export function isValidBirthday(birthday: string): boolean {
|
export function isValidBirthday(birthday: string): boolean {
|
||||||
return typeof birthday == 'string' && /^([0-9]{4})\-([0-9]{2})-([0-9]{2})$/.test(birthday);
|
return typeof birthday == 'string' && /^([0-9]{4})\-([0-9]{2})-([0-9]{2})$/.test(birthday);
|
||||||
}
|
}
|
||||||
|
//#endregion
|
||||||
|
|
||||||
export function init(user): IUser {
|
export function init(user): IUser {
|
||||||
user._id = new mongo.ObjectID(user._id);
|
user._id = new mongo.ObjectID(user._id);
|
||||||
|
|
Loading…
Reference in a new issue