mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-19 05:58:53 -04:00
code review feedback
This commit is contained in:
@@ -286,6 +286,13 @@ def init_app(app):
|
||||
@app.after_request
|
||||
def after_request(response):
|
||||
response.headers.add("X-Content-Type-Options", "nosniff")
|
||||
|
||||
# Some dynamic scan findings
|
||||
response.headers.add("Cross-Origin-Opener-Policy", "same-origin")
|
||||
response.headers.add("Cross-Origin-Embedder-Policy", "require-corp")
|
||||
response.headers.add("Cross-Origin-Resource-Policy", "same-origin")
|
||||
response.headers.add("Cross-Origin-Opener-Policy", "same-origin")
|
||||
|
||||
return response
|
||||
|
||||
@app.errorhandler(Exception)
|
||||
|
||||
@@ -52,7 +52,8 @@ def cleanup_unfinished_jobs():
|
||||
# The query already checks that the processing_finished time is null, so here we are saying
|
||||
# if it started more than 4 hours ago, that's too long
|
||||
try:
|
||||
acceptable_finish_time = job.processing_started + timedelta(minutes=5)
|
||||
if job.processing_started is not None:
|
||||
acceptable_finish_time = job.processing_started + timedelta(minutes=5)
|
||||
except TypeError:
|
||||
current_app.logger.exception(
|
||||
f"Job ID {job.id} processing_started is {job.processing_started}.",
|
||||
|
||||
@@ -846,6 +846,19 @@ def create_new_service(name, message_limit, restricted, email_from, created_by_i
|
||||
db.session.rollback()
|
||||
|
||||
|
||||
@notify_command(name="get-service-sender-phones")
|
||||
@click.option("-s", "--service_id", required=True, prompt=True)
|
||||
def get_service_sender_phones(service_id):
|
||||
sender_phone_numbers = """
|
||||
select sms_sender, is_default
|
||||
from service_sms_senders
|
||||
where service_id = :service_id
|
||||
"""
|
||||
rows = db.session.execute(text(sender_phone_numbers), {"service_id": service_id})
|
||||
for row in rows:
|
||||
print(row)
|
||||
|
||||
|
||||
@notify_command(name="promote-user-to-platform-admin")
|
||||
@click.option("-u", "--user-email-address", required=True, prompt=True)
|
||||
def promote_user_to_platform_admin(user_email_address):
|
||||
|
||||
@@ -270,7 +270,6 @@ def get_notifications_for_job(
|
||||
def get_recent_notifications_for_job(
|
||||
service_id, job_id, filter_dict=None, page=1, page_size=None
|
||||
):
|
||||
print(f"FILTER_DICT AT DAO LEVEL {filter_dict}")
|
||||
if page_size is None:
|
||||
page_size = current_app.config["PAGE_SIZE"]
|
||||
|
||||
@@ -281,7 +280,6 @@ def get_recent_notifications_for_job(
|
||||
|
||||
stmt = _filter_query(stmt, filter_dict)
|
||||
stmt = stmt.order_by(desc(Notification.job_row_number))
|
||||
print(f"STMT {stmt}")
|
||||
results = db.session.execute(stmt).scalars().all()
|
||||
|
||||
page_size = current_app.config["PAGE_SIZE"]
|
||||
|
||||
@@ -128,7 +128,6 @@ def get_all_notifications_for_service_job(service_id, job_id):
|
||||
@job_blueprint.route("/<job_id>/recent_notifications", methods=["GET"])
|
||||
def get_recent_notifications_for_service_job(service_id, job_id):
|
||||
data = notifications_filter_schema.load(request.args)
|
||||
print(f"DATA COMING IN AT REST LEVEL IS {data}")
|
||||
page = data["page"] if "page" in data else 1
|
||||
page_size = (
|
||||
data["page_size"]
|
||||
|
||||
Reference in New Issue
Block a user