@@ -502,38 +502,17 @@ const initialize = (
502502 // pending orders are the ones that are not taken by another user
503503 bot . command ( 'cancelall' , userMiddleware , async ( ctx : CommunityContext ) => {
504504 try {
505- const pending_orders =
506- ( await ordersActions . getOrders ( ctx . user , 'PENDING' ) ) || [ ] ;
507- const seller_orders =
508- ( await ordersActions . getOrders ( ctx . user , 'WAITING_BUYER_INVOICE' ) ) ||
509- [ ] ;
510- const buyer_orders =
511- ( await ordersActions . getOrders ( ctx . user , 'WAITING_PAYMENT' ) ) || [ ] ;
512-
513- const orders = [ ...pending_orders , ...seller_orders , ...buyer_orders ] ;
505+ // /cancelall only cancels PENDING orders (published orders that nobody
506+ // has taken yet). Orders already being taken (WAITING_PAYMENT /
507+ // WAITING_BUYER_INVOICE) must be handled individually with /cancel or
508+ // through a dispute, just like single /cancel rejects them.
509+ const orders = ( await ordersActions . getOrders ( ctx . user , 'PENDING' ) ) || [ ] ;
514510
515511 if ( orders . length === 0 ) {
516512 return await messages . notOrdersMessage ( ctx ) ;
517513 }
518514
519515 for ( const order of orders ) {
520- // If a buyer is taking a sell offer and accidentally touch continue button we
521- // let the user to cancel
522- if ( order . type === 'sell' && order . status === 'WAITING_BUYER_INVOICE' ) {
523- return await cancelAddInvoice ( ctx , order ) ;
524- }
525-
526- // If a seller is taking a buy offer and accidentally touch continue button we
527- // let the user to cancel
528- if ( order . type === 'buy' && order . status === 'WAITING_PAYMENT' ) {
529- return await cancelShowHoldInvoice ( ctx , order ) ;
530- }
531-
532- // If a buyer wants cancel but the seller already pay the hold invoice
533- if ( order . type === 'buy' && order . status === 'WAITING_BUYER_INVOICE' ) {
534- if ( order . hash ) await cancelHoldInvoice ( { hash : order . hash } ) ;
535- }
536-
537516 order . status = 'CANCELED' ;
538517 order . canceled_by = ctx . user . id ;
539518 await order . save ( ) ;
0 commit comments