Skip to content

Commit f3de947

Browse files
authored
Merge pull request #391 from csfloat/fix/strict-rollback-check
fix: Increase Strictness of Rollback Check
2 parents 560f4cc + 855a7b2 commit f3de947

4 files changed

Lines changed: 9 additions & 2 deletions

File tree

src/lib/alarms/rollback.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ function findRollbackTrades(pendingTrades: SlimTrade[], tradeHistory: TradeHisto
3030

3131
// Does it correspond to an active CSFloat sale?
3232
const csfloatTrade = pendingTrades.find(
33-
(e) => e.state === TradeState.PENDING && all_ids.includes(e.contract.item.asset_id)
33+
(e) =>
34+
e.state === TradeState.PENDING &&
35+
all_ids.includes(e.contract.item.asset_id) &&
36+
(trade.other_party_id === e.seller_id || trade.other_party_id === e.buyer_id)
3437
);
3538
if (!csfloatTrade) {
3639
continue;

src/lib/alarms/trade_history.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ export async function getTradeHistoryFromAPI(
147147
.map((e) => {
148148
return {
149149
other_party_url: `https://steamcommunity.com/profiles/${e.steamid_other}`,
150+
other_party_id: e.steamid_other,
150151
received_assets: (e.assets_received || [])
151152
.filter((e) => e.appid === AppId.CSGO)
152153
.map((e) => {
@@ -193,6 +194,7 @@ function parseTradeHistoryHTML(body: string): TradeHistoryStatus[] {
193194
const statuses = [...links].map((e) => {
194195
return {
195196
other_party_url: `https://steamcommunity.com/${e[1]}`,
197+
other_party_id: '',
196198
received_assets: [],
197199
given_assets: [],
198200
trade_id: '',

src/lib/alarms/trade_offer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ export async function pingCancelTrades(pendingTrades: SlimTrade[], tradeHistory:
112112
const rolledBackTrade = (tradeHistory || []).find(
113113
(e) =>
114114
e.status === TradeStatus.TradeProtectionRollback &&
115-
!!e.received_assets.find((a) => a.asset_id === trade.contract?.item?.asset_id)
115+
!!e.received_assets.find((a) => a.asset_id === trade.contract?.item?.asset_id) &&
116+
(e.other_party_id === trade.seller_id || e.other_party_id === trade.buyer_id)
116117
);
117118
if (!rolledBackTrade) {
118119
// no rollback, trade offer was accepted, shouldn't cancel

src/lib/bridge/handlers/trade_history_status.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export interface TradeHistoryStatus {
1111
trade_id: string;
1212
status: number;
1313
other_party_url: string;
14+
other_party_id: string;
1415
received_assets: TradeHistoryAsset[];
1516
given_assets: TradeHistoryAsset[];
1617
time_init: number;

0 commit comments

Comments
 (0)