Skip to content

Commit dd92b43

Browse files
Merge pull request #470 from TogetherCrew/466-turn-offon-all-module
466 turn offon all module
2 parents f9091c0 + 925df58 commit dd92b43

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/services/module.service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FilterQuery, HydratedDocument, ObjectId, Types } from 'mongoose';
22

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

55
import platformService from './platform.service';
66
import websiteService from './website';
@@ -64,7 +64,9 @@ const updateModule = async (
6464
updateBody: Partial<IModuleUpdateBody>,
6565
): Promise<HydratedDocument<IModule>> => {
6666
if (!updateBody.options?.platforms?.length) {
67-
return module.save();
67+
Object.assign(module, updateBody);
68+
69+
return await module.save();
6870
}
6971

7072
if (!module.options) {

src/validations/module.validation.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,11 @@ const dynamicModuleUpdate = (req: any) => {
199199
moduleId: Joi.string().custom(objectId).required(),
200200
}),
201201
};
202-
let bodyOption = {};
202+
let bodyOption = {
203+
body: Joi.object().required().keys({
204+
activated: Joi.boolean(),
205+
}),
206+
};
203207

204208
switch (moduleName) {
205209
case ModuleNames.Hivemind:

0 commit comments

Comments
 (0)