Skip to content

Commit 356f171

Browse files
committed
Fix validation for platform membership ID
1 parent 4700580 commit 356f171

2 files changed

Lines changed: 41 additions & 41 deletions

File tree

api/db/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { metrics } from '../metrics/index.js';
66
export const pool = new pg.Pool({
77
max: 4,
88
ssl: process.env.PGSSL ? process.env.PGSSL === 'true' : { rejectUnauthorized: false },
9-
connectionTimeoutMillis: 500,
9+
connectionTimeoutMillis: 1000,
1010
// Query timeout is on the NodeJS side, it times out the an operation on the client
1111
query_timeout: 2000,
1212
});

api/routes/update.ts

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -118,47 +118,47 @@ function validateUpdates(
118118
status: 'InvalidArgument',
119119
message: `${update.action} requires platform membership ID to be set`,
120120
};
121-
}
121+
} else {
122+
switch (update.action) {
123+
case 'tag_cleanup':
124+
case 'delete_loadout':
125+
case 'track_triumph':
126+
case 'delete_search':
127+
// no special validation
128+
break;
122129

123-
switch (update.action) {
124-
case 'tag_cleanup':
125-
case 'delete_loadout':
126-
case 'track_triumph':
127-
case 'delete_search':
128-
// no special validation
129-
break;
130-
131-
case 'setting':
132-
result = validateUpdateSettings(update.payload);
133-
break;
134-
135-
case 'loadout':
136-
result = validateUpdateLoadout(update.payload);
137-
break;
138-
139-
case 'tag':
140-
result = validateUpdateItemAnnotation(update.payload);
141-
break;
142-
143-
case 'item_hash_tag':
144-
result = validateUpdateItemHashTag(update.payload);
145-
break;
146-
147-
case 'search':
148-
case 'save_search':
149-
result = validateSearch(update.payload);
150-
break;
151-
152-
default:
153-
console.warn(
154-
`Unknown action type: ${(update as { action: string }).action} from ${appId}, ${req.header(
155-
'User-Agent',
156-
)}, ${req.header('Referer')}`,
157-
);
158-
result = {
159-
status: 'InvalidArgument',
160-
message: `Unknown action type: ${(update as { action: string }).action}`,
161-
};
130+
case 'setting':
131+
result = validateUpdateSettings(update.payload);
132+
break;
133+
134+
case 'loadout':
135+
result = validateUpdateLoadout(update.payload);
136+
break;
137+
138+
case 'tag':
139+
result = validateUpdateItemAnnotation(update.payload);
140+
break;
141+
142+
case 'item_hash_tag':
143+
result = validateUpdateItemHashTag(update.payload);
144+
break;
145+
146+
case 'search':
147+
case 'save_search':
148+
result = validateSearch(update.payload);
149+
break;
150+
151+
default:
152+
console.warn(
153+
`Unknown action type: ${(update as { action: string }).action} from ${appId}, ${req.header(
154+
'User-Agent',
155+
)}, ${req.header('Referer')}`,
156+
);
157+
result = {
158+
status: 'InvalidArgument',
159+
message: `Unknown action type: ${(update as { action: string }).action}`,
160+
};
161+
}
162162
}
163163
if (result.status !== 'Success') {
164164
const dimVersion = req.headers['x-dim-version']?.[0];

0 commit comments

Comments
 (0)