@@ -18,7 +18,6 @@ export function schedulePublish(request: functions.Request): Promise<ScheduledPu
1818 try {
1919 const token : string | undefined = await geToken ( request ) ;
2020 const deckId : string | undefined = request . body . deckId ;
21- const ownerId : string | undefined = request . body . ownerId ;
2221
2322 if ( ! deckId ) {
2423 reject ( 'No deck information provided.' ) ;
@@ -30,11 +29,6 @@ export function schedulePublish(request: functions.Request): Promise<ScheduledPu
3029 return ;
3130 }
3231
33- if ( ! ownerId ) {
34- reject ( 'No owner ID provided.' ) ;
35- return ;
36- }
37-
3832 const publish : boolean = request . body . publish !== undefined && request . body . publish ;
3933 const github : boolean = request . body . github !== undefined && request . body . github ;
4034
@@ -44,25 +38,10 @@ export function schedulePublish(request: functions.Request): Promise<ScheduledPu
4438 }
4539
4640 // We tell the frontend to wait
47- await updateDeckDeploy ( deckId , ownerId , publish , github ) ;
41+ await updateDeckDeploy ( deckId , publish , github ) ;
4842
4943 // We schedule internally / cloud the job so we keep secret the token
50-
51- if ( publish ) {
52- await scheduleTask ( {
53- deckId,
54- token,
55- type : 'publish-deck' ,
56- } ) ;
57- }
58-
59- if ( github ) {
60- await scheduleTask ( {
61- deckId,
62- token,
63- type : 'push-github' ,
64- } ) ;
65- }
44+ await schedule ( deckId , publish , github , token ) ;
6645
6746 resolve ( {
6847 deckId,
@@ -76,7 +55,35 @@ export function schedulePublish(request: functions.Request): Promise<ScheduledPu
7655 } ) ;
7756}
7857
79- function updateDeckDeploy ( deckId : string , ownerId : string , publish : boolean , github : boolean ) : Promise < void > {
58+ async function schedule ( deckId : string , publish : boolean , github : boolean , token : string ) {
59+ if ( publish && github ) {
60+ await scheduleTask ( {
61+ deckId,
62+ token,
63+ type : 'publish-all' ,
64+ } ) ;
65+
66+ return ;
67+ }
68+
69+ if ( publish ) {
70+ await scheduleTask ( {
71+ deckId,
72+ token,
73+ type : 'publish-deck' ,
74+ } ) ;
75+ }
76+
77+ if ( github ) {
78+ await scheduleTask ( {
79+ deckId,
80+ token,
81+ type : 'push-github' ,
82+ } ) ;
83+ }
84+ }
85+
86+ function updateDeckDeploy ( deckId : string , publish : boolean , github : boolean ) : Promise < void > {
8087 return new Promise < void > ( async ( resolve , reject ) => {
8188 try {
8289 if ( ! deckId || deckId === undefined || ! deckId ) {
0 commit comments