@@ -129,7 +129,7 @@ func (l *TransactionListener) OnTransactionReceived(cb wallet.TransactionCallbac
129
129
log .Errorf ("update funding for sale (%s): %s" , orderId , err )
130
130
}
131
131
// This is a dispute payout. We should set the order state.
132
- if state == pb . OrderState_DECIDED && len (records ) > 0 && fundsReleased {
132
+ if len (records ) > 0 && fundsReleased {
133
133
if contract .DisputeAcceptance == nil && contract != nil && contract .BuyerOrder != nil && contract .BuyerOrder .BuyerID != nil {
134
134
accept := new (pb.DisputeAcceptance )
135
135
ts , _ := ptypes .TimestampProto (time .Now ())
@@ -154,16 +154,22 @@ func (l *TransactionListener) OnTransactionReceived(cb wallet.TransactionCallbac
154
154
log .Errorf ("persist dispute acceptance notification for order (%s): %s" , orderId , err )
155
155
}
156
156
}
157
- if err := l .db .Sales ().Put (orderId , * contract , pb .OrderState_RESOLVED , false ); err != nil {
158
- log .Errorf ("failed updating order (%s) to RESOLVED: %s" , orderId , err .Error ())
157
+ if state == pb .OrderState_DECIDED {
158
+ if err := l .db .Sales ().Put (orderId , * contract , pb .OrderState_RESOLVED , false ); err != nil {
159
+ log .Errorf ("failed updating order (%s) to RESOLVED: %s" , orderId , err .Error ())
160
+ }
161
+ } else {
162
+ if err := l .db .Sales ().Put (orderId , * contract , state , false ); err != nil {
163
+ log .Errorf ("failed updating order (%s) with DisputeAcceptance: %s" , orderId , err .Error ())
164
+ }
159
165
}
160
166
}
161
167
} else {
162
168
err = l .db .Purchases ().UpdateFunding (orderId , funded , records )
163
169
if err != nil {
164
170
log .Errorf ("update funding for purchase (%s): %s" , orderId , err )
165
171
}
166
- if state == pb . OrderState_DECIDED && len (records ) > 0 && fundsReleased {
172
+ if len (records ) > 0 && fundsReleased {
167
173
if contract .DisputeAcceptance == nil && contract != nil && len (contract .VendorListings ) > 0 && contract .VendorListings [0 ].VendorID != nil {
168
174
accept := new (pb.DisputeAcceptance )
169
175
ts , _ := ptypes .TimestampProto (time .Now ())
@@ -192,8 +198,14 @@ func (l *TransactionListener) OnTransactionReceived(cb wallet.TransactionCallbac
192
198
log .Errorf ("persist dispute acceptance notification for order (%s): %s" , orderId , err )
193
199
}
194
200
}
195
- if err := l .db .Purchases ().Put (orderId , * contract , pb .OrderState_RESOLVED , false ); err != nil {
196
- log .Errorf ("failed updating order (%s) to RESOLVED: %s" , orderId , err .Error ())
201
+ if state == pb .OrderState_DECIDED {
202
+ if err := l .db .Purchases ().Put (orderId , * contract , pb .OrderState_RESOLVED , false ); err != nil {
203
+ log .Errorf ("failed updating order (%s) to RESOLVED: %s" , orderId , err .Error ())
204
+ }
205
+ } else {
206
+ if err := l .db .Purchases ().Put (orderId , * contract , state , false ); err != nil {
207
+ log .Errorf ("failed updating order (%s) with DisputeAcceptance: %s" , orderId , err .Error ())
208
+ }
197
209
}
198
210
}
199
211
}
0 commit comments