SpaceNinjaServer/src/models/loginModel.ts
Sainan 4895b4630b
Some checks failed
Build Docker image / docker-amd64 (push) Waiting to run
Build Docker image / docker-arm64 (push) Waiting to run
Build / build (push) Has been cancelled
feat: credit boosters (+ daily first win) (#2324)
Daily first win is kinda weird because the client doesn't even seem to acknowledge it.

Also fixed missionCompletionCredits being added to inventory inconsistently (sometimes once, sometimes twice).

Closes #1086
Closes #2322

Reviewed-on: #2324
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-06-27 08:20:37 -07:00

53 lines
1.8 KiB
TypeScript

import { IDatabaseAccountJson, IIgnore } from "@/src/types/loginTypes";
import { model, Schema, SchemaOptions } from "mongoose";
const opts = {
toJSON: { virtuals: true },
toObject: { virtuals: true }
} satisfies SchemaOptions;
const databaseAccountSchema = new Schema<IDatabaseAccountJson>(
{
email: { type: String, required: true, unique: true },
password: { type: String, required: true },
DisplayName: { type: String, required: true, unique: true },
CountryCode: { type: String, default: "" },
ClientType: { type: String },
CrossPlatformAllowed: { type: Boolean, default: true },
ForceLogoutVersion: { type: Number, default: 0 },
AmazonAuthToken: { type: String },
AmazonRefreshToken: { type: String },
ConsentNeeded: { type: Boolean, default: false },
TrackedSettings: { type: [String], default: [] },
Nonce: { type: Number, default: 0 },
BuildLabel: String,
Dropped: Boolean,
LastLogin: { type: Date, default: 0 },
LatestEventMessageDate: { type: Date, default: 0 },
LastLoginRewardDate: { type: Number, default: 0 },
LoginDays: { type: Number, default: 1 },
DailyFirstWinDate: { type: Number, default: 0 }
},
opts
);
databaseAccountSchema.set("toJSON", {
transform(_document, returnedObject) {
delete returnedObject._id;
delete returnedObject.__v;
},
virtuals: true
});
export const Account = model<IDatabaseAccountJson>("Account", databaseAccountSchema);
const ignoreSchema = new Schema<IIgnore>({
ignorer: Schema.Types.ObjectId,
ignoree: Schema.Types.ObjectId
});
ignoreSchema.index({ ignorer: 1 });
ignoreSchema.index({ ignorer: 1, ignoree: 1 }, { unique: true });
export const Ignore = model<IIgnore>("Ignore", ignoreSchema);