mirror of
https://github.com/spacebarchat/server.git
synced 2026-05-14 16:15:18 +00:00
Renamed to JsonNumber and removed from incorrectly typed date field
This commit is contained in:
@@ -20,7 +20,7 @@ import { BaseEntity, BeforeInsert, BeforeUpdate, Column, ColumnOptions, FindOpti
|
||||
import { Snowflake } from "../util/Snowflake";
|
||||
import { getDatabase } from "../util/Database";
|
||||
import { OrmUtils } from "../imports/OrmUtils";
|
||||
import { annotationsKey } from "../util/Decorators";
|
||||
import { annotationsKey, JsonNumber } from "../util/Decorators";
|
||||
|
||||
export class BaseClassWithoutId extends BaseEntity {
|
||||
private get construct() {
|
||||
@@ -56,7 +56,7 @@ export class BaseClassWithoutId extends BaseEntity {
|
||||
if (
|
||||
key in this && // This object has this property, should never fail but better to be safe
|
||||
key in annotations && // If this property has an annotation
|
||||
annotations[key].indexOf("BigintToLong") > -1 && // if one of the annotations is JsonRemoveEmpty
|
||||
annotations[key].indexOf("JsonNumber") > -1 && // if one of the annotations is JsonRemoveEmpty
|
||||
typeof this[key] == "string" // and its a String
|
||||
) {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
|
||||
@@ -29,7 +29,7 @@ import { Message } from "./Message";
|
||||
import { Role } from "./Role";
|
||||
import { User } from "./User";
|
||||
import { AvatarDecorationData, Collectibles, DisplayNameStyle, PrimaryGuild, PublicMember, PublicMemberProjection, UserGuildSettings } from "@spacebar/schemas";
|
||||
import { BigintToLong } from "../util/Decorators";
|
||||
import { JsonNumber } from "../util/Decorators";
|
||||
|
||||
export const MemberPrivateProjection: (keyof Member)[] = [
|
||||
"id",
|
||||
@@ -99,7 +99,6 @@ export class Member extends BaseClassWithoutId {
|
||||
joined_at: Date;
|
||||
|
||||
@Column({ type: "bigint", nullable: true })
|
||||
@BigintToLong
|
||||
premium_since?: number;
|
||||
|
||||
@Column()
|
||||
|
||||
@@ -38,7 +38,7 @@ import {
|
||||
PublicUserProjection,
|
||||
UserPrivate,
|
||||
} from "@spacebar/schemas";
|
||||
import { BigintToLong } from "../util/Decorators";
|
||||
import { JsonNumber } from "../util/Decorators";
|
||||
|
||||
@Entity({
|
||||
name: "users",
|
||||
@@ -125,22 +125,22 @@ export class User extends BaseClass {
|
||||
email?: string; // email of the user
|
||||
|
||||
@Column({ type: "bigint" })
|
||||
@BigintToLong
|
||||
@JsonNumber
|
||||
flags: number = 0; // UserFlags // TODO: generate
|
||||
|
||||
@Column({ type: "bigint" })
|
||||
@BigintToLong
|
||||
@JsonNumber
|
||||
public_flags: number = 0;
|
||||
|
||||
@Column({ type: "bigint" })
|
||||
@BigintToLong
|
||||
@JsonNumber
|
||||
purchased_flags: number = 0;
|
||||
|
||||
@Column()
|
||||
premium_usage_flags: number = 0;
|
||||
|
||||
@Column({ type: "bigint" })
|
||||
@BigintToLong
|
||||
@JsonNumber
|
||||
rights: string;
|
||||
|
||||
@OneToMany(() => Session, (session: Session) => session.user)
|
||||
|
||||
@@ -20,7 +20,7 @@ export function JsonRemoveEmpty(target: BaseClassWithoutId, propertyKey: string)
|
||||
addAnnotationMetadata(target, propertyKey, "JsonRemoveEmpty");
|
||||
}
|
||||
|
||||
export function BigintToLong(target: BaseClassWithoutId, propertyKey: string) {
|
||||
export function JsonNumber(target: BaseClassWithoutId, propertyKey: string) {
|
||||
initAnnotationMetadata(target, propertyKey);
|
||||
addAnnotationMetadata(target, propertyKey, "BigintToLong");
|
||||
addAnnotationMetadata(target, propertyKey, "JsonNumber");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user