mirror of
https://github.com/GSA/notifications-api.git
synced 2026-07-24 09:58:53 -04:00
merge from main
This commit is contained in:
@@ -19,7 +19,6 @@ from flask import (
|
||||
)
|
||||
from flask.ctx import has_app_context
|
||||
from flask_migrate import Migrate
|
||||
from flask_socketio import SocketIO
|
||||
from flask_sqlalchemy import SQLAlchemy as _SQLAlchemy
|
||||
from sqlalchemy import event
|
||||
from werkzeug.exceptions import HTTPException as WerkzeugHTTPException
|
||||
@@ -102,15 +101,6 @@ zendesk_client = None
|
||||
redis_store = RedisClient()
|
||||
document_download_client = None
|
||||
|
||||
socketio = SocketIO(
|
||||
cors_allowed_origins=[
|
||||
config.Config.ADMIN_BASE_URL,
|
||||
],
|
||||
message_queue=config.Config.REDIS_URL,
|
||||
logger=True,
|
||||
engineio_logger=True,
|
||||
)
|
||||
|
||||
notification_provider_clients = NotificationProviderClients()
|
||||
|
||||
api_user = LocalProxy(lambda: g.api_user)
|
||||
@@ -195,11 +185,6 @@ def create_app(application):
|
||||
application.config["NOTIFY_APP_NAME"] = application.name
|
||||
init_app(application)
|
||||
|
||||
socketio.init_app(application)
|
||||
|
||||
from app.socket_handlers import register_socket_handlers
|
||||
|
||||
register_socket_handlers(socketio)
|
||||
request_helper.init_app(application)
|
||||
db.init_app(application)
|
||||
logging.init_app(application)
|
||||
|
||||
@@ -26,11 +26,9 @@ from werkzeug.datastructures import MultiDict
|
||||
from app import create_uuid, db
|
||||
from app.dao.dao_utils import autocommit
|
||||
from app.dao.inbound_sms_dao import Pagination
|
||||
from app.dao.jobs_dao import dao_get_job_by_id
|
||||
from app.enums import KeyType, NotificationStatus, NotificationType
|
||||
from app.models import FactNotificationStatus, Notification, NotificationHistory
|
||||
from app.utils import (
|
||||
emit_job_update_summary,
|
||||
escape_special_characters,
|
||||
get_midnight_in_utc,
|
||||
midnight_n_days_ago,
|
||||
@@ -897,19 +895,6 @@ def dao_update_delivery_receipts(receipts, delivered):
|
||||
f"#loadtestperformance batch update query time: \
|
||||
updated {len(receipts)} notification in {elapsed_time} ms"
|
||||
)
|
||||
job_ids = (
|
||||
db.session.execute(
|
||||
select(Notification.job_id).where(
|
||||
Notification.message_id.in_(id_to_carrier.keys())
|
||||
)
|
||||
)
|
||||
.scalars()
|
||||
.all()
|
||||
)
|
||||
|
||||
for job_id in set(job_ids):
|
||||
job = dao_get_job_by_id(job_id)
|
||||
emit_job_update_summary(job)
|
||||
|
||||
|
||||
def dao_close_out_delivery_receipts():
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
from flask import current_app, request
|
||||
from flask_socketio import join_room, leave_room
|
||||
|
||||
|
||||
def register_socket_handlers(socketio):
|
||||
@socketio.on("connect")
|
||||
def on_connect():
|
||||
current_app.logger.info(
|
||||
f"Socket {request.sid} connected from {request.environ.get('HTTP_ORIGIN')}"
|
||||
)
|
||||
return True
|
||||
|
||||
@socketio.on("disconnect")
|
||||
def on_disconnect():
|
||||
current_app.logger.info(f"Socket {request.sid} disconnected")
|
||||
|
||||
@socketio.on("join")
|
||||
def on_join(data): # noqa: F401
|
||||
room = data.get("room")
|
||||
join_room(room)
|
||||
current_app.logger.info(f"Socket {request.sid} joined room {room}")
|
||||
|
||||
@socketio.on("leave")
|
||||
def on_leave(data): # noqa: F401
|
||||
room = data.get("room")
|
||||
leave_room(room)
|
||||
current_app.logger.info(f"Socket {request.sid} left room {room}")
|
||||
14
app/utils.py
14
app/utils.py
@@ -146,20 +146,6 @@ def debug_not_production(msg):
|
||||
current_app.logger.info(msg)
|
||||
|
||||
|
||||
def emit_job_update_summary(job):
|
||||
from app import socketio
|
||||
|
||||
socketio.emit(
|
||||
"job_updated",
|
||||
{
|
||||
"job_id": str(job.id),
|
||||
"job_status": job.job_status,
|
||||
"notification_count": job.notification_count,
|
||||
},
|
||||
room=f"job-{job.id}",
|
||||
)
|
||||
|
||||
|
||||
def is_suspicious_input(input_str):
|
||||
if not isinstance(input_str, str):
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user