Skip to content

Commit 8ef8c1d

Browse files
authored
Merge pull request #58 from ResilientApp/test_brushes
Test brushes fixed persisting and stamps not appearing issues
2 parents 040611e + afce51b commit 8ef8c1d

32 files changed

Lines changed: 6158 additions & 566 deletions

backend/app.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,15 @@ def handle_all_exceptions(e):
179179
from api_v1.collaborations import collaborations_v1_bp
180180
from api_v1.notifications import notifications_v1_bp
181181
from api_v1.users import users_v1_bp
182+
from routes.stamps import stamps_bp
182183
from api_v1.templates import templates_v1_bp
183184

184185
app.register_blueprint(auth_v1_bp)
185186
app.register_blueprint(canvases_v1_bp)
186187
app.register_blueprint(collaborations_v1_bp)
187188
app.register_blueprint(notifications_v1_bp)
188189
app.register_blueprint(users_v1_bp)
190+
app.register_blueprint(stamps_bp, url_prefix='/api')
189191
app.register_blueprint(templates_v1_bp)
190192

191193
# Frontend serving must be last to avoid route conflicts

backend/incubator-resilientdb-resilient-python-cache/resilient_python_cache/cache.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import asyncio
2222
import json
2323
import logging
24+
import ssl
2425
from typing import Optional
2526

2627
import httpx
@@ -114,7 +115,7 @@ async def fetch_and_sync_initial_blocks(self):
114115
batch_ranges = []
115116
blocks_fetched = True
116117

117-
async with httpx.AsyncClient() as client:
118+
async with httpx.AsyncClient(verify=False) as client:
118119
while blocks_fetched:
119120
min_seq = self.current_block_number + 1
120121
max_seq = min_seq + batch_size - 1
@@ -158,7 +159,7 @@ async def fetch_and_sync_initial_blocks(self):
158159
async def fetch_and_sync_batch(self, min_seq: int, max_seq: int, semaphore: asyncio.Semaphore):
159160
async with semaphore:
160161
try:
161-
async with httpx.AsyncClient() as client:
162+
async with httpx.AsyncClient(verify=False) as client:
162163
url = f"{self.http_endpoint}/{min_seq}/{max_seq}"
163164
logger.info(f"Fetching blocks from {min_seq} to {max_seq}")
164165
response = await client.get(url)
@@ -217,7 +218,7 @@ async def fetch_and_sync_new_blocks(self):
217218
batch_ranges = []
218219
blocks_fetched = True
219220

220-
async with httpx.AsyncClient() as client:
221+
async with httpx.AsyncClient(verify=False) as client:
221222
while blocks_fetched:
222223
min_seq = self.current_block_number + 1
223224
max_seq = min_seq + batch_size - 1
@@ -251,7 +252,12 @@ async def fetch_and_sync_new_blocks(self):
251252

252253
async def connect_websocket(self):
253254
try:
254-
async with websockets.connect(self.ws_endpoint) as websocket:
255+
# Create SSL context that doesn't verify certificates
256+
ssl_context = ssl.create_default_context()
257+
ssl_context.check_hostname = False
258+
ssl_context.verify_mode = ssl.CERT_NONE
259+
260+
async with websockets.connect(self.ws_endpoint, ssl=ssl_context) as websocket:
255261
logger.info(f"Connected to WebSocket: {self.ws_endpoint}")
256262
self.reconnect_attempts = 0
257263
self.emit('connected')
@@ -318,4 +324,4 @@ async def close(self):
318324
except Exception as e:
319325
logger.error("Error closing connections:")
320326
logger.error(e)
321-
raise ResilientPythonCacheError(str(e)) from e
327+
raise ResilientPythonCacheError(str(e)) from e

backend/middleware/validators.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,46 @@
88

99
import re
1010
from typing import Tuple
11+
from functools import wraps
12+
from flask import request, jsonify
13+
14+
15+
def validate_json(required_fields=None):
16+
"""
17+
Decorator to validate JSON request data.
18+
19+
Args:
20+
required_fields (list): List of required field names
21+
22+
Returns:
23+
Decorator function that validates request JSON
24+
"""
25+
def decorator(f):
26+
@wraps(f)
27+
def decorated_function(*args, **kwargs):
28+
# Check if request has JSON data
29+
if not request.is_json:
30+
return jsonify({'error': 'Request must be JSON'}), 400
31+
32+
data = request.get_json()
33+
if not data:
34+
return jsonify({'error': 'Request body cannot be empty'}), 400
35+
36+
# Check required fields
37+
if required_fields:
38+
missing_fields = []
39+
for field in required_fields:
40+
if field not in data or data[field] is None or data[field] == '':
41+
missing_fields.append(field)
42+
43+
if missing_fields:
44+
return jsonify({
45+
'error': f'Missing required fields: {", ".join(missing_fields)}'
46+
}), 400
47+
48+
return f(*args, **kwargs)
49+
return decorated_function
50+
return decorator
1151

1252

1353
def validate_username(value: str) -> Tuple[bool, str]:

0 commit comments

Comments
 (0)