mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-31 23:26:23 -05:00
delete commented out code
This commit is contained in:
@@ -2,6 +2,7 @@ import json
|
||||
import os
|
||||
from datetime import timedelta
|
||||
|
||||
from botocore.exceptions import ClientError
|
||||
from flask import current_app
|
||||
from sqlalchemy.orm.exc import NoResultFound
|
||||
|
||||
@@ -62,6 +63,21 @@ def check_sms_delivery_receipt(self, message_id, notification_id, sent_at):
|
||||
provider_response=provider_response,
|
||||
)
|
||||
raise self.retry(exc=ntfe)
|
||||
except ClientError as err:
|
||||
# Probably a ThrottlingException but could be something else
|
||||
error_code = err.response["Error"]["Code"]
|
||||
provider_response = (
|
||||
f"{error_code} while checking sms receipt -- still looking"
|
||||
)
|
||||
status = "pending"
|
||||
carrier = ""
|
||||
update_notification_status_by_id(
|
||||
notification_id,
|
||||
status,
|
||||
carrier=carrier,
|
||||
provider_response=provider_response,
|
||||
)
|
||||
raise self.retry(exc=err)
|
||||
|
||||
if status == "success":
|
||||
status = NotificationStatus.DELIVERED
|
||||
|
||||
@@ -9,10 +9,6 @@ from app.enums import KeyType
|
||||
from app.exceptions import ArchiveValidationError
|
||||
from notifications_utils.recipients import InvalidEmailError
|
||||
|
||||
# class VirusScanError(Exception):
|
||||
# def __init__(self, message):
|
||||
# super().__init__(message)
|
||||
|
||||
|
||||
class InvalidRequest(Exception):
|
||||
code = None
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# from datetime import timedelta
|
||||
|
||||
from flask import Blueprint, jsonify, request
|
||||
|
||||
from app.celery.process_ses_receipts_tasks import process_ses_results
|
||||
@@ -8,7 +6,6 @@ from app.errors import InvalidRequest
|
||||
from app.notifications.sns_handlers import sns_notification_handler
|
||||
|
||||
ses_callback_blueprint = Blueprint("notifications_ses_callback", __name__)
|
||||
# DEFAULT_MAX_AGE = timedelta(days=10000)
|
||||
|
||||
|
||||
# 400 counts as a permanent failure so SNS will not retry.
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import enum
|
||||
|
||||
# from datetime import timedelta
|
||||
from json import decoder
|
||||
|
||||
import requests
|
||||
@@ -9,8 +7,6 @@ from flask import current_app, json
|
||||
from app.errors import InvalidRequest
|
||||
from app.notifications.sns_cert_validator import validate_sns_cert
|
||||
|
||||
# DEFAULT_MAX_AGE = timedelta(days=10000)
|
||||
|
||||
|
||||
class SNSMessageType(enum.Enum):
|
||||
SubscriptionConfirmation = "SubscriptionConfirmation"
|
||||
|
||||
@@ -13,7 +13,7 @@ from app.dao.service_user_dao import dao_get_service_user, dao_update_service_us
|
||||
from app.dao.services_dao import dao_fetch_service_by_id
|
||||
from app.dao.template_folder_dao import dao_get_template_folder_by_id_and_service_id
|
||||
from app.dao.templates_dao import dao_get_template_by_id
|
||||
from app.dao.users_dao import ( # get_user_and_accounts,; update_user_password,
|
||||
from app.dao.users_dao import (
|
||||
count_user_verify_codes,
|
||||
create_secret_code,
|
||||
create_user_code,
|
||||
@@ -40,7 +40,7 @@ from app.notifications.process_notifications import (
|
||||
send_notification_to_queue,
|
||||
)
|
||||
from app.schema_validation import validate
|
||||
from app.schemas import ( # user_update_password_schema_load_json,
|
||||
from app.schemas import (
|
||||
create_user_schema,
|
||||
email_data_request_schema,
|
||||
partial_email_data_request_schema,
|
||||
@@ -626,57 +626,6 @@ def get_all_users():
|
||||
return jsonify(data=result), 200
|
||||
|
||||
|
||||
# @user_blueprint.route("/reset-password", methods=["POST"])
|
||||
# def send_user_reset_password():
|
||||
# request_json = request.get_json()
|
||||
# email = email_data_request_schema.load(request_json)
|
||||
|
||||
# user_to_send_to = get_user_by_email(email["email"])
|
||||
# template = dao_get_template_by_id(current_app.config["PASSWORD_RESET_TEMPLATE_ID"])
|
||||
# service = Service.query.get(current_app.config["NOTIFY_SERVICE_ID"])
|
||||
# personalisation = {
|
||||
# "user_name": user_to_send_to.name,
|
||||
# "url": _create_reset_password_url(
|
||||
# user_to_send_to.email_address,
|
||||
# base_url=request_json.get("admin_base_url"),
|
||||
# next_redirect=request_json.get("next"),
|
||||
# ),
|
||||
# }
|
||||
# saved_notification = persist_notification(
|
||||
# template_id=template.id,
|
||||
# template_version=template.version,
|
||||
# recipient=email["email"],
|
||||
# service=service,
|
||||
# personalisation=None,
|
||||
# notification_type=template.template_type,
|
||||
# api_key_id=None,
|
||||
# key_type=KeyType.NORMAL,
|
||||
# reply_to_text=service.get_default_reply_to_email_address(),
|
||||
# )
|
||||
# saved_notification.personalisation = personalisation
|
||||
|
||||
# redis_store.set(
|
||||
# f"email-personalisation-{saved_notification.id}",
|
||||
# json.dumps(personalisation),
|
||||
# ex=60 * 60,
|
||||
# )
|
||||
# send_notification_to_queue(saved_notification, queue=QueueNames.NOTIFY)
|
||||
|
||||
# return jsonify({}), 204
|
||||
|
||||
|
||||
# @user_blueprint.route("/<uuid:user_id>/update-password", methods=["POST"])
|
||||
# def update_password(user_id):
|
||||
# user = get_user_by_id(user_id=user_id)
|
||||
# req_json = request.get_json()
|
||||
# password = req_json.get("_password")
|
||||
|
||||
# user_update_password_schema_load_json.load(req_json)
|
||||
|
||||
# update_user_password(user, password)
|
||||
# return jsonify(data=user.serialize()), 200
|
||||
|
||||
|
||||
@user_blueprint.route("/report-all-users", methods=["GET"])
|
||||
def report_all_users():
|
||||
users = dao_report_users()
|
||||
@@ -690,17 +639,6 @@ def get_organizations_and_services_for_user(user_id):
|
||||
return jsonify(data)
|
||||
|
||||
|
||||
# def _create_reset_password_url(email, next_redirect, base_url=None):
|
||||
# data = json.dumps({"email": email, "created_at": str(utc_now())})
|
||||
# static_url_part = "/new-password/"
|
||||
# full_url = url_with_token(
|
||||
# data, static_url_part, current_app.config, base_url=base_url
|
||||
# )
|
||||
# if next_redirect:
|
||||
# full_url += "?{}".format(urlencode({"next": next_redirect}))
|
||||
# return full_url
|
||||
|
||||
|
||||
def _create_verification_url(user, base_url):
|
||||
data = json.dumps({"user_id": str(user.id), "email": user.email_address})
|
||||
url = "/verify-email/"
|
||||
|
||||
19
app/utils.py
19
app/utils.py
@@ -60,11 +60,6 @@ def get_midnight_in_utc(date):
|
||||
return datetime.combine(date, datetime.min.time())
|
||||
|
||||
|
||||
# def get_midnight_for_day_before(date):
|
||||
# day_before = date - timedelta(1)
|
||||
# return get_midnight_in_utc(day_before)
|
||||
|
||||
|
||||
def get_month_from_utc_column(column):
|
||||
"""
|
||||
Where queries need to count notifications by month it needs to be
|
||||
@@ -112,20 +107,6 @@ def get_dt_string_or_none(val):
|
||||
return val.strftime(DATETIME_FORMAT) if val else None
|
||||
|
||||
|
||||
# def get_uuid_string_or_none(val):
|
||||
# return str(val) if val else None
|
||||
|
||||
|
||||
# def format_sequential_number(sequential_number):
|
||||
# return format(sequential_number, "x").zfill(8)
|
||||
|
||||
|
||||
# def get_reference_from_personalisation(personalisation):
|
||||
# if personalisation:
|
||||
# return personalisation.get("reference")
|
||||
# return None
|
||||
|
||||
|
||||
# Function used for debugging.
|
||||
# Do print(hilite(message)) while debugging, then remove your print statements
|
||||
def hilite(message):
|
||||
|
||||
Reference in New Issue
Block a user