@@ -265,6 +265,21 @@ export async function reject (
265
265
}
266
266
}
267
267
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
+
268
283
/**
269
284
* Forcefully reject a submission, this will run cleanup for the submission.
270
285
*/
@@ -273,7 +288,7 @@ export async function forceReject (
273
288
// Could be in the pending state, we will just ignore warnings if that is the case
274
289
submission : ValidatedSubmission | PendingSubmission ,
275
290
template : RejectionTemplate
276
- ) : Promise < VoteModificationResult > {
291
+ ) : Promise < RejectionResult > {
277
292
// Do not allow paused submissions to be rejected, this should be checked by the caller
278
293
// Errored submissions are acceptable because invalid-id cases will be in the error state
279
294
// This case should be validated by callers
@@ -295,6 +310,7 @@ export async function forceReject (
295
310
user : `<@${ submission . authorId } >` ,
296
311
name : submission . name
297
312
} )
313
+
298
314
await runCatching (
299
315
async ( ) =>
300
316
await publicLogs . send ( {
@@ -326,7 +342,7 @@ export async function forceReject (
326
342
}
327
343
} catch ( err ) {
328
344
return {
329
- error : true ,
345
+ outcome : 'error' ,
330
346
message : `Failed to send rejection message: ${ err } `
331
347
}
332
348
}
@@ -366,12 +382,11 @@ export async function forceReject (
366
382
ctx : submission
367
383
} )
368
384
385
+ await updateSubmissionState ( submission , 'DENIED' )
386
+
369
387
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.
372
388
return {
373
- error : true ,
374
- message : 'didnt-run-cleanup'
389
+ outcome : 'cleanup-not-run'
375
390
}
376
391
}
377
392
@@ -383,8 +398,7 @@ export async function forceReject (
383
398
} , 'suppress' )
384
399
385
400
return {
386
- error : false ,
387
- outcome : 'instant-reject'
401
+ outcome : 'success'
388
402
}
389
403
}
390
404
@@ -401,8 +415,7 @@ export async function forceReject (
401
415
} , 'suppress' )
402
416
403
417
return {
404
- error : false ,
405
- outcome : 'instant-reject'
418
+ outcome : 'success'
406
419
}
407
420
}
408
421
0 commit comments