Skip to content

Commit

Permalink
Merge pull request #260 from csfloat/fix/annotate-steam-id-ping-cancel;
Browse files Browse the repository at this point in the history
Annotate Steam ID in Ping Cancel
  • Loading branch information
Step7750 authored Oct 15, 2024
2 parents bc2742a + 4d379b7 commit a10edd2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/lib/alarms/trade_offer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export async function pingCancelTrades(pendingTrades: Trade[]) {
}

try {
await PingCancelTrade.handleRequest({trade_id: trade.id}, {});
await PingCancelTrade.handleRequest({trade_id: trade.id, steam_id: tradeOffers.steam_id}, {});
} catch (e) {
console.error(`failed to send cancel ping for trade ${trade.id}`, e);
}
Expand Down Expand Up @@ -238,7 +238,11 @@ async function getSentTradeOffersFromAPI(): Promise<OfferStatus[]> {
return data.response.trade_offers_sent.map(offerStateMapper);
}

async function getSentAndReceivedTradeOffersFromAPI(): Promise<{received: OfferStatus[]; sent: OfferStatus[]}> {
async function getSentAndReceivedTradeOffersFromAPI(): Promise<{
received: OfferStatus[];
sent: OfferStatus[];
steam_id?: string | null;
}> {
const access = await getAccessToken();

const resp = await fetch(
Expand All @@ -256,6 +260,7 @@ async function getSentAndReceivedTradeOffersFromAPI(): Promise<{received: OfferS
return {
received: data.response.trade_offers_received.map(offerStateMapper),
sent: data.response.trade_offers_sent.map(offerStateMapper),
steam_id: access.steam_id,
};
}

Expand Down
7 changes: 7 additions & 0 deletions src/lib/bridge/handlers/ping_cancel_trade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {Trade} from '../../types/float_market';

export interface PingCancelTradeRequest {
trade_id: string;
steam_id?: string | null;
}

export interface PingCancelTradeResponse {
Expand All @@ -17,6 +18,12 @@ export const PingCancelTrade = new SimpleHandler<PingCancelTradeRequest, PingCan
const resp = await fetch(`${environment.csfloat_base_api_url}/v1/trades/${req.trade_id}/cancel-ping`, {
credentials: 'include',
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
steam_id: req.steam_id,
}),
});

if (resp.status !== 200) {
Expand Down

0 comments on commit a10edd2

Please sign in to comment.