Commit Graph

256 Commits

Author SHA1 Message Date
Kenneth Kehl
72689c39d0 add gevent.sleep(0) as a keep alive 2025-07-31 12:30:35 -07:00
Kenneth Kehl
58a8b51f59 more input checking 2025-06-26 10:35:46 -07:00
Kenneth Kehl
34434bda57 initial 2025-06-10 10:33:59 -07:00
alexjanousekGSA
1472755b51 Fixed unit test 2025-06-09 13:39:08 -04:00
alexjanousekGSA
82deb9633d Made conditional more specific to pass scan 2025-06-09 13:06:01 -04:00
alexjanousekGSA
8e7b3dead3 Fixing static scan 2025-06-09 13:01:22 -04:00
alexjanousekGSA
bc68f80958 Updated based on PR comments 2025-06-09 12:09:22 -04:00
alexjanousekGSA
c8eae375f4 Fixed scan errors 2025-06-02 10:44:42 -04:00
alexjanousekGSA
8feced8d7f Fixed more tests, 48 left 2025-05-28 13:47:35 -04:00
alexjanousekGSA
898607b40a Removed dependency that is not needed, fixed more tests 2025-05-16 16:23:59 -04:00
alexjanousekGSA
a100fa6eb8 Fixed test_get_notification.py tests 2025-05-14 15:01:01 -04:00
alexjanousekGSA
b7d87b6db8 Removed unused import 2025-05-14 13:42:12 -04:00
alexjanousekGSA
68aa63945a Fixed test_rest file 2025-05-14 13:41:23 -04:00
alexjanousekGSA
0402f6dc71 Fixed a few unit tests 2025-05-09 15:14:07 -04:00
Kenneth Kehl
a413ec092d merge from main 2025-01-28 08:45:04 -08:00
Kenneth Kehl
8444b76690 fix flake8 2024-08-09 09:18:58 -07:00
Kenneth Kehl
2e7e6e81fc Need to remove priority logic 2024-08-09 09:11:28 -07:00
Carlo Costino
543a20f4a1 Merge pull request #987 from GSA/pr_debug_reports
add some debug around report generation
2024-05-31 10:03:05 -04:00
Carlo Costino
99edc88197 Localize notification_utils to the API
This changeset pulls in all of the notification_utils code directly into the API and removes it as an external dependency.  We are doing this to cut down on operational maintenance of the project and will begin removing parts of it no longer needed for the API.

Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
2024-05-16 10:17:45 -04:00
Kenneth Kehl
e7c68531f2 fix flake 8 2024-05-15 08:34:56 -07:00
Kenneth Kehl
c3a20eca17 add some debug around report generation 2024-05-14 07:23:47 -07:00
Kenneth Kehl
b777249b6f merge from main 2024-03-01 13:50:09 -08:00
Cliff Hill
9523cc1d97 Cleaning up with black, isort, flake8.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:43:33 -05:00
Cliff Hill
7416de2a28 KeyType implemented.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:43:33 -05:00
Cliff Hill
3982f061b6 Made enums.py for all the enums to avoid cyclic imports.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:43:31 -05:00
Cliff Hill
820ee5a942 Cleaning up a lot of things, getting Enums used everywhere.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:40:52 -05:00
Kenneth Kehl
6dc9828663 fix tests 2024-01-22 10:55:09 -08:00
Kenneth Kehl
065009bb7a merge from main and reformat 2023-08-29 16:21:18 -07:00
Kenneth Kehl
1ecb747c6d reformat 2023-08-29 14:54:30 -07:00
Kenneth Kehl
5a350560d7 notify-api-433b remove research mode 2023-08-25 12:09:00 -07:00
Kenneth Kehl
026dc14021 notify-api-412 use black to enforce python style standards 2023-08-23 10:35:43 -07:00
Steven Reilly
ff4190a8eb Remove letters-related code (#175)
This deletes a big ol' chunk of code related to letters. It's not everything—there are still a few things that might be tied to sms/email—but it's the the heart of letters function. SMS and email function should be untouched by this.

Areas affected:

- Things obviously about letters
- PDF tasks, used for precompiling letters
- Virus scanning, used for those PDFs
- FTP, used to send letters to the printer
- Postage stuff
2023-03-02 20:20:31 -05:00
Katie Smith
8ae2b0bb31 Replace how .dump is called
As with `.load`, only data is now returned instead of a tuple.
2022-05-25 11:35:44 +01:00
Katie Smith
bd4f74b359 Replace how .load is called
https://marshmallow.readthedocs.io/en/stable/upgrading.html#schemas-are-always-strict

`.load` doesn't return a `(data, errors)` tuple any more - only data is
returned. A `ValidationError` is raised if validation fails. The code
now relies on the `marshmallow_validation_error` error handler to handle
errors instead of having to raise an `InvalidRequest`. This has no
effect on the response that is returned (a test has been modified to
check).

Also added a new `password` field to the `UserSchema` so that we don't
have to specially check for password errors in the `.create_user` endpoint
- we can let marshmallow handle them.
2022-05-25 11:35:44 +01:00
Pea Tyczynska
52c529ab3a Use personalisation to set client_reference for letters
which were sent through Notify interface only. This is done
to avoid performance dip from additional operation for
other notification types.
2021-03-24 14:55:10 +00:00
Ben Thorner
a91fde2fda Run auto-correct on app/ and tests/ 2021-03-12 11:45:45 +00:00
Rebecca Law
4a9f9e4b17 Remove the template_postage parameter for persist_notification
It was confusing to have 2 differnt postage parameters.
2020-08-06 07:35:13 +01:00
Chris Hill-Scott
ad2328fc05 Serialise template immediately after fetching
This commit changes the code in post notification endpoint to handle a
serialised template (ie a `dict`) rather than a database object.

This is the first step towards being able to cache the template and not
hit the database on every request.

There should be no functional changes here, it’s just refactoring.

There are some changes to the tests where the signature of functions
has changed.

Importing of the template schema has to be done at a function level,
otherwise Marshmallow gets weird.

This commit also copies the `JSONModel` class from the admin app, which
turns serialised data (a dict made from JSON) into an object on which
certain predefined properties are allowed.

This means we can still do the caching of serialised data, without
having to change too much of the code in the app, or make it ugly by
sprinkling dict lookups everywhere.

We’re not copying all of JSONModel from the admin app, just the bits we
need. We don’t need to compare or hash these objects, they’re just used
for lookups. And redefining `__getattribute__` scares Leo.
2020-06-22 10:20:51 +01:00
Pea Tyczynska
ef9f3c1e5f Make sure we check if a service can send to number harmoniously
We were checking this separately in two places in the code. Now
we will have this logic in one place, in validators.

Also pull in utils version that recognises crown depenency numbers
as international.
2020-06-19 15:59:15 +01:00
Pea Tyczynska
b0bb0b9780 Make sure people without international sms permission can send to crown dependencies 2020-06-19 15:58:22 +01:00
Chris Hill-Scott
5ddb5a75da Use new properties of utils Templates
We’ve added some new properties to the templates in utils that we can
use instead of doing weird things like
`WithSubjectTemplate.__str__(another_instance)`
2020-04-15 16:40:42 +01:00
Chris Hill-Scott
025ac3ea89 Use same template to validate and send notification
To be absolutely sure that we can send a message we should also validate
it using the same template class that we use to render it.
2020-04-07 10:41:16 +01:00
Rebecca Law
a994e8fb6e Update validators to use is_message_too_long()
- update check_sms_content_char_count to use the SMSTemplate.is_message_too_long function, and updated the error message to align with the message returned by the admin app.
- Update the the code used by version 1 of the api to use the validate_template method.
  - I did find a couple of services still using the old api, however, this change should not affect them as I checked the messages being sent and they are not too long.
  - We will be sending a message to them to see if they can upgrade.
- Update the log message for authenication to include the URL - makes it easier to track if a service is using version 1 of the api.
2020-03-10 09:38:16 +00:00
Leo Hemsted
8f7f99234b use Template.is_message_too_long rather than content_count directly
this function returns false for emails and letters so we can clean up
the code and reduce duplication a little bit
2019-11-18 17:00:32 +00:00
Pea Tyczynska
5ebeb9937a Avoid call to database to get template in persist_notifications 2019-01-14 17:53:06 +00:00
Katie Smith
a87be9b74a Use new value of SMS_CHAR_COUNT_LIMIT from utils
Admin, API and utils were all defining a value for SMS_CHAR_COUNT_LIMIT.
This value has been updated in notifications-utils to allow text
messages to be 4 fragments long and notifications-api now gets the value of
SMS_CHAR_COUNT_LIMIT from notifications-utils instead of defining it in
config.

Also updated some tests to check for the higher limit.
2018-08-16 16:34:34 +01:00
Rebecca Law
dce79832ff As Notify matures we probably need less logging, especially to report happy path events.
This PR is a proposal to reduce the average messages we see for a single notification from about 7 messages to 2.

Messaging would change to something like this:
February 2nd 2018, 15:39:05.885	Full delivery response from Firetext for notification: 8eda51d5-cd82-4569-bfc9-d5570cdf2126
{'status': ['0'], 'reference': ['8eda51d5-cd82-4569-bfc9-d5570cdf2126'], 'time': ['2018-02-02 15:39:01'], 'code': ['000']}
February 2nd 2018, 15:39:05.885	Firetext callback return status of 0 for reference: 8eda51d5-cd82-4569-bfc9-d5570cdf2126
February 2nd 2018, 15:38:57.727	SMS 8eda51d5-cd82-4569-bfc9-d5570cdf2126 sent to provider firetext at 2018-02-02 15:38:56.716814
February 2nd 2018, 15:38:56.727	Starting sending SMS 8eda51d5-cd82-4569-bfc9-d5570cdf2126 to provider at 2018-02-02 15:38:56.408181
February 2nd 2018, 15:38:56.727	Firetext request for 8eda51d5-cd82-4569-bfc9-d5570cdf2126 finished in 0.30376038211397827
February 2nd 2018, 15:38:49.449	sms 8eda51d5-cd82-4569-bfc9-d5570cdf2126 created at 2018-02-02 15:38:48.439113
February 2nd 2018, 15:38:49.449	sms 8eda51d5-cd82-4569-bfc9-d5570cdf2126 sent to the priority-tasks queue for delivery

To somthing like this:
February 2nd 2018, 15:39:05.885	Firetext callback return status of 0 for reference: 8eda51d5-cd82-4569-bfc9-d5570cdf2126
February 2nd 2018, 15:38:49.449	sms 8eda51d5-cd82-4569-bfc9-d5570cdf2126 created at 2018-02-02 15:38:48.439113
2018-02-02 15:55:25 +00:00
Rebecca Law
a052020f84 - simplify if statement
- use the template.get_reply_to_text() in send_notification, it's already using the right thing.
2018-01-08 16:54:19 +00:00
venusbb
3945007d24 add reply-to-text to user/rest persist notifications 2017-11-27 14:36:54 +00:00
Rebecca Law
530f2e7f6a Update invite user endpoint to set the reply_to_text on the notification.
Update v1 post notifications to set the reply_to_text on the notification.
2017-11-27 12:30:50 +00:00