Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions bot/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,11 @@ const addInvoicePHI = async (
// only orders with status PAID_HOLD_INVOICE are released payments
if (order.status !== 'PAID_HOLD_INVOICE') return;

// Only the order's buyer may (re)submit the payout invoice. The order id
// comes from the callback data, so we verify the caller is the buyer
// before entering the invoice flow.
if (!ctx.user || String(order.buyer_id) !== String(ctx.user._id)) return;

const buyer = await User.findOne({ _id: order.buyer_id });
if (buyer === null) return;
if (order.amount === 0) {
Expand Down
5 changes: 5 additions & 0 deletions bot/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,11 @@ const initialize = (
const order = await Order.findOne({ _id: ctx.match[1] });
if (!order) return;

// Only the order's buyer may set/replace the payout invoice. The order
// id comes from the callback data, so we verify the caller is the buyer
// before driving the invoice flow.
if (String(order.buyer_id) !== String(ctx.user._id)) return;

if (order.status === 'WAITING_BUYER_INVOICE') {
await addInvoice(ctx, bot, order);
} else {
Expand Down
Loading