@@ -1127,28 +1127,25 @@ async function createChallenge(currentUser, challenge, userToken) {
1127
1127
1128
1128
enrichChallengeForResponse ( ret , track , type ) ;
1129
1129
1130
- const isLocal = process . env . LOCAL == "true" ;
1131
- if ( ! isLocal ) {
1132
- // Create in ES
1133
- await esClient . create ( {
1134
- index : config . get ( "ES.ES_INDEX" ) ,
1135
- type : config . get ( "ES.OPENSEARCH" ) == "false" ? config . get ( "ES.ES_TYPE" ) : undefined ,
1136
- refresh : config . get ( "ES.ES_REFRESH" ) ,
1137
- id : ret . id ,
1138
- body : ret ,
1139
- } ) ;
1130
+ // Create in ES
1131
+ await esClient . create ( {
1132
+ index : config . get ( "ES.ES_INDEX" ) ,
1133
+ type : config . get ( "ES.OPENSEARCH" ) == "false" ? config . get ( "ES.ES_TYPE" ) : undefined ,
1134
+ refresh : config . get ( "ES.ES_REFRESH" ) ,
1135
+ id : ret . id ,
1136
+ body : ret ,
1137
+ } ) ;
1140
1138
1141
- // If the challenge is self-service, add the creating user as the "client manager", *not* the manager
1142
- // This is necessary for proper handling of the vanilla embed on the self-service work item dashboard
1139
+ // If the challenge is self-service, add the creating user as the "client manager", *not* the manager
1140
+ // This is necessary for proper handling of the vanilla embed on the self-service work item dashboard
1143
1141
1144
- if ( challenge . legacy . selfService ) {
1145
- if ( currentUser . handle ) {
1146
- await helper . createResource ( ret . id , ret . createdBy , config . CLIENT_MANAGER_ROLE_ID ) ;
1147
- }
1148
- } else {
1149
- if ( currentUser . handle ) {
1150
- await helper . createResource ( ret . id , ret . createdBy , config . MANAGER_ROLE_ID ) ;
1151
- }
1142
+ if ( challenge . legacy . selfService ) {
1143
+ if ( currentUser . handle ) {
1144
+ await helper . createResource ( ret . id , ret . createdBy , config . CLIENT_MANAGER_ROLE_ID ) ;
1145
+ }
1146
+ } else {
1147
+ if ( currentUser . handle ) {
1148
+ await helper . createResource ( ret . id , ret . createdBy , config . MANAGER_ROLE_ID ) ;
1152
1149
}
1153
1150
}
1154
1151
@@ -1501,6 +1498,10 @@ async function updateChallenge(currentUser, challengeId, data) {
1501
1498
data = sanitizeData ( sanitizeChallenge ( data ) , challenge ) ;
1502
1499
console . debug ( "Sanitized Data:" , data ) ;
1503
1500
1501
+ if ( data . phases != null && data . startDate == null ) {
1502
+ data . startDate = challenge . startDate ;
1503
+ }
1504
+
1504
1505
validateChallengeUpdateRequest ( currentUser , challenge , data ) ;
1505
1506
1506
1507
const projectId = _ . get ( challenge , "projectId" ) ;
@@ -1887,64 +1888,61 @@ async function updateChallenge(currentUser, challengeId, data) {
1887
1888
: undefined ,
1888
1889
} ) ;
1889
1890
1890
- const isLocal = process . env . LOCAL == "true" ;
1891
- if ( ! isLocal ) {
1892
- // Update ES
1893
- await esClient . update ( {
1894
- index : config . get ( "ES.ES_INDEX" ) ,
1895
- type : config . get ( "ES.OPENSEARCH" ) == "false" ? config . get ( "ES.ES_TYPE" ) : undefined ,
1896
- refresh : config . get ( "ES.ES_REFRESH" ) ,
1897
- id : challengeId ,
1898
- body : {
1899
- doc : updatedChallenge ,
1900
- } ,
1901
- } ) ;
1891
+ // Update ES
1892
+ await esClient . update ( {
1893
+ index : config . get ( "ES.ES_INDEX" ) ,
1894
+ type : config . get ( "ES.OPENSEARCH" ) == "false" ? config . get ( "ES.ES_TYPE" ) : undefined ,
1895
+ refresh : config . get ( "ES.ES_REFRESH" ) ,
1896
+ id : challengeId ,
1897
+ body : {
1898
+ doc : updatedChallenge ,
1899
+ } ,
1900
+ } ) ;
1902
1901
1903
- if ( updatedChallenge . legacy . selfService ) {
1904
- const creator = await helper . getMemberByHandle ( updatedChallenge . createdBy ) ;
1905
- if ( sendSubmittedEmail ) {
1906
- await helper . sendSelfServiceNotification (
1907
- constants . SelfServiceNotificationTypes . WORK_REQUEST_SUBMITTED ,
1908
- [ { email : creator . email } ] ,
1909
- {
1910
- handle : creator . handle ,
1911
- workItemName : updatedChallenge . name ,
1912
- }
1913
- ) ;
1914
- }
1915
- if ( sendActivationEmail ) {
1916
- await helper . sendSelfServiceNotification (
1917
- constants . SelfServiceNotificationTypes . WORK_REQUEST_STARTED ,
1918
- [ { email : creator . email } ] ,
1919
- {
1920
- handle : creator . handle ,
1921
- workItemName : updatedChallenge . name ,
1922
- workItemUrl : `${ config . SELF_SERVICE_APP_URL } /work-items/${ updatedChallenge . id } ` ,
1923
- }
1924
- ) ;
1925
- }
1926
- if ( sendCompletedEmail ) {
1927
- await helper . sendSelfServiceNotification (
1928
- constants . SelfServiceNotificationTypes . WORK_COMPLETED ,
1929
- [ { email : creator . email } ] ,
1930
- {
1931
- handle : creator . handle ,
1932
- workItemName : updatedChallenge . name ,
1933
- workItemUrl : `${ config . SELF_SERVICE_APP_URL } /work-items/${ updatedChallenge . id } ?tab=solutions` ,
1934
- }
1935
- ) ;
1936
- }
1937
- if ( sendRejectedEmail || cancelReason ) {
1938
- logger . debug ( "Should send redirected email" ) ;
1939
- await helper . sendSelfServiceNotification (
1940
- constants . SelfServiceNotificationTypes . WORK_REQUEST_REDIRECTED ,
1941
- [ { email : creator . email } ] ,
1942
- {
1943
- handle : creator . handle ,
1944
- workItemName : updatedChallenge . name ,
1945
- }
1946
- ) ;
1947
- }
1902
+ if ( updatedChallenge . legacy . selfService ) {
1903
+ const creator = await helper . getMemberByHandle ( updatedChallenge . createdBy ) ;
1904
+ if ( sendSubmittedEmail ) {
1905
+ await helper . sendSelfServiceNotification (
1906
+ constants . SelfServiceNotificationTypes . WORK_REQUEST_SUBMITTED ,
1907
+ [ { email : creator . email } ] ,
1908
+ {
1909
+ handle : creator . handle ,
1910
+ workItemName : updatedChallenge . name ,
1911
+ }
1912
+ ) ;
1913
+ }
1914
+ if ( sendActivationEmail ) {
1915
+ await helper . sendSelfServiceNotification (
1916
+ constants . SelfServiceNotificationTypes . WORK_REQUEST_STARTED ,
1917
+ [ { email : creator . email } ] ,
1918
+ {
1919
+ handle : creator . handle ,
1920
+ workItemName : updatedChallenge . name ,
1921
+ workItemUrl : `${ config . SELF_SERVICE_APP_URL } /work-items/${ updatedChallenge . id } ` ,
1922
+ }
1923
+ ) ;
1924
+ }
1925
+ if ( sendCompletedEmail ) {
1926
+ await helper . sendSelfServiceNotification (
1927
+ constants . SelfServiceNotificationTypes . WORK_COMPLETED ,
1928
+ [ { email : creator . email } ] ,
1929
+ {
1930
+ handle : creator . handle ,
1931
+ workItemName : updatedChallenge . name ,
1932
+ workItemUrl : `${ config . SELF_SERVICE_APP_URL } /work-items/${ updatedChallenge . id } ?tab=solutions` ,
1933
+ }
1934
+ ) ;
1935
+ }
1936
+ if ( sendRejectedEmail || cancelReason ) {
1937
+ logger . debug ( "Should send redirected email" ) ;
1938
+ await helper . sendSelfServiceNotification (
1939
+ constants . SelfServiceNotificationTypes . WORK_REQUEST_REDIRECTED ,
1940
+ [ { email : creator . email } ] ,
1941
+ {
1942
+ handle : creator . handle ,
1943
+ workItemName : updatedChallenge . name ,
1944
+ }
1945
+ ) ;
1948
1946
}
1949
1947
}
1950
1948
0 commit comments