fix(starpost): limit late cargo disclosure
This commit is contained in:
1 parent
7ff9ed2ebf
commit
9f5faac5f7
2 files changed
+13
-1
No files matched your search
+11
-1
@@ -29,6 +29,7 @@ app.config.update(
|
||||
)
|
||||
|
||||
CONTRACT_FILENAME_RE = re.compile(r"contract-([0-9]+)-[0-9a-f]{16}\.pdf")
|
||||
CARGO_PURCHASE_WINDOW_SECONDS = 2
|
||||
|
||||
|
||||
migrate()
|
||||
@@ -591,7 +592,16 @@ def checkout():
|
||||
@auth("buyer")
|
||||
def buyer_orders():
|
||||
with db() as conn, conn.cursor() as cur:
|
||||
cur.execute("SELECT o.id,o.status,o.warehouse_status,o.warehouse_updated_at,o.tracking_code,o.price,o.created_at,o.delivered_at,p.name,CASE WHEN o.status='delivered' THEN p.cargo ELSE NULL END cargo FROM orders o JOIN products p ON p.id=o.product_id WHERE o.buyer_id=%s ORDER BY o.id DESC", (session["user_id"],))
|
||||
cur.execute(
|
||||
"SELECT o.id,o.status,o.warehouse_status,o.warehouse_updated_at,"
|
||||
"o.tracking_code,o.price,o.created_at,o.delivered_at,p.name,"
|
||||
"CASE WHEN o.status='delivered' "
|
||||
"AND o.created_at <= p.created_at + (%s * interval '1 second') "
|
||||
"THEN p.cargo ELSE NULL END cargo "
|
||||
"FROM orders o JOIN products p ON p.id=o.product_id "
|
||||
"WHERE o.buyer_id=%s ORDER BY o.id DESC",
|
||||
(CARGO_PURCHASE_WINDOW_SECONDS, session["user_id"]),
|
||||
)
|
||||
return jsonify(cur.fetchall())
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user