Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion database/bookmarks_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@ def _ensure_indexes(self):
[("user_id", ASCENDING), ("file_id", ASCENDING), ("anchor_id", ASCENDING)],
unique=True,
name="unique_user_file_anchor",
# שים לב: יש גרסאות MongoDB שאינן תומכות ב-$ne בתוך partial index (מתורגם ל-$not).
# כדי לשמור תאימות מלאה, נשתמש בסינון שמוודא קיום וסוג מחרוזת בלבד, כאשר ערכים ריקים
# אינם נשמרים מלכתחילה (to_dict לא שומר anchor_id ריק, וב-startup אנו מבצעים unset).
partialFilterExpression={
"anchor_id": {"$type": "string", "$ne": ""}
"anchor_id": {"$exists": True, "$type": "string"}
},
),
# אינדקס לחיפוש מהיר לפי משתמש וקובץ
Expand Down
36 changes: 36 additions & 0 deletions webapp/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3941,6 +3941,42 @@ def api_ui_prefs():
except Exception:
return jsonify({'ok': False, 'error': 'שגיאה לא צפויה'}), 500


# --- User preferences (generic) ---
@app.route('/api/user/preferences', methods=['POST'])
@login_required
def update_user_preferences():
"""עדכון העדפות משתמש כלליות (כעת: סוג עורך).

מבנה קלט צפוי (JSON): { "editor_type": "simple" | "codemirror" }
"""
try:
payload = request.get_json(silent=True) or {}
editor_type = (payload.get('editor_type') or '').strip().lower()
if editor_type not in {'simple', 'codemirror'}:
return jsonify({'ok': False, 'error': 'Invalid editor type'}), 400

# עדכון session כדי להשפיע מיידית ב-render
session['preferred_editor'] = editor_type

# שמירה ב-DB תחת ui_prefs.editor לשימור חוצה דיפלוימנטים
try:
from datetime import datetime, timezone
db = get_db()
user_id = session['user_id']
db.users.update_one(
{'user_id': user_id},
{'$set': {'ui_prefs.editor': editor_type, 'updated_at': datetime.now(timezone.utc)}},
upsert=True,
)
except Exception:
# לא מפילים את הבקשה במקרה של DB בעייתי – נשמור לפחות בסשן
pass

return jsonify({'ok': True, 'editor_type': editor_type})
except Exception:
return jsonify({'ok': False, 'error': 'שגיאה לא צפויה'}), 500

# --- Public statistics for landing/mini web app ---
@app.route('/api/public_stats')
def api_public_stats():
Expand Down
Loading