1010from collections import OrderedDict , namedtuple
1111from ordered_set import OrderedSet
1212from typing import Callable , Dict , List
13- from notifications_utils import SMS_CHAR_COUNT_LIMIT
1413from flask import current_app
15- from notifications_utils .sanitise_text import SanitiseSMS
1614from . import EMAIL_REGEX_PATTERN , hostname_part , tld_part
1715from notifications_utils .formatters import strip_and_remove_obscure_whitespace , strip_whitespace
1816from notifications_utils .template import SMSMessageTemplate , Template
@@ -276,23 +274,6 @@ def rows_with_missing_data(self):
276274 def rows_with_message_too_long (self ):
277275 return self ._filter_rows ("message_too_long" )
278276
279- @property
280- def rows_with_combined_variable_content_too_long (self ):
281- """
282- Checks if the length of all variable, plus the length of the template content,
283- exceeds the SMS limit of 612 characters. Counts non-GSM characters as 2.
284- """
285- if self .rows_as_list :
286- for row in self .rows_as_list :
287- if row .personalisation and self .template :
288- variable_length = 0
289- for variable in row .personalisation .as_dict_with_keys (self .template .placeholders ).values ():
290- if variable :
291- variable_length += sum (1 if char in SanitiseSMS .ALLOWED_CHARACTERS else 2 for char in str (variable ))
292- total_length = variable_length + (len (self .template .content ) if self .template else 0 )
293- if total_length > SMS_CHAR_COUNT_LIMIT :
294- yield row
295-
296277 @property
297278 def initial_rows_with_errors (self ):
298279 return islice (self .rows_with_errors , self .max_errors_shown )
@@ -378,9 +359,7 @@ def _get_error_for_field(self, key, value): # noqa: C901
378359 if self .is_optional_address_column (key ):
379360 return
380361
381- formatted_key = Columns .make_key (key )
382-
383- if formatted_key in self .recipient_column_headers_as_column_keys :
362+ if Columns .make_key (key ) in self .recipient_column_headers_as_column_keys :
384363 if value in [None , "" ] or isinstance (value , list ):
385364 if self .duplicate_recipient_column_headers :
386365 return None
@@ -391,19 +370,12 @@ def _get_error_for_field(self, key, value): # noqa: C901
391370 except (InvalidEmailError , InvalidPhoneError , InvalidAddressError ) as error :
392371 return str (error )
393372
394- if formatted_key not in self .placeholders_as_column_keys :
373+ if Columns . make_key ( key ) not in self .placeholders_as_column_keys :
395374 return
396375
397376 if value in [None , "" ]:
398377 return Cell .missing_field_error
399378
400- if self .template :
401- if formatted_key in self .placeholders_as_column_keys and self .template .template_type == "sms" :
402- try :
403- validate_sms_message_length (value , self .template .content )
404- except ValueError as error :
405- return str (error )
406-
407379
408380class InvalidEmailError (Exception ):
409381 def __init__ (self , message = None ):
@@ -579,14 +551,6 @@ def validate_recipient(recipient, template_type: str, column=None, international
579551 return validators [template_type ](recipient , column )
580552
581553
582- def validate_sms_message_length (variable_content , template_content_length ):
583- variable_length = sum (1 if char in SanitiseSMS .ALLOWED_CHARACTERS else 2 for char in variable_content )
584-
585- if variable_length + len (template_content_length ) > SMS_CHAR_COUNT_LIMIT :
586- raise ValueError (f"Maximum { SMS_CHAR_COUNT_LIMIT } characters. Some messages may be too long due to custom content." )
587- return
588-
589-
590554@lru_cache (maxsize = 32 , typed = False )
591555def format_recipient (recipient ):
592556 if not isinstance (recipient , str ):
0 commit comments