2018-11-26 12:53:39 +00:00
|
|
|
from datetime import timedelta
|
2017-06-12 15:55:42 +01:00
|
|
|
import os
|
2017-07-11 15:41:44 +01:00
|
|
|
import json
|
2017-06-12 15:55:42 +01:00
|
|
|
|
2017-07-19 13:50:29 +01:00
|
|
|
from celery.schedules import crontab
|
|
|
|
|
from kombu import Exchange, Queue
|
|
|
|
|
|
2016-12-08 12:12:45 +00:00
|
|
|
if os.environ.get('VCAP_SERVICES'):
|
|
|
|
|
# on cloudfoundry, config is a json blob in VCAP_SERVICES - unpack it, and populate
|
|
|
|
|
# standard environment variables from it
|
|
|
|
|
from app.cloudfoundry_config import extract_cloudfoundry_config
|
2017-04-24 14:15:08 +01:00
|
|
|
|
2016-12-08 12:12:45 +00:00
|
|
|
extract_cloudfoundry_config()
|
|
|
|
|
|
2016-09-07 09:35:31 +01:00
|
|
|
|
2017-07-19 13:50:29 +01:00
|
|
|
class QueueNames(object):
|
|
|
|
|
PERIODIC = 'periodic-tasks'
|
|
|
|
|
PRIORITY = 'priority-tasks'
|
|
|
|
|
DATABASE = 'database-tasks'
|
2017-07-20 15:48:21 +01:00
|
|
|
SEND_SMS = 'send-sms-tasks'
|
|
|
|
|
SEND_EMAIL = 'send-email-tasks'
|
2017-07-19 13:50:29 +01:00
|
|
|
RESEARCH_MODE = 'research-mode-tasks'
|
|
|
|
|
STATISTICS = 'statistics-tasks'
|
|
|
|
|
JOBS = 'job-tasks'
|
|
|
|
|
RETRY = 'retry-tasks'
|
|
|
|
|
NOTIFY = 'notify-internal-tasks'
|
|
|
|
|
PROCESS_FTP = 'process-ftp-tasks'
|
2017-12-14 16:00:51 +00:00
|
|
|
CREATE_LETTERS_PDF = 'create-letters-pdf-tasks'
|
2017-12-13 10:57:08 +00:00
|
|
|
CALLBACKS = 'service-callbacks'
|
2017-12-18 16:12:17 +00:00
|
|
|
LETTERS = 'letter-tasks'
|
2018-03-19 13:13:38 +00:00
|
|
|
ANTIVIRUS = 'antivirus-tasks'
|
2017-07-19 13:50:29 +01:00
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def all_queues():
|
|
|
|
|
return [
|
|
|
|
|
QueueNames.PRIORITY,
|
|
|
|
|
QueueNames.PERIODIC,
|
|
|
|
|
QueueNames.DATABASE,
|
2017-07-20 15:48:21 +01:00
|
|
|
QueueNames.SEND_SMS,
|
|
|
|
|
QueueNames.SEND_EMAIL,
|
2017-07-19 13:50:29 +01:00
|
|
|
QueueNames.RESEARCH_MODE,
|
|
|
|
|
QueueNames.STATISTICS,
|
|
|
|
|
QueueNames.JOBS,
|
|
|
|
|
QueueNames.RETRY,
|
|
|
|
|
QueueNames.NOTIFY,
|
2017-12-08 17:27:05 +00:00
|
|
|
QueueNames.CREATE_LETTERS_PDF,
|
2017-12-13 10:57:08 +00:00
|
|
|
QueueNames.CALLBACKS,
|
2017-12-18 16:12:17 +00:00
|
|
|
QueueNames.LETTERS,
|
2017-07-19 13:50:29 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
2017-08-22 15:49:56 +01:00
|
|
|
class TaskNames(object):
|
2017-10-13 16:46:17 +01:00
|
|
|
PROCESS_INCOMPLETE_JOBS = 'process-incomplete-jobs'
|
2017-12-19 14:18:05 +00:00
|
|
|
ZIP_AND_SEND_LETTER_PDFS = 'zip-and-send-letter-pdfs'
|
2018-03-19 13:13:38 +00:00
|
|
|
SCAN_FILE = 'scan-file'
|
2017-08-22 15:49:56 +01:00
|
|
|
|
|
|
|
|
|
2016-12-08 12:12:45 +00:00
|
|
|
class Config(object):
|
2016-09-07 09:35:31 +01:00
|
|
|
# URL of admin app
|
2018-02-21 18:12:03 +00:00
|
|
|
ADMIN_BASE_URL = os.getenv('ADMIN_BASE_URL', 'http://localhost:6012')
|
2016-09-07 09:35:31 +01:00
|
|
|
|
2016-12-08 12:12:45 +00:00
|
|
|
# URL of api app (on AWS this is the internal api endpoint)
|
|
|
|
|
API_HOST_NAME = os.getenv('API_HOST_NAME')
|
|
|
|
|
|
2016-09-07 09:35:31 +01:00
|
|
|
# admin app api key
|
2018-02-21 18:12:03 +00:00
|
|
|
ADMIN_CLIENT_SECRET = os.getenv('ADMIN_CLIENT_SECRET')
|
2016-09-07 09:35:31 +01:00
|
|
|
|
|
|
|
|
# encyption secret/salt
|
2018-02-21 18:12:03 +00:00
|
|
|
SECRET_KEY = os.getenv('SECRET_KEY')
|
|
|
|
|
DANGEROUS_SALT = os.getenv('DANGEROUS_SALT')
|
2016-09-07 09:35:31 +01:00
|
|
|
|
|
|
|
|
# DB conection string
|
2018-02-21 18:12:03 +00:00
|
|
|
SQLALCHEMY_DATABASE_URI = os.getenv('SQLALCHEMY_DATABASE_URI')
|
2016-09-07 09:35:31 +01:00
|
|
|
|
|
|
|
|
# MMG API Key
|
2018-02-21 18:12:03 +00:00
|
|
|
MMG_API_KEY = os.getenv('MMG_API_KEY')
|
2016-09-07 09:35:31 +01:00
|
|
|
|
|
|
|
|
# Firetext API Key
|
|
|
|
|
FIRETEXT_API_KEY = os.getenv("FIRETEXT_API_KEY")
|
|
|
|
|
|
|
|
|
|
# Firetext simluation key
|
|
|
|
|
LOADTESTING_API_KEY = os.getenv("LOADTESTING_API_KEY")
|
|
|
|
|
|
|
|
|
|
# Hosted graphite statsd prefix
|
|
|
|
|
STATSD_PREFIX = os.getenv('STATSD_PREFIX')
|
|
|
|
|
|
|
|
|
|
# Prefix to identify queues in SQS
|
|
|
|
|
NOTIFICATION_QUEUE_PREFIX = os.getenv('NOTIFICATION_QUEUE_PREFIX')
|
|
|
|
|
|
2016-11-28 09:39:56 +00:00
|
|
|
# URL of redis instance
|
|
|
|
|
REDIS_URL = os.getenv('REDIS_URL')
|
2016-12-08 12:12:45 +00:00
|
|
|
REDIS_ENABLED = os.getenv('REDIS_ENABLED') == '1'
|
add new redis template usage per day key
We've run into issues with redis expiring keys while we try and write
to them - short lived redis TTLs aren't really sustainable for keys
where we mutate the state. Template usage is a hash contained in redis
where we increment a count keyed by template_id each time a message is
sent for that template. But if the key expires, hincrby (redis command
for incrementing a value in a hash) will re-create an empty hash.
This is no good, as we need the hash to be populated with the last
seven days worth of data, which we then increment further. We can't
tell whether the hincrby created the key, so a different approach
entirely was needed:
* New redis key: <service_id>-template-usage-<YYYY-MM-DD>. Note: This
YYYY-MM-DD is BTC time so it lines up nicely with ft_billing table
* Incremented to from process_notification - if it doesn't exist yet,
it'll be created then.
* Expiry set to 8 days every time it's incremented to.
Then, at read time, we'll just read the last eight days of keys from
Redis, and sum them up. This works because we're only ever incrementing
from that one place - never setting wholesale, never recreating the
data from scratch. So we know that if the data is in redis, then it is
good and accurate data.
One thing we *don't* know and *cannot* reason about is what no key in
redis means. It could be either of:
* This is the first message that the service has sent today.
* The key was deleted from redis for some reason.
Since we set the TTL to so long, we'll never be writing to a key that
previously expired. But if there is a redis (or operator) error and the
key is deleted, then we'll have bad data - after any data loss we'll
have to rebuild the data.
2018-03-29 13:55:22 +01:00
|
|
|
EXPIRE_CACHE_TEN_MINUTES = 600
|
|
|
|
|
EXPIRE_CACHE_EIGHT_DAYS = 8 * 24 * 60 * 60
|
2016-12-08 12:12:45 +00:00
|
|
|
|
2017-01-27 12:21:08 +00:00
|
|
|
# Performance platform
|
2017-03-31 15:54:29 +01:00
|
|
|
PERFORMANCE_PLATFORM_ENABLED = False
|
2017-08-23 15:04:37 +01:00
|
|
|
PERFORMANCE_PLATFORM_URL = 'https://www.performance.service.gov.uk/data/govuk-notify/'
|
2017-01-27 12:21:08 +00:00
|
|
|
|
2018-04-25 14:22:23 +01:00
|
|
|
# Zendesk
|
|
|
|
|
ZENDESK_API_KEY = os.environ.get('ZENDESK_API_KEY')
|
2018-01-17 14:36:02 +00:00
|
|
|
|
2016-12-08 12:12:45 +00:00
|
|
|
# Logging
|
|
|
|
|
DEBUG = False
|
2017-08-09 16:07:35 +01:00
|
|
|
NOTIFY_LOG_PATH = os.getenv('NOTIFY_LOG_PATH')
|
2016-11-28 09:39:56 +00:00
|
|
|
|
2019-01-16 14:11:03 +00:00
|
|
|
# Cronitor
|
|
|
|
|
CRONITOR_ENABLED = False
|
|
|
|
|
CRONITOR_KEYS = json.loads(os.environ.get('CRONITOR_KEYS', '{}'))
|
|
|
|
|
|
2016-09-07 09:35:31 +01:00
|
|
|
###########################
|
|
|
|
|
# Default config values ###
|
|
|
|
|
###########################
|
|
|
|
|
|
|
|
|
|
NOTIFY_ENVIRONMENT = 'development'
|
|
|
|
|
ADMIN_CLIENT_USER_NAME = 'notify-admin'
|
|
|
|
|
AWS_REGION = 'eu-west-1'
|
|
|
|
|
INVITATION_EXPIRATION_DAYS = 2
|
2016-01-07 13:28:56 +00:00
|
|
|
NOTIFY_APP_NAME = 'api'
|
2018-12-04 11:48:28 +00:00
|
|
|
SQLALCHEMY_RECORD_QUERIES = False
|
|
|
|
|
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
2018-02-22 10:27:02 +00:00
|
|
|
SQLALCHEMY_POOL_SIZE = int(os.environ.get('SQLALCHEMY_POOL_SIZE', 5))
|
2018-01-05 05:53:40 +00:00
|
|
|
SQLALCHEMY_POOL_TIMEOUT = 30
|
|
|
|
|
SQLALCHEMY_POOL_RECYCLE = 300
|
2019-01-09 12:22:51 +00:00
|
|
|
SQLALCHEMY_STATEMENT_TIMEOUT = 1200
|
2016-03-01 13:30:10 +00:00
|
|
|
PAGE_SIZE = 50
|
2017-01-20 12:26:55 +00:00
|
|
|
API_PAGE_SIZE = 250
|
2016-10-11 14:30:40 +01:00
|
|
|
TEST_MESSAGE_FILENAME = 'Test message'
|
2017-06-01 13:56:47 +01:00
|
|
|
ONE_OFF_MESSAGE_FILENAME = 'Report'
|
2017-02-15 16:18:05 +00:00
|
|
|
MAX_VERIFY_CODE_COUNT = 10
|
2016-01-27 17:42:05 +00:00
|
|
|
|
2017-12-19 14:18:05 +00:00
|
|
|
MAX_LETTER_PDF_ZIP_FILESIZE = 500 * 1024 * 1024 # 500mb
|
2018-01-02 17:18:01 +00:00
|
|
|
MAX_LETTER_PDF_COUNT_PER_ZIP = 5000
|
2017-12-19 14:18:05 +00:00
|
|
|
|
2017-11-16 12:02:09 +00:00
|
|
|
CHECK_PROXY_HEADER = False
|
|
|
|
|
|
2016-06-02 11:12:01 +01:00
|
|
|
NOTIFY_SERVICE_ID = 'd6aa2c68-a2d9-4437-ab19-3ae8eb202553'
|
2017-03-02 18:03:53 +00:00
|
|
|
NOTIFY_USER_ID = '6af522d0-2915-4e52-83a3-3690455a5fe6'
|
2016-06-02 11:12:01 +01:00
|
|
|
INVITATION_EMAIL_TEMPLATE_ID = '4f46df42-f795-4cc4-83bb-65ca312f49cc'
|
|
|
|
|
SMS_CODE_TEMPLATE_ID = '36fb0730-6259-4da1-8a80-c8de22ad4246'
|
2017-11-03 14:38:30 +00:00
|
|
|
EMAIL_2FA_TEMPLATE_ID = '299726d2-dba6-42b8-8209-30e1d66ea164'
|
|
|
|
|
NEW_USER_EMAIL_VERIFICATION_TEMPLATE_ID = 'ece42649-22a8-4d06-b87f-d52d5d3f0a27'
|
2016-06-02 11:12:01 +01:00
|
|
|
PASSWORD_RESET_TEMPLATE_ID = '474e9242-823b-4f99-813d-ed392e7f1201'
|
2016-07-07 17:23:07 +01:00
|
|
|
ALREADY_REGISTERED_EMAIL_TEMPLATE_ID = '0880fbb1-a0c6-46f0-9a8e-36c986381ceb'
|
2016-10-12 13:06:39 +01:00
|
|
|
CHANGE_EMAIL_CONFIRMATION_TEMPLATE_ID = 'eb4d9930-87ab-4aef-9bce-786762687884'
|
2017-05-12 14:06:29 +01:00
|
|
|
SERVICE_NOW_LIVE_TEMPLATE_ID = '618185c6-3636-49cd-b7d2-6f6f5eb3bdde'
|
2018-02-16 14:42:03 +00:00
|
|
|
ORGANISATION_INVITATION_EMAIL_TEMPLATE_ID = '203566f0-d835-47c5-aa06-932439c86573'
|
2016-06-02 11:12:01 +01:00
|
|
|
|
2017-07-19 13:50:29 +01:00
|
|
|
BROKER_URL = 'sqs://'
|
|
|
|
|
BROKER_TRANSPORT_OPTIONS = {
|
|
|
|
|
'region': AWS_REGION,
|
2018-10-09 13:27:49 +01:00
|
|
|
'polling_interval': 1, # 1 second
|
2017-07-19 13:50:29 +01:00
|
|
|
'visibility_timeout': 310,
|
2018-10-09 13:27:49 +01:00
|
|
|
'queue_name_prefix': NOTIFICATION_QUEUE_PREFIX
|
2017-07-19 13:50:29 +01:00
|
|
|
}
|
2017-09-25 18:07:57 +01:00
|
|
|
CELERY_ENABLE_UTC = True
|
2017-07-19 13:50:29 +01:00
|
|
|
CELERY_TIMEZONE = 'Europe/London'
|
|
|
|
|
CELERY_ACCEPT_CONTENT = ['json']
|
|
|
|
|
CELERY_TASK_SERIALIZER = 'json'
|
2019-01-16 14:11:03 +00:00
|
|
|
CELERY_IMPORTS = (
|
|
|
|
|
'app.celery.tasks',
|
|
|
|
|
'app.celery.scheduled_tasks',
|
|
|
|
|
'app.celery.reporting_tasks',
|
|
|
|
|
'app.celery.nightly_tasks',
|
|
|
|
|
)
|
2017-07-19 13:50:29 +01:00
|
|
|
CELERYBEAT_SCHEDULE = {
|
2019-01-14 17:22:41 +00:00
|
|
|
# app/celery/scheduled_tasks.py
|
2017-07-19 13:50:29 +01:00
|
|
|
'run-scheduled-jobs': {
|
|
|
|
|
'task': 'run-scheduled-jobs',
|
|
|
|
|
'schedule': crontab(minute=1),
|
|
|
|
|
'options': {'queue': QueueNames.PERIODIC}
|
|
|
|
|
},
|
|
|
|
|
'delete-verify-codes': {
|
|
|
|
|
'task': 'delete-verify-codes',
|
|
|
|
|
'schedule': timedelta(minutes=63),
|
|
|
|
|
'options': {'queue': QueueNames.PERIODIC}
|
|
|
|
|
},
|
|
|
|
|
'delete-invitations': {
|
|
|
|
|
'task': 'delete-invitations',
|
|
|
|
|
'schedule': timedelta(minutes=66),
|
|
|
|
|
'options': {'queue': QueueNames.PERIODIC}
|
|
|
|
|
},
|
2018-11-07 16:39:23 +00:00
|
|
|
'switch-current-sms-provider-on-slow-delivery': {
|
|
|
|
|
'task': 'switch-current-sms-provider-on-slow-delivery',
|
|
|
|
|
'schedule': crontab(), # Every minute
|
|
|
|
|
'options': {'queue': QueueNames.PERIODIC}
|
|
|
|
|
},
|
|
|
|
|
'check-job-status': {
|
|
|
|
|
'task': 'check-job-status',
|
|
|
|
|
'schedule': crontab(),
|
|
|
|
|
'options': {'queue': QueueNames.PERIODIC}
|
|
|
|
|
},
|
|
|
|
|
'replay-created-notifications': {
|
|
|
|
|
'task': 'replay-created-notifications',
|
|
|
|
|
'schedule': crontab(minute='0, 15, 30, 45'),
|
|
|
|
|
'options': {'queue': QueueNames.PERIODIC}
|
|
|
|
|
},
|
2019-01-14 17:22:41 +00:00
|
|
|
# app/celery/nightly_tasks.py
|
2018-11-07 16:39:23 +00:00
|
|
|
'timeout-sending-notifications': {
|
|
|
|
|
'task': 'timeout-sending-notifications',
|
|
|
|
|
'schedule': crontab(hour=0, minute=5),
|
|
|
|
|
'options': {'queue': QueueNames.PERIODIC}
|
|
|
|
|
},
|
|
|
|
|
'create-nightly-billing': {
|
|
|
|
|
'task': 'create-nightly-billing',
|
|
|
|
|
'schedule': crontab(hour=0, minute=15),
|
|
|
|
|
'options': {'queue': QueueNames.PERIODIC}
|
|
|
|
|
},
|
|
|
|
|
'create-nightly-notification-status': {
|
|
|
|
|
'task': 'create-nightly-notification-status',
|
2018-11-07 16:49:48 +00:00
|
|
|
'schedule': crontab(hour=0, minute=30), # after 'timeout-sending-notifications'
|
2018-11-07 16:39:23 +00:00
|
|
|
'options': {'queue': QueueNames.PERIODIC}
|
|
|
|
|
},
|
2017-07-19 13:50:29 +01:00
|
|
|
'delete-sms-notifications': {
|
|
|
|
|
'task': 'delete-sms-notifications',
|
2018-11-07 16:49:48 +00:00
|
|
|
'schedule': crontab(hour=0, minute=45), # after 'create-nightly-notification-status'
|
2017-07-19 13:50:29 +01:00
|
|
|
'options': {'queue': QueueNames.PERIODIC}
|
|
|
|
|
},
|
|
|
|
|
'delete-email-notifications': {
|
|
|
|
|
'task': 'delete-email-notifications',
|
2018-11-07 16:49:48 +00:00
|
|
|
'schedule': crontab(hour=1, minute=0), # after 'create-nightly-notification-status'
|
2017-07-19 13:50:29 +01:00
|
|
|
'options': {'queue': QueueNames.PERIODIC}
|
|
|
|
|
},
|
2018-03-01 15:39:51 +00:00
|
|
|
'delete-letter-notifications': {
|
|
|
|
|
'task': 'delete-letter-notifications',
|
2018-11-07 16:49:48 +00:00
|
|
|
'schedule': crontab(hour=1, minute=20), # after 'create-nightly-notification-status'
|
2018-03-01 15:39:51 +00:00
|
|
|
'options': {'queue': QueueNames.PERIODIC}
|
|
|
|
|
},
|
2017-07-19 13:50:29 +01:00
|
|
|
'delete-inbound-sms': {
|
|
|
|
|
'task': 'delete-inbound-sms',
|
2018-11-07 16:39:23 +00:00
|
|
|
'schedule': crontab(hour=1, minute=40),
|
2017-07-19 13:50:29 +01:00
|
|
|
'options': {'queue': QueueNames.PERIODIC}
|
|
|
|
|
},
|
2018-11-07 16:39:23 +00:00
|
|
|
|
2017-07-19 13:50:29 +01:00
|
|
|
'send-daily-performance-platform-stats': {
|
|
|
|
|
'task': 'send-daily-performance-platform-stats',
|
2017-09-25 18:28:10 +01:00
|
|
|
'schedule': crontab(hour=2, minute=0),
|
2017-07-19 13:50:29 +01:00
|
|
|
'options': {'queue': QueueNames.PERIODIC}
|
|
|
|
|
},
|
2018-11-21 14:21:37 +00:00
|
|
|
'remove_transformed_dvla_files': {
|
|
|
|
|
'task': 'remove_transformed_dvla_files',
|
|
|
|
|
'schedule': crontab(hour=3, minute=40),
|
|
|
|
|
'options': {'queue': QueueNames.PERIODIC}
|
|
|
|
|
},
|
2017-07-19 13:50:29 +01:00
|
|
|
'remove_sms_email_jobs': {
|
2019-01-16 14:11:03 +00:00
|
|
|
'task': 'remove_sms_email_jobs',
|
2017-09-25 18:28:10 +01:00
|
|
|
'schedule': crontab(hour=4, minute=0),
|
2017-07-19 13:50:29 +01:00
|
|
|
'options': {'queue': QueueNames.PERIODIC},
|
|
|
|
|
},
|
|
|
|
|
'remove_letter_jobs': {
|
2019-01-16 14:11:03 +00:00
|
|
|
'task': 'remove_letter_jobs',
|
2018-11-21 14:21:37 +00:00
|
|
|
'schedule': crontab(hour=4, minute=20), # this has to run AFTER remove_transformed_dvla_files
|
|
|
|
|
# since we mark jobs as archived
|
2017-07-19 13:50:29 +01:00
|
|
|
'options': {'queue': QueueNames.PERIODIC},
|
|
|
|
|
},
|
2018-01-17 14:36:02 +00:00
|
|
|
'raise-alert-if-letter-notifications-still-sending': {
|
|
|
|
|
'task': 'raise-alert-if-letter-notifications-still-sending',
|
|
|
|
|
'schedule': crontab(hour=16, minute=30),
|
|
|
|
|
'options': {'queue': QueueNames.PERIODIC}
|
|
|
|
|
},
|
2018-09-12 17:16:34 +01:00
|
|
|
# The collate-letter-pdf does assume it is called in an hour that BST does not make a
|
|
|
|
|
# difference to the truncate date which translates to the filename to process
|
|
|
|
|
'collate-letter-pdfs-for-day': {
|
|
|
|
|
'task': 'collate-letter-pdfs-for-day',
|
2017-12-18 16:12:17 +00:00
|
|
|
'schedule': crontab(hour=17, minute=50),
|
|
|
|
|
'options': {'queue': QueueNames.PERIODIC}
|
|
|
|
|
},
|
2018-01-11 16:37:39 +00:00
|
|
|
'raise-alert-if-no-letter-ack-file': {
|
|
|
|
|
'task': 'raise-alert-if-no-letter-ack-file',
|
2018-01-12 15:10:42 +00:00
|
|
|
'schedule': crontab(hour=23, minute=00),
|
2018-01-11 16:37:39 +00:00
|
|
|
'options': {'queue': QueueNames.PERIODIC}
|
|
|
|
|
},
|
2017-07-19 13:50:29 +01:00
|
|
|
}
|
2018-10-09 13:27:49 +01:00
|
|
|
CELERY_QUEUES = []
|
2017-07-19 13:50:29 +01:00
|
|
|
|
2016-04-29 12:59:36 +01:00
|
|
|
NOTIFICATIONS_ALERT = 5 # five mins
|
2016-09-07 09:35:31 +01:00
|
|
|
FROM_NUMBER = 'development'
|
2016-02-09 13:31:45 +00:00
|
|
|
|
2016-05-13 17:15:39 +01:00
|
|
|
STATSD_ENABLED = False
|
2016-08-05 10:44:43 +01:00
|
|
|
STATSD_HOST = "statsd.hostedgraphite.com"
|
|
|
|
|
STATSD_PORT = 8125
|
2016-05-13 17:15:39 +01:00
|
|
|
|
2016-12-15 17:30:05 +00:00
|
|
|
SENDING_NOTIFICATIONS_TIMEOUT_PERIOD = 259200 # 3 days
|
2016-06-08 15:25:57 +01:00
|
|
|
|
2017-02-03 13:34:09 +00:00
|
|
|
SIMULATED_EMAIL_ADDRESSES = (
|
|
|
|
|
'simulate-delivered@notifications.service.gov.uk',
|
|
|
|
|
'simulate-delivered-2@notifications.service.gov.uk',
|
|
|
|
|
'simulate-delivered-3@notifications.service.gov.uk',
|
|
|
|
|
)
|
2016-09-13 17:00:28 +01:00
|
|
|
|
|
|
|
|
SIMULATED_SMS_NUMBERS = ('+447700900000', '+447700900111', '+447700900222')
|
|
|
|
|
|
2017-09-13 15:25:05 +01:00
|
|
|
DVLA_BUCKETS = {
|
|
|
|
|
'job': '{}-dvla-file-per-job'.format(os.getenv('NOTIFY_ENVIRONMENT')),
|
2017-09-25 18:28:10 +01:00
|
|
|
'notification': '{}-dvla-letter-api-files'.format(os.getenv('NOTIFY_ENVIRONMENT'))
|
2017-09-13 15:25:05 +01:00
|
|
|
}
|
2017-03-15 15:26:58 +00:00
|
|
|
|
2017-06-06 14:49:05 +01:00
|
|
|
FREE_SMS_TIER_FRAGMENT_COUNT = 250000
|
|
|
|
|
|
2017-07-11 15:41:44 +01:00
|
|
|
SMS_INBOUND_WHITELIST = json.loads(os.environ.get('SMS_INBOUND_WHITELIST', '[]'))
|
2017-11-20 12:25:01 +00:00
|
|
|
FIRETEXT_INBOUND_SMS_AUTH = json.loads(os.environ.get('FIRETEXT_INBOUND_SMS_AUTH', '[]'))
|
2017-12-14 13:35:13 +00:00
|
|
|
MMG_INBOUND_SMS_AUTH = json.loads(os.environ.get('MMG_INBOUND_SMS_AUTH', '[]'))
|
2017-12-15 12:19:58 +00:00
|
|
|
MMG_INBOUND_SMS_USERNAME = json.loads(os.environ.get('MMG_INBOUND_SMS_USERNAME', '[]'))
|
2017-11-20 12:25:01 +00:00
|
|
|
|
2017-11-06 12:27:48 +00:00
|
|
|
ROUTE_SECRET_KEY_1 = os.environ.get('ROUTE_SECRET_KEY_1', '')
|
|
|
|
|
ROUTE_SECRET_KEY_2 = os.environ.get('ROUTE_SECRET_KEY_2', '')
|
2017-07-03 14:14:17 +01:00
|
|
|
|
2017-08-23 18:11:44 +01:00
|
|
|
# Format is as follows:
|
|
|
|
|
# {"dataset_1": "token_1", ...}
|
|
|
|
|
PERFORMANCE_PLATFORM_ENDPOINTS = json.loads(os.environ.get('PERFORMANCE_PLATFORM_ENDPOINTS', '{}'))
|
|
|
|
|
|
2017-12-06 13:51:52 +00:00
|
|
|
TEMPLATE_PREVIEW_API_HOST = os.environ.get('TEMPLATE_PREVIEW_API_HOST', 'http://localhost:6013')
|
|
|
|
|
TEMPLATE_PREVIEW_API_KEY = os.environ.get('TEMPLATE_PREVIEW_API_KEY', 'my-secret-key')
|
|
|
|
|
|
2018-04-04 17:31:02 +01:00
|
|
|
DOCUMENT_DOWNLOAD_API_HOST = os.environ.get('DOCUMENT_DOWNLOAD_API_HOST', 'http://localhost:7000')
|
|
|
|
|
DOCUMENT_DOWNLOAD_API_KEY = os.environ.get('DOCUMENT_DOWNLOAD_API_KEY', 'auth-token')
|
|
|
|
|
|
2018-02-21 18:12:03 +00:00
|
|
|
MMG_URL = "https://api.mmg.co.uk/json/api.php"
|
|
|
|
|
AWS_REGION = 'eu-west-1'
|
|
|
|
|
|
2017-07-03 14:14:17 +01:00
|
|
|
|
2016-09-07 09:35:31 +01:00
|
|
|
######################
|
|
|
|
|
# Config overrides ###
|
|
|
|
|
######################
|
|
|
|
|
|
2015-12-10 10:56:59 +00:00
|
|
|
class Development(Config):
|
2018-02-21 18:12:03 +00:00
|
|
|
DEBUG = True
|
2017-11-15 16:00:13 +00:00
|
|
|
SQLALCHEMY_ECHO = False
|
2018-02-21 18:12:03 +00:00
|
|
|
|
2016-08-08 14:05:35 +01:00
|
|
|
CSV_UPLOAD_BUCKET_NAME = 'development-notifications-csv-upload'
|
2018-03-14 17:39:17 +00:00
|
|
|
TEST_LETTERS_BUCKET_NAME = 'development-test-letters'
|
2017-06-12 15:55:42 +01:00
|
|
|
DVLA_RESPONSE_BUCKET_NAME = 'notify.tools-ftp'
|
2018-03-13 14:06:03 +00:00
|
|
|
LETTERS_PDF_BUCKET_NAME = 'development-letters-pdf'
|
|
|
|
|
LETTERS_SCAN_BUCKET_NAME = 'development-letters-scan'
|
2018-09-03 13:24:51 +01:00
|
|
|
INVALID_PDF_BUCKET_NAME = 'development-letters-invalid-pdf'
|
2018-02-21 18:12:03 +00:00
|
|
|
|
|
|
|
|
ADMIN_CLIENT_SECRET = 'dev-notify-secret-key'
|
|
|
|
|
SECRET_KEY = 'dev-notify-secret-key'
|
|
|
|
|
DANGEROUS_SALT = 'dev-notify-salt'
|
|
|
|
|
|
2018-09-20 14:34:46 +01:00
|
|
|
MMG_INBOUND_SMS_AUTH = ['testkey']
|
|
|
|
|
MMG_INBOUND_SMS_USERNAME = ['username']
|
|
|
|
|
|
2016-08-08 10:20:33 +01:00
|
|
|
NOTIFY_ENVIRONMENT = 'development'
|
2018-02-21 18:12:03 +00:00
|
|
|
NOTIFY_LOG_PATH = 'application.log'
|
2017-07-19 13:50:29 +01:00
|
|
|
NOTIFICATION_QUEUE_PREFIX = 'development'
|
2018-02-21 18:12:03 +00:00
|
|
|
NOTIFY_EMAIL_DOMAIN = "notify.tools"
|
|
|
|
|
|
|
|
|
|
SQLALCHEMY_DATABASE_URI = 'postgresql://localhost/notification_api'
|
|
|
|
|
REDIS_URL = 'redis://localhost:6379/0'
|
|
|
|
|
|
|
|
|
|
STATSD_ENABLED = False
|
|
|
|
|
STATSD_HOST = "localhost"
|
|
|
|
|
STATSD_PORT = 1000
|
|
|
|
|
STATSD_PREFIX = "stats-prefix"
|
2017-05-25 10:50:55 +01:00
|
|
|
|
2018-10-09 13:27:49 +01:00
|
|
|
for queue in QueueNames.all_queues():
|
|
|
|
|
Config.CELERY_QUEUES.append(
|
|
|
|
|
Queue(queue, Exchange('default'), routing_key=queue)
|
|
|
|
|
)
|
|
|
|
|
|
2016-12-08 12:12:45 +00:00
|
|
|
API_HOST_NAME = "http://localhost:6011"
|
2017-04-25 09:54:09 +01:00
|
|
|
API_RATE_LIMIT_ENABLED = True
|
2016-08-31 11:40:31 +01:00
|
|
|
|
|
|
|
|
|
2018-02-21 18:42:24 +00:00
|
|
|
class Test(Development):
|
2016-09-07 09:35:31 +01:00
|
|
|
NOTIFY_EMAIL_DOMAIN = 'test.notify.com'
|
|
|
|
|
FROM_NUMBER = 'testing'
|
2016-08-31 11:40:31 +01:00
|
|
|
NOTIFY_ENVIRONMENT = 'test'
|
2017-06-19 13:49:20 +01:00
|
|
|
TESTING = True
|
2018-02-21 18:42:24 +00:00
|
|
|
|
2016-08-31 11:40:31 +01:00
|
|
|
CSV_UPLOAD_BUCKET_NAME = 'test-notifications-csv-upload'
|
2018-03-14 17:39:17 +00:00
|
|
|
TEST_LETTERS_BUCKET_NAME = 'test-test-letters'
|
2017-06-12 15:55:42 +01:00
|
|
|
DVLA_RESPONSE_BUCKET_NAME = 'test.notify.com-ftp'
|
2018-03-13 14:06:03 +00:00
|
|
|
LETTERS_PDF_BUCKET_NAME = 'test-letters-pdf'
|
|
|
|
|
LETTERS_SCAN_BUCKET_NAME = 'test-letters-scan'
|
2018-09-03 13:24:51 +01:00
|
|
|
INVALID_PDF_BUCKET_NAME = 'test-letters-invalid-pdf'
|
2018-02-21 18:42:24 +00:00
|
|
|
|
2018-02-21 18:12:03 +00:00
|
|
|
# this is overriden in jenkins and on cloudfoundry
|
|
|
|
|
SQLALCHEMY_DATABASE_URI = os.getenv('SQLALCHEMY_DATABASE_URI', 'postgresql://localhost/test_notification_api')
|
2017-05-25 10:50:55 +01:00
|
|
|
|
2017-06-09 16:20:02 +01:00
|
|
|
BROKER_URL = 'you-forgot-to-mock-celery-in-your-tests://'
|
|
|
|
|
|
2018-10-09 13:27:49 +01:00
|
|
|
for queue in QueueNames.all_queues():
|
|
|
|
|
Config.CELERY_QUEUES.append(
|
|
|
|
|
Queue(queue, Exchange('default'), routing_key=queue)
|
|
|
|
|
)
|
|
|
|
|
|
2017-04-25 09:54:09 +01:00
|
|
|
API_RATE_LIMIT_ENABLED = True
|
2016-12-08 12:12:45 +00:00
|
|
|
API_HOST_NAME = "http://localhost:6011"
|
2016-01-18 11:03:38 +00:00
|
|
|
|
2017-09-26 10:59:09 +01:00
|
|
|
SMS_INBOUND_WHITELIST = ['203.0.113.195']
|
2017-11-20 12:25:01 +00:00
|
|
|
FIRETEXT_INBOUND_SMS_AUTH = ['testkey']
|
2017-12-12 14:53:38 +00:00
|
|
|
TEMPLATE_PREVIEW_API_HOST = 'http://localhost:9999'
|
2017-09-26 10:59:09 +01:00
|
|
|
|
2016-05-13 17:20:29 +01:00
|
|
|
|
2016-04-07 13:44:04 +01:00
|
|
|
class Preview(Config):
|
2016-09-07 09:35:31 +01:00
|
|
|
NOTIFY_EMAIL_DOMAIN = 'notify.works'
|
2016-08-08 10:20:33 +01:00
|
|
|
NOTIFY_ENVIRONMENT = 'preview'
|
2016-08-03 11:50:24 +01:00
|
|
|
CSV_UPLOAD_BUCKET_NAME = 'preview-notifications-csv-upload'
|
2018-03-14 17:39:17 +00:00
|
|
|
TEST_LETTERS_BUCKET_NAME = 'preview-test-letters'
|
2017-06-12 15:55:42 +01:00
|
|
|
DVLA_RESPONSE_BUCKET_NAME = 'notify.works-ftp'
|
2018-03-13 14:06:03 +00:00
|
|
|
LETTERS_PDF_BUCKET_NAME = 'preview-letters-pdf'
|
|
|
|
|
LETTERS_SCAN_BUCKET_NAME = 'preview-letters-scan'
|
2018-09-03 13:24:51 +01:00
|
|
|
INVALID_PDF_BUCKET_NAME = 'preview-letters-invalid-pdf'
|
2016-09-08 10:44:14 +01:00
|
|
|
FROM_NUMBER = 'preview'
|
2017-04-25 09:54:09 +01:00
|
|
|
API_RATE_LIMIT_ENABLED = True
|
2018-08-23 10:26:06 +01:00
|
|
|
CHECK_PROXY_HEADER = False
|
2016-04-07 13:44:04 +01:00
|
|
|
|
|
|
|
|
|
2016-07-04 16:54:03 +01:00
|
|
|
class Staging(Config):
|
2016-09-07 09:35:31 +01:00
|
|
|
NOTIFY_EMAIL_DOMAIN = 'staging-notify.works'
|
2016-08-08 10:20:33 +01:00
|
|
|
NOTIFY_ENVIRONMENT = 'staging'
|
2018-11-21 14:07:04 +00:00
|
|
|
CSV_UPLOAD_BUCKET_NAME = 'staging-notifications-csv-upload'
|
2018-03-14 17:39:17 +00:00
|
|
|
TEST_LETTERS_BUCKET_NAME = 'staging-test-letters'
|
2017-06-12 15:55:42 +01:00
|
|
|
DVLA_RESPONSE_BUCKET_NAME = 'staging-notify.works-ftp'
|
2018-03-13 14:06:03 +00:00
|
|
|
LETTERS_PDF_BUCKET_NAME = 'staging-letters-pdf'
|
|
|
|
|
LETTERS_SCAN_BUCKET_NAME = 'staging-letters-scan'
|
2018-09-03 13:24:51 +01:00
|
|
|
INVALID_PDF_BUCKET_NAME = 'staging-letters-invalid-pdf'
|
2016-08-05 10:44:43 +01:00
|
|
|
STATSD_ENABLED = True
|
2016-09-08 10:44:14 +01:00
|
|
|
FROM_NUMBER = 'stage'
|
2017-04-25 09:54:09 +01:00
|
|
|
API_RATE_LIMIT_ENABLED = True
|
2017-11-16 12:02:09 +00:00
|
|
|
CHECK_PROXY_HEADER = True
|
2017-12-06 09:36:23 +00:00
|
|
|
REDIS_ENABLED = True
|
2016-07-04 16:54:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class Live(Config):
|
2016-09-07 09:35:31 +01:00
|
|
|
NOTIFY_EMAIL_DOMAIN = 'notifications.service.gov.uk'
|
2016-08-08 10:20:33 +01:00
|
|
|
NOTIFY_ENVIRONMENT = 'live'
|
2016-07-04 16:54:03 +01:00
|
|
|
CSV_UPLOAD_BUCKET_NAME = 'live-notifications-csv-upload'
|
2018-03-14 17:39:17 +00:00
|
|
|
TEST_LETTERS_BUCKET_NAME = 'production-test-letters'
|
2017-06-12 15:55:42 +01:00
|
|
|
DVLA_RESPONSE_BUCKET_NAME = 'notifications.service.gov.uk-ftp'
|
2018-03-13 14:06:03 +00:00
|
|
|
LETTERS_PDF_BUCKET_NAME = 'production-letters-pdf'
|
|
|
|
|
LETTERS_SCAN_BUCKET_NAME = 'production-letters-scan'
|
2018-09-03 13:24:51 +01:00
|
|
|
INVALID_PDF_BUCKET_NAME = 'production-letters-invalid-pdf'
|
2016-08-05 10:44:43 +01:00
|
|
|
STATSD_ENABLED = True
|
2017-05-22 15:58:19 +01:00
|
|
|
FROM_NUMBER = 'GOVUK'
|
2017-03-31 15:54:29 +01:00
|
|
|
PERFORMANCE_PLATFORM_ENABLED = True
|
2017-05-03 12:13:32 +01:00
|
|
|
API_RATE_LIMIT_ENABLED = True
|
2017-11-28 11:59:17 +00:00
|
|
|
CHECK_PROXY_HEADER = True
|
2016-12-08 12:12:45 +00:00
|
|
|
|
2019-01-16 14:11:03 +00:00
|
|
|
CRONITOR_ENABLED = True
|
|
|
|
|
|
2016-12-08 12:12:45 +00:00
|
|
|
|
|
|
|
|
class CloudFoundryConfig(Config):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# CloudFoundry sandbox
|
|
|
|
|
class Sandbox(CloudFoundryConfig):
|
|
|
|
|
NOTIFY_EMAIL_DOMAIN = 'notify.works'
|
|
|
|
|
NOTIFY_ENVIRONMENT = 'sandbox'
|
|
|
|
|
CSV_UPLOAD_BUCKET_NAME = 'cf-sandbox-notifications-csv-upload'
|
2017-12-04 16:29:04 +00:00
|
|
|
LETTERS_PDF_BUCKET_NAME = 'cf-sandbox-letters-pdf'
|
2018-03-14 17:39:17 +00:00
|
|
|
TEST_LETTERS_BUCKET_NAME = 'cf-sandbox-test-letters'
|
2017-06-12 15:55:42 +01:00
|
|
|
DVLA_RESPONSE_BUCKET_NAME = 'notify.works-ftp'
|
2018-03-13 14:06:03 +00:00
|
|
|
LETTERS_PDF_BUCKET_NAME = 'cf-sandbox-letters-pdf'
|
2018-03-13 14:08:34 +00:00
|
|
|
LETTERS_SCAN_BUCKET_NAME = 'cf-sandbox-letters-scan'
|
2018-09-03 13:24:51 +01:00
|
|
|
INVALID_PDF_BUCKET_NAME = 'cf-sandbox-letters-invalid-pdf'
|
2016-12-08 12:12:45 +00:00
|
|
|
FROM_NUMBER = 'sandbox'
|
2017-05-05 15:20:34 +01:00
|
|
|
REDIS_ENABLED = False
|
2016-07-05 21:25:37 +01:00
|
|
|
|
2016-07-04 16:54:03 +01:00
|
|
|
|
2016-03-17 11:47:44 +00:00
|
|
|
configs = {
|
2016-08-31 11:42:05 +01:00
|
|
|
'development': Development,
|
|
|
|
|
'test': Test,
|
|
|
|
|
'live': Live,
|
2017-03-21 14:43:56 +00:00
|
|
|
'production': Live,
|
2016-08-31 11:42:05 +01:00
|
|
|
'staging': Staging,
|
2016-12-08 12:12:45 +00:00
|
|
|
'preview': Preview,
|
|
|
|
|
'sandbox': Sandbox
|
2016-03-17 11:47:44 +00:00
|
|
|
}
|