@@ -265,6 +265,21 @@ export async function reject (
265265 }
266266}
267267
268+ interface RejectionOk {
269+ outcome : 'success'
270+ }
271+
272+ interface RejectionErr {
273+ outcome : 'error'
274+ message : string
275+ }
276+
277+ interface RejectionCleanupNotRun {
278+ outcome : 'cleanup-not-run'
279+ }
280+
281+ export type RejectionResult = RejectionOk | RejectionErr | RejectionCleanupNotRun
282+
268283/**
269284 * Forcefully reject a submission, this will run cleanup for the submission.
270285 */
@@ -273,7 +288,7 @@ export async function forceReject (
273288 // Could be in the pending state, we will just ignore warnings if that is the case
274289 submission : ValidatedSubmission | PendingSubmission ,
275290 template : RejectionTemplate
276- ) : Promise < VoteModificationResult > {
291+ ) : Promise < RejectionResult > {
277292 // Do not allow paused submissions to be rejected, this should be checked by the caller
278293 // Errored submissions are acceptable because invalid-id cases will be in the error state
279294 // This case should be validated by callers
@@ -295,6 +310,7 @@ export async function forceReject (
295310 user : `<@${ submission . authorId } >` ,
296311 name : submission . name
297312 } )
313+
298314 await runCatching (
299315 async ( ) =>
300316 await publicLogs . send ( {
@@ -326,7 +342,7 @@ export async function forceReject (
326342 }
327343 } catch ( err ) {
328344 return {
329- error : true ,
345+ outcome : 'error' ,
330346 message : `Failed to send rejection message: ${ err } `
331347 }
332348 }
@@ -366,12 +382,11 @@ export async function forceReject (
366382 ctx : submission
367383 } )
368384
385+ await updateSubmissionState ( submission , 'DENIED' )
386+
369387 if ( ! shouldRunCleanup ) {
370- // Not an ideal abort from here, but it's the easiest way to go about it.
371- // This is an extreme edge case for the API design to handle.
372388 return {
373- error : true ,
374- message : 'didnt-run-cleanup'
389+ outcome : 'cleanup-not-run'
375390 }
376391 }
377392
@@ -383,8 +398,7 @@ export async function forceReject (
383398 } , 'suppress' )
384399
385400 return {
386- error : false ,
387- outcome : 'instant-reject'
401+ outcome : 'success'
388402 }
389403 }
390404
@@ -401,8 +415,7 @@ export async function forceReject (
401415 } , 'suppress' )
402416
403417 return {
404- error : false ,
405- outcome : 'instant-reject'
418+ outcome : 'success'
406419 }
407420 }
408421
0 commit comments