Update app.py
Browse files
app.py
CHANGED
|
@@ -233,7 +233,7 @@ def get_or_create_account(platform, udid):
|
|
| 233 |
@app.route('/account/update/<id>', methods=['POST'])
|
| 234 |
def update_account(id):
|
| 235 |
# Request body'den gelen verileri al
|
| 236 |
-
|
| 237 |
|
| 238 |
# ID'ye göre hesabı bul
|
| 239 |
account = next((acc for acc in fake_db["accounts"] if acc["id"] == id), None)
|
|
@@ -245,19 +245,18 @@ def update_account(id):
|
|
| 245 |
"error": "Account not found"
|
| 246 |
}), 404
|
| 247 |
|
| 248 |
-
# Sadece
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
account['level'] = data['level']
|
| 253 |
|
| 254 |
-
# Güncellenmiş hesabı döndür
|
| 255 |
return jsonify({
|
| 256 |
"success": True,
|
| 257 |
"object": {
|
| 258 |
"account": {
|
| 259 |
"id": account["id"],
|
| 260 |
-
"timestamp": account["timestamp"],
|
| 261 |
"udid": account["udid"],
|
| 262 |
"platform": account["platform"],
|
| 263 |
"credit": account["credit"],
|
|
|
|
| 233 |
@app.route('/account/update/<id>', methods=['POST'])
|
| 234 |
def update_account(id):
|
| 235 |
# Request body'den gelen verileri al
|
| 236 |
+
incoming_data = request.get_json()
|
| 237 |
|
| 238 |
# ID'ye göre hesabı bul
|
| 239 |
account = next((acc for acc in fake_db["accounts"] if acc["id"] == id), None)
|
|
|
|
| 245 |
"error": "Account not found"
|
| 246 |
}), 404
|
| 247 |
|
| 248 |
+
# Sadece request'te gelen alanları güncelle (diğerlerine ve timestamp'e dokunma)
|
| 249 |
+
for field in ['credit', 'level', 'platform', 'udid']: # Güncellenebilir alanlar
|
| 250 |
+
if field in incoming_data:
|
| 251 |
+
account[field] = incoming_data[field]
|
|
|
|
| 252 |
|
| 253 |
+
# Güncellenmiş hesabı döndür (timestamp otomatik korunur)
|
| 254 |
return jsonify({
|
| 255 |
"success": True,
|
| 256 |
"object": {
|
| 257 |
"account": {
|
| 258 |
"id": account["id"],
|
| 259 |
+
"timestamp": account["timestamp"], # Orjinal değer korunur
|
| 260 |
"udid": account["udid"],
|
| 261 |
"platform": account["platform"],
|
| 262 |
"credit": account["credit"],
|