@@ -4,7 +4,7 @@ import { IModule, IModuleUpdateBody, Module, PlatformNames, ModuleNames } from '
44
55import platformService from './platform.service' ;
66import websiteService from './website' ;
7-
7+ import temporalMediaWiki from './temporal/mediaWiki.service' ;
88/**
99 * Create a module
1010 * @param {IModule } ModuleBody
@@ -94,6 +94,9 @@ const updateModule = async (
9494 // if (module.name === ModuleNames.Hivemind && newPlatform.name === PlatformNames.Website) {
9595 // await handleHivemindWebsiteCase(newPlatform);
9696 // }
97+ if ( module . name === ModuleNames . Hivemind && newPlatform . name === PlatformNames . MediaWiki ) {
98+ await handleHivemindMediaWikiCase ( newPlatform ) ;
99+ }
97100 existingPlatform . metadata = newPlatform . metadata ;
98101 } else {
99102 module . options . platforms . push ( newPlatform ) ;
@@ -132,6 +135,27 @@ const handleHivemindWebsiteCase = async (platform: any) => {
132135 }
133136} ;
134137
138+ /**
139+ * Handle special case for Hivemind module with MediaWiki platform
140+ * @param {Object } platform - Platform object
141+ */
142+ const handleHivemindMediaWikiCase = async ( platform : any ) => {
143+ const platformDoc = await platformService . getPlatformById ( platform . platform ) ;
144+
145+ if ( ! platformDoc ) return ;
146+
147+ const isActivated = platform . metadata ?. activated ;
148+ const existingWorkflowId = platformDoc . get ( 'metadata.workflowId' ) ;
149+
150+ if ( isActivated === true ) {
151+ if ( ! existingWorkflowId ) {
152+ const workflowId = await temporalMediaWiki . executeWorkflow ( platform . platform ) ;
153+ platformDoc . set ( 'metadata.workflowId' , workflowId ) ;
154+ await platformDoc . save ( ) ;
155+ }
156+ }
157+ } ;
158+
135159/**
136160 * Delete module
137161 * @param {HydratedDocument<IModule> } module - module doc
0 commit comments