Commit 311ea6f9 authored by Simon Esposito's avatar Simon Esposito
Browse files

Fix subscription upsert query

parent 9114f9bb
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -4688,10 +4688,6 @@
        "operator": {
          "$ref": "#/definitions/apiOperator",
          "description": "Operator."
        },
        "authoritative": {
          "type": "boolean",
          "description": "Whether the leaderboard was created authoritatively or not."
        }
      },
      "description": "A tournament on the server."
@@ -5010,7 +5006,7 @@
        },
        "providerResponse": {
          "type": "string",
          "description": "Raw provider validation response."
          "description": "Raw provider validation response body."
        },
        "environment": {
          "$ref": "#/definitions/apiStoreEnvironment",
@@ -5065,6 +5061,14 @@
        "active": {
          "type": "boolean",
          "description": "Whether the subscription is currently active or not."
        },
        "providerResponse": {
          "type": "string",
          "description": "Raw provider validation response body."
        },
        "providerNotification": {
          "type": "string",
          "description": "Raw provider notification body."
        }
      }
    },
+9 −1
Original line number Diff line number Diff line
@@ -3011,7 +3011,7 @@
        },
        "provider_response": {
          "type": "string",
          "description": "Raw provider validation response."
          "description": "Raw provider validation response body."
        },
        "environment": {
          "$ref": "#/definitions/apiStoreEnvironment",
@@ -3066,6 +3066,14 @@
        "active": {
          "type": "boolean",
          "description": "Whether the subscription is currently active or not."
        },
        "provider_response": {
          "type": "string",
          "description": "Raw provider validation response body."
        },
        "provider_notification": {
          "type": "string",
          "description": "Raw provider notification body."
        }
      }
    },
+5 −1
Original line number Diff line number Diff line
@@ -740,7 +740,7 @@ export interface ApiValidatedPurchase {
	environment?:ApiStoreEnvironment
  // Purchase Product ID.
	product_id?:string
  // Raw provider validation response.
  // Raw provider validation response body.
	provider_response?:string
  // UNIX Timestamp when the purchase was done.
	purchase_time?:string
@@ -767,6 +767,10 @@ export interface ApiValidatedSubscription {
	original_transaction_id?:string
  // Purchase Product ID.
	product_id?:string
  // Raw provider notification body.
	provider_notification?:string
  // Raw provider validation response body.
	provider_response?:string
  // UNIX Timestamp when the purchase was done.
	purchase_time?:string
  // Store identifier
+0 −4
+4 −4
Original line number Diff line number Diff line
@@ -492,15 +492,15 @@ INTO
         		raw_notification
        )
VALUES
    ($1, $2, $3, $4, $5, $6, $7, NULLIF($8, ''), NULLIF($9, ''))
    ($1, $2, $3, $4, $5, $6, $7, COALESCE(NULLIF($8, ''), '{}'::JSONB), COALESCE(NULLIF($9, ''), '{}'::JSONB))
ON CONFLICT
    (original_transaction_id)
DO
	UPDATE SET
		expire_time = $7,
		update_time = now(),
		raw_response = $8,
		raw_notification = $9
		raw_response = COALESCE(NULLIF($8, ''), subscription.raw_response),
		raw_notification = COALESCE(NULLIF($9, ''), subscription.raw_notification)
RETURNING
    create_time, update_time, expire_time, raw_response, raw_notification
`
@@ -511,7 +511,7 @@ RETURNING
		rawResponse     string
		rawNotification string
	)
	if err := db.QueryRowContext(ctx, query, sub.userID, sub.store, sub.originalTransactionId, sub.productId, sub.purchaseTime, sub.environment, sub.expireTime, sub.rawResponse).Scan(&createTime, &updateTime, &expireTime, &rawResponse, &rawNotification); err != nil {
	if err := db.QueryRowContext(ctx, query, sub.userID, sub.store, sub.originalTransactionId, sub.productId, sub.purchaseTime, sub.environment, sub.expireTime, sub.rawResponse, sub.rawNotification).Scan(&createTime, &updateTime, &expireTime, &rawResponse, &rawNotification); err != nil {
		return err
	}

Loading