diff --git a/src/controllers/api/saveSettingsController.ts b/src/controllers/api/saveSettingsController.ts index 72bf8bfa..40780a35 100644 --- a/src/controllers/api/saveSettingsController.ts +++ b/src/controllers/api/saveSettingsController.ts @@ -14,9 +14,9 @@ const saveSettingsController: RequestHandler = async (req, res): Promise = const settingResults = getJSONfromString(String(req.body)); const inventory = await getInventory(accountId); - inventory.Settings = Object.assign(inventory.Settings, settingResults.Settings); + inventory.Settings = Object.assign(inventory.Settings ?? {}, settingResults.Settings); await inventory.save(); - res.json(inventory.Settings); + res.json({ Settings: inventory.Settings }); }; export { saveSettingsController }; diff --git a/src/models/inventoryModels/inventoryModel.ts b/src/models/inventoryModels/inventoryModel.ts index 7904a12f..2f685233 100644 --- a/src/models/inventoryModels/inventoryModel.ts +++ b/src/models/inventoryModels/inventoryModel.ts @@ -496,7 +496,8 @@ const settingsSchema = new Schema({ GiftMode: String, GuildInvRestriction: String, ShowFriendInvNotifications: Boolean, - TradingRulesConfirmed: Boolean + TradingRulesConfirmed: Boolean, + SubscribedToSurveys: Boolean }); const consumedSchuitsSchema = new Schema( diff --git a/src/types/inventoryTypes/inventoryTypes.ts b/src/types/inventoryTypes/inventoryTypes.ts index 7e18be4d..5d0edcfc 100644 --- a/src/types/inventoryTypes/inventoryTypes.ts +++ b/src/types/inventoryTypes/inventoryTypes.ts @@ -295,7 +295,7 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu Nemesis?: INemesisClient; NemesisHistory: INemesisBaseClient[]; LastNemesisAllySpawnTime?: IMongoDate; - Settings: ISettings; + Settings?: ISettings; PersonalTechProjects: IPersonalTechProject[]; PlayerSkills: IPlayerSkills; CrewShipAmmo: ITypeCount[]; @@ -971,11 +971,12 @@ export interface ISentientSpawnChanceBoosters { } export interface ISettings { - FriendInvRestriction: string; - GiftMode: string; - GuildInvRestriction: string; + FriendInvRestriction: "GIFT_MODE_ALL" | "GIFT_MODE_FRIENDS" | "GIFT_MODE_NONE"; + GiftMode: "GIFT_MODE_ALL" | "GIFT_MODE_FRIENDS" | "GIFT_MODE_NONE"; + GuildInvRestriction: "GIFT_MODE_ALL" | "GIFT_MODE_FRIENDS" | "GIFT_MODE_NONE"; ShowFriendInvNotifications: boolean; TradingRulesConfirmed: boolean; + SubscribedToSurveys?: boolean; } export interface IShipInventory {