Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/controllers/platform.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,7 @@ const getPlatform = catchAsync(async function (req: IAuthRequest, res: Response)
res.send(platform);
});
const updatePlatform = catchAsync(async function (req: IAuthAndPlatform, res: Response) {
console.log('Debug1');
platformService.validatePlatformUpdate(req.platform, req.body);
console.log('Debug2');

const platform = await platformService.updatePlatform(req.platform, req.user, req.body);
res.send(platform);
});
Expand Down
11 changes: 10 additions & 1 deletion src/services/module.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { FilterQuery, HydratedDocument, ObjectId, Types } from 'mongoose';

import { IModule, IModuleUpdateBody, Module, ModuleNames, PlatformNames } from '@togethercrew.dev/db';
import {
IModule, IModuleUpdateBody, Module, ModuleNames, PlatformNames
} from '@togethercrew.dev/db';

import platformService from './platform.service';
import websiteService from './website';
Expand Down Expand Up @@ -63,10 +65,14 @@ const updateModule = async (
module: HydratedDocument<IModule>,
updateBody: Partial<IModuleUpdateBody>,
): Promise<HydratedDocument<IModule>> => {
console.log('S1', module.name, updateBody.options?.platforms);

if (!updateBody.options?.platforms?.length) {
return module.save();
}

console.log('S2', module.options);

if (!module.options) {
module.options = { platforms: [] };
} else if (!module.options.platforms) {
Expand All @@ -75,6 +81,8 @@ const updateModule = async (

const platforms = updateBody.options.platforms;

console.log('S3', platforms[0].name);

if (platforms[0].name === undefined) {
const globalOption = module.options.platforms[0];
if (globalOption) {
Expand All @@ -87,6 +95,7 @@ const updateModule = async (

for (const newPlatform of platforms) {
const existingPlatform = module.options.platforms.find((p) => p.name === newPlatform.name);
console.log('S4', existingPlatform);

if (existingPlatform) {
existingPlatform.metadata = newPlatform.metadata;
Expand Down
3 changes: 0 additions & 3 deletions src/services/platform.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ const updatePlatform = async (
user: HydratedDocument<IUser>,
updateBody: Partial<IPlatform>,
): Promise<HydratedDocument<IPlatform>> => {
console.log('123', updateBody.metadata);

// Handle special cases based on platform type
if (platform.name === PlatformNames.Website) {
await handleWebsiteResourceChanges(platform, updateBody);
Expand All @@ -140,7 +138,6 @@ const updatePlatform = async (
}
}

console.log('321', updateBody.metadata);
if (updateBody.metadata) {
updateBody.metadata = {
...platform.metadata,
Expand Down