|
5 | 5 | "encoding/json" //"errors"
|
6 | 6 | "fmt"
|
7 | 7 | mh "gx/ipfs/QmerPMzPk1mJVowm8KgmoknWa4yCYvvugMPsgWmDNUvDLW/go-multihash"
|
| 8 | + "math/big" |
8 | 9 | "time"
|
9 | 10 | )
|
10 | 11 |
|
@@ -313,7 +314,27 @@ func (n *Notification) UnmarshalJSON(data []byte) error {
|
313 | 314 | case NotifierTypeOrderNewNotification:
|
314 | 315 | var notifier = OrderNotification{}
|
315 | 316 | if err := json.Unmarshal(payload.NotifierData, ¬ifier); err != nil {
|
316 |
| - return err |
| 317 | + notifierLegacy := OrderNotificationV4{} |
| 318 | + if err2 := json.Unmarshal(payload.NotifierData, ¬ifierLegacy); err2 != nil { |
| 319 | + return err2 |
| 320 | + } |
| 321 | + notifier.OrderId = notifierLegacy.OrderId |
| 322 | + notifier.BuyerHandle = notifierLegacy.BuyerHandle |
| 323 | + notifier.BuyerID = notifierLegacy.BuyerID |
| 324 | + notifier.ID = notifierLegacy.ID |
| 325 | + notifier.Price = &CurrencyValue{ |
| 326 | + Amount: new(big.Int).SetUint64(notifierLegacy.Price.Amount), |
| 327 | + Currency: CurrencyDefinition{ |
| 328 | + Code: CurrencyCode(notifierLegacy.Price.CurrencyCode), |
| 329 | + Divisibility: uint(notifierLegacy.Price.CoinDivisibility), |
| 330 | + }, |
| 331 | + } |
| 332 | + notifier.PriceModifier = notifierLegacy.PriceModifier |
| 333 | + notifier.Slug = notifierLegacy.Slug |
| 334 | + notifier.Type = notifierLegacy.Type |
| 335 | + notifier.ListingType = notifierLegacy.ListingType |
| 336 | + notifier.Thumbnail = notifierLegacy.Thumbnail |
| 337 | + notifier.Title = notifierLegacy.Title |
317 | 338 | }
|
318 | 339 | n.NotifierData = notifier
|
319 | 340 | case NotifierTypePaymentNotification:
|
@@ -413,6 +434,27 @@ type OrderNotification struct {
|
413 | 434 | Type NotificationType `json:"type"`
|
414 | 435 | }
|
415 | 436 |
|
| 437 | +type ListingPrice struct { |
| 438 | + Amount uint64 `json:"amount"` |
| 439 | + CurrencyCode string `json:"currencyCode"` |
| 440 | + PriceModifier float32 `json:"priceModifier"` |
| 441 | + CoinDivisibility uint32 `json:"coinDivisibility"` |
| 442 | +} |
| 443 | + |
| 444 | +type OrderNotificationV4 struct { |
| 445 | + BuyerHandle string `json:"buyerHandle"` |
| 446 | + BuyerID string `json:"buyerId"` |
| 447 | + ID string `json:"notificationId"` |
| 448 | + ListingType string `json:"listingType"` |
| 449 | + OrderId string `json:"orderId"` |
| 450 | + Price ListingPrice `json:"price"` |
| 451 | + PriceModifier float32 `json:"priceModifier"` |
| 452 | + Slug string `json:"slug"` |
| 453 | + Thumbnail Thumbnail `json:"thumbnail"` |
| 454 | + Title string `json:"title"` |
| 455 | + Type NotificationType `json:"type"` |
| 456 | +} |
| 457 | + |
416 | 458 | func (n OrderNotification) Data() ([]byte, error) {
|
417 | 459 | return json.MarshalIndent(notificationWrapper{n}, "", " ")
|
418 | 460 | }
|
|
0 commit comments