(self, params, **kwargs)
| 864 | return record_add_parser |
| 865 | |
| 866 | def execute(self, params, **kwargs): |
| 867 | if kwargs.get('syntax_help') is True: |
| 868 | print(record_fields_description) |
| 869 | return |
| 870 | |
| 871 | # Validate email parameters |
| 872 | send_email = kwargs.get('send_email') |
| 873 | if send_email: |
| 874 | if not kwargs.get('email_config'): |
| 875 | raise CommandError('record-add', '--send-email requires --email-config to specify email configuration') |
| 876 | |
| 877 | # Validate email provider dependencies early (before creating record) |
| 878 | try: |
| 879 | from .email_commands import find_email_config_record, load_email_config_from_record |
| 880 | from ..email_service import validate_email_provider_dependencies |
| 881 | |
| 882 | email_config_name = kwargs.get('email_config') |
| 883 | config_uid = find_email_config_record(params, email_config_name) |
| 884 | email_config_obj = load_email_config_from_record(params, config_uid) |
| 885 | |
| 886 | # Check if required dependencies are installed for this provider |
| 887 | is_valid, error_message = validate_email_provider_dependencies(email_config_obj.provider) |
| 888 | |
| 889 | if not is_valid: |
| 890 | raise CommandError('record-add', f'\n{error_message}') |
| 891 | |
| 892 | except Exception as e: |
| 893 | # Re-raise CommandError as-is, wrap other exceptions |
| 894 | if isinstance(e, CommandError): |
| 895 | raise |
| 896 | raise CommandError('record-add', f'Failed to validate email configuration: {e}') |
| 897 | |
| 898 | # Handle share link creation |
| 899 | # If --send-email is used without --self-destruct, create a 24h time-based expiration (not self-destruct) |
| 900 | expiration_period = None |
| 901 | self_destruct = kwargs.get('self_destruct') |
| 902 | is_self_destruct_link = False # Track whether to enable self-destruct on first use |
| 903 | |
| 904 | if self_destruct: |
| 905 | expiration_period = parse_timeout(self_destruct) |
| 906 | if expiration_period.total_seconds() > 182 * 24 * 60 * 60: |
| 907 | raise CommandError('', 'URL expiration period cannot be greater than 6 months.') |
| 908 | is_self_destruct_link = True # User explicitly requested self-destruct |
| 909 | elif send_email: |
| 910 | # Auto-create share link with 24-hour time-based expiration (without self-destruct) |
| 911 | expiration_period = parse_timeout('24h') |
| 912 | self_destruct = '24h' # For email template text |
| 913 | is_self_destruct_link = False # Time-based only, can be used multiple times |
| 914 | logging.info('--send-email used without --self-destruct, creating 24 hour time-based share link') |
| 915 | |
| 916 | folder_uid = FolderMixin.resolve_folder(params, kwargs.get('folder')) |
| 917 | |
| 918 | self.warnings.clear() |
| 919 | title = kwargs.get('title') |
| 920 | if not title: |
| 921 | raise CommandError('record-add', 'Title parameter is required.') |
| 922 | record_type = kwargs.get('record_type') # type: Optional[str] |
| 923 | if not record_type: |
nothing calls this directly
no test coverage detected