mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-25 08:43:55 -04:00
Merge pull request #1460 from GSA/main
12/4/2024 Production Deploy - large batch hotfixes
This commit is contained in:
8
.github/workflows/restage-apps.yml
vendored
8
.github/workflows/restage-apps.yml
vendored
@@ -19,18 +19,18 @@ jobs:
|
|||||||
app: ["api", "admin"]
|
app: ["api", "admin"]
|
||||||
steps:
|
steps:
|
||||||
- name: Restage ${{matrix.app}}
|
- name: Restage ${{matrix.app}}
|
||||||
uses: 18f/cg-deploy-action@main
|
uses: cloud-gov/cg-cli-tools@main
|
||||||
with:
|
with:
|
||||||
cf_username: ${{ secrets.CLOUDGOV_USERNAME }}
|
cf_username: ${{ secrets.CLOUDGOV_USERNAME }}
|
||||||
cf_password: ${{ secrets.CLOUDGOV_PASSWORD }}
|
cf_password: ${{ secrets.CLOUDGOV_PASSWORD }}
|
||||||
cf_org: gsa-tts-benefits-studio
|
cf_org: gsa-tts-benefits-studio
|
||||||
cf_space: notify-${{ inputs.environment }}
|
cf_space: notify-${{ inputs.environment }}
|
||||||
full_command: "cf restage --strategy rolling notify-${{matrix.app}}-${{inputs.environment}}"
|
command: "cf restage --strategy rolling notify-${{matrix.app}}-${{inputs.environment}}"
|
||||||
- name: Restage ${{matrix.app}} egress
|
- name: Restage ${{matrix.app}} egress
|
||||||
uses: 18f/cg-deploy-action@main
|
uses: cloud-gov/cg-cli-tools@main
|
||||||
with:
|
with:
|
||||||
cf_username: ${{ secrets.CLOUDGOV_USERNAME }}
|
cf_username: ${{ secrets.CLOUDGOV_USERNAME }}
|
||||||
cf_password: ${{ secrets.CLOUDGOV_PASSWORD }}
|
cf_password: ${{ secrets.CLOUDGOV_PASSWORD }}
|
||||||
cf_org: gsa-tts-benefits-studio
|
cf_org: gsa-tts-benefits-studio
|
||||||
cf_space: notify-${{ inputs.environment }}-egress
|
cf_space: notify-${{ inputs.environment }}-egress
|
||||||
full_command: "cf restage --strategy rolling egress-proxy-notify-${{matrix.app}}-${{inputs.environment}}"
|
command: "cf restage --strategy rolling egress-proxy-notify-${{matrix.app}}-${{inputs.environment}}"
|
||||||
|
|||||||
@@ -20,7 +20,10 @@ from app.dao.service_sms_sender_dao import dao_get_service_sms_senders_by_id
|
|||||||
from app.dao.templates_dao import dao_get_template_by_id
|
from app.dao.templates_dao import dao_get_template_by_id
|
||||||
from app.enums import JobStatus, KeyType, NotificationType
|
from app.enums import JobStatus, KeyType, NotificationType
|
||||||
from app.errors import TotalRequestsError
|
from app.errors import TotalRequestsError
|
||||||
from app.notifications.process_notifications import persist_notification
|
from app.notifications.process_notifications import (
|
||||||
|
get_notification,
|
||||||
|
persist_notification,
|
||||||
|
)
|
||||||
from app.notifications.validators import check_service_over_total_message_limit
|
from app.notifications.validators import check_service_over_total_message_limit
|
||||||
from app.serialised_models import SerialisedService, SerialisedTemplate
|
from app.serialised_models import SerialisedService, SerialisedTemplate
|
||||||
from app.service.utils import service_allowed_to_send_to
|
from app.service.utils import service_allowed_to_send_to
|
||||||
@@ -271,7 +274,7 @@ def save_email(
|
|||||||
"Email {} failed as restricted service".format(notification_id)
|
"Email {} failed as restricted service".format(notification_id)
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
original_notification = get_notification(notification_id)
|
||||||
try:
|
try:
|
||||||
saved_notification = persist_notification(
|
saved_notification = persist_notification(
|
||||||
template_id=notification["template"],
|
template_id=notification["template"],
|
||||||
@@ -288,10 +291,11 @@ def save_email(
|
|||||||
notification_id=notification_id,
|
notification_id=notification_id,
|
||||||
reply_to_text=reply_to_text,
|
reply_to_text=reply_to_text,
|
||||||
)
|
)
|
||||||
|
# we only want to send once
|
||||||
provider_tasks.deliver_email.apply_async(
|
if original_notification is None:
|
||||||
[str(saved_notification.id)], queue=QueueNames.SEND_EMAIL
|
provider_tasks.deliver_email.apply_async(
|
||||||
)
|
[str(saved_notification.id)], queue=QueueNames.SEND_EMAIL
|
||||||
|
)
|
||||||
|
|
||||||
current_app.logger.debug(
|
current_app.logger.debug(
|
||||||
"Email {} created at {}".format(
|
"Email {} created at {}".format(
|
||||||
@@ -329,6 +333,8 @@ def save_api_email_or_sms(self, encrypted_notification):
|
|||||||
if notification["notification_type"] == NotificationType.EMAIL
|
if notification["notification_type"] == NotificationType.EMAIL
|
||||||
else provider_tasks.deliver_sms
|
else provider_tasks.deliver_sms
|
||||||
)
|
)
|
||||||
|
|
||||||
|
original_notification = get_notification(notification["id"])
|
||||||
try:
|
try:
|
||||||
persist_notification(
|
persist_notification(
|
||||||
notification_id=notification["id"],
|
notification_id=notification["id"],
|
||||||
@@ -347,10 +353,11 @@ def save_api_email_or_sms(self, encrypted_notification):
|
|||||||
document_download_count=notification["document_download_count"],
|
document_download_count=notification["document_download_count"],
|
||||||
)
|
)
|
||||||
# Only get here if save to the db was successful (i.e. first time)
|
# Only get here if save to the db was successful (i.e. first time)
|
||||||
provider_task.apply_async([notification["id"]], queue=q)
|
if original_notification is None:
|
||||||
current_app.logger.debug(
|
provider_task.apply_async([notification["id"]], queue=q)
|
||||||
f"{notification['notification_type']} {notification['id']} has been persisted and sent to delivery queue."
|
current_app.logger.debug(
|
||||||
)
|
f"{notification['id']} has been persisted and sent to delivery queue."
|
||||||
|
)
|
||||||
|
|
||||||
except IntegrityError:
|
except IntegrityError:
|
||||||
current_app.logger.warning(
|
current_app.logger.warning(
|
||||||
|
|||||||
@@ -71,7 +71,12 @@ def dao_create_notification(notification):
|
|||||||
# notify-api-742 remove phone numbers from db
|
# notify-api-742 remove phone numbers from db
|
||||||
notification.to = "1"
|
notification.to = "1"
|
||||||
notification.normalised_to = "1"
|
notification.normalised_to = "1"
|
||||||
db.session.add(notification)
|
|
||||||
|
# notify-api-1454 insert only if it doesn't exist
|
||||||
|
stmt = select(Notification).where(Notification.id == notification.id)
|
||||||
|
result = db.session.execute(stmt).scalar()
|
||||||
|
if result is None:
|
||||||
|
db.session.add(notification)
|
||||||
|
|
||||||
|
|
||||||
def country_records_delivery(phone_prefix):
|
def country_records_delivery(phone_prefix):
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from app.config import QueueNames
|
|||||||
from app.dao.notifications_dao import (
|
from app.dao.notifications_dao import (
|
||||||
dao_create_notification,
|
dao_create_notification,
|
||||||
dao_delete_notifications_by_id,
|
dao_delete_notifications_by_id,
|
||||||
|
get_notification_by_id,
|
||||||
)
|
)
|
||||||
from app.enums import KeyType, NotificationStatus, NotificationType
|
from app.enums import KeyType, NotificationStatus, NotificationType
|
||||||
from app.errors import BadRequestError
|
from app.errors import BadRequestError
|
||||||
@@ -53,6 +54,10 @@ def check_placeholders(template_object):
|
|||||||
raise BadRequestError(fields=[{"template": message}], message=message)
|
raise BadRequestError(fields=[{"template": message}], message=message)
|
||||||
|
|
||||||
|
|
||||||
|
def get_notification(notification_id):
|
||||||
|
return get_notification_by_id(notification_id)
|
||||||
|
|
||||||
|
|
||||||
def persist_notification(
|
def persist_notification(
|
||||||
*,
|
*,
|
||||||
template_id,
|
template_id,
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ module "redis-v70" {
|
|||||||
cf_org_name = local.cf_org_name
|
cf_org_name = local.cf_org_name
|
||||||
cf_space_name = local.cf_space_name
|
cf_space_name = local.cf_space_name
|
||||||
name = "${local.app_name}-redis-v70-${local.env}"
|
name = "${local.app_name}-redis-v70-${local.env}"
|
||||||
redis_plan_name = "redis-3node-large"
|
redis_plan_name = "redis-5node-large"
|
||||||
json_params = jsonencode(
|
json_params = jsonencode(
|
||||||
{
|
{
|
||||||
"engineVersion" : "7.0",
|
"engineVersion" : "7.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user