system now uses seperate pricing.
All checks were successful
Build Frontend / Build Frontend (push) Successful in 24s
All checks were successful
Build Frontend / Build Frontend (push) Successful in 24s
This commit is contained in:
@@ -786,6 +786,98 @@ export default async function adminManagementRoutes(fastify, options) {
|
||||
}
|
||||
);
|
||||
|
||||
// PATCH /admin/config/instantsell - Update instant sell settings
|
||||
fastify.patch(
|
||||
"/config/instantsell",
|
||||
{
|
||||
preHandler: [authenticate, isAdmin],
|
||||
schema: {
|
||||
body: {
|
||||
type: "object",
|
||||
properties: {
|
||||
enabled: { type: "boolean" },
|
||||
payoutRate: { type: "number", minimum: 0, maximum: 1 },
|
||||
minItemValue: { type: "number", minimum: 0 },
|
||||
maxItemValue: { type: "number", minimum: 0 },
|
||||
cs2: {
|
||||
type: "object",
|
||||
properties: {
|
||||
enabled: { type: "boolean" },
|
||||
payoutRate: { type: "number", minimum: 0, maximum: 1 },
|
||||
},
|
||||
},
|
||||
rust: {
|
||||
type: "object",
|
||||
properties: {
|
||||
enabled: { type: "boolean" },
|
||||
payoutRate: { type: "number", minimum: 0, maximum: 1 },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
async (request, reply) => {
|
||||
try {
|
||||
const config = await SiteConfig.getConfig();
|
||||
|
||||
// Update top-level instant sell settings
|
||||
["enabled", "payoutRate", "minItemValue", "maxItemValue"].forEach(
|
||||
(key) => {
|
||||
if (request.body[key] !== undefined) {
|
||||
config.instantSell[key] = request.body[key];
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Update CS2 settings
|
||||
if (request.body.cs2) {
|
||||
Object.keys(request.body.cs2).forEach((key) => {
|
||||
if (request.body.cs2[key] !== undefined) {
|
||||
config.instantSell.cs2[key] = request.body.cs2[key];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Update Rust settings
|
||||
if (request.body.rust) {
|
||||
Object.keys(request.body.rust).forEach((key) => {
|
||||
if (request.body.rust[key] !== undefined) {
|
||||
config.instantSell.rust[key] = request.body.rust[key];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
config.lastUpdatedBy = request.user.username;
|
||||
config.lastUpdatedAt = new Date();
|
||||
|
||||
await config.save();
|
||||
|
||||
console.log(
|
||||
`⚙️ Admin ${request.user.username} updated instant sell settings:`,
|
||||
{
|
||||
payoutRate: config.instantSell.payoutRate,
|
||||
cs2PayoutRate: config.instantSell.cs2?.payoutRate,
|
||||
rustPayoutRate: config.instantSell.rust?.payoutRate,
|
||||
}
|
||||
);
|
||||
|
||||
return reply.send({
|
||||
success: true,
|
||||
message: "Instant sell settings updated",
|
||||
instantSell: config.instantSell,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("❌ Failed to update instant sell settings:", error);
|
||||
return reply.status(500).send({
|
||||
success: false,
|
||||
message: "Failed to update instant sell settings",
|
||||
error: error.message,
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// ============================================
|
||||
// ANNOUNCEMENTS
|
||||
// ============================================
|
||||
|
||||
Reference in New Issue
Block a user