Showing preview only (1,389K chars total). Download the full file or copy to clipboard to get everything.
Repository: postalserver/postal
Branch: main
Commit: d532922ff7f5
Files: 525
Total size: 1.2 MB
Directory structure:
gitextract_spx0x18a/
├── .dockerignore
├── .github/
│ ├── ISSUE_TEMPLATE/
│ │ ├── bug_report.md
│ │ └── config.yml
│ └── workflows/
│ ├── ci.yml
│ └── close.yml
├── .gitignore
├── .release-please-manifest.json
├── .rubocop.yml
├── .ruby-version
├── CHANGELOG.md
├── CONTRIBUTING.md
├── Dockerfile
├── Gemfile
├── MIT-LICENCE
├── Procfile.dev
├── README.md
├── Rakefile
├── SECURITY.md
├── app/
│ ├── assets/
│ │ ├── config/
│ │ │ └── manifest.js
│ │ ├── images/
│ │ │ └── .keep
│ │ ├── javascripts/
│ │ │ └── application/
│ │ │ ├── application.coffee
│ │ │ ├── elements/
│ │ │ │ ├── ajax.coffee
│ │ │ │ ├── mail_graph.coffee
│ │ │ │ ├── remembering.coffee
│ │ │ │ └── searchable.coffee
│ │ │ └── vendor/
│ │ │ ├── chartist.js
│ │ │ └── jquery.multibox.js
│ │ └── stylesheets/
│ │ └── application/
│ │ ├── application.scss
│ │ ├── components/
│ │ │ ├── _admin_stats.scss
│ │ │ ├── _button_set.scss
│ │ │ ├── _checkbox_list.scss
│ │ │ ├── _credential_list.scss
│ │ │ ├── _danger_zone.scss
│ │ │ ├── _data_table.scss
│ │ │ ├── _delivery_list.scss
│ │ │ ├── _domain_list.scss
│ │ │ ├── _endpoint_list.scss
│ │ │ ├── _error_explanation.scss
│ │ │ ├── _field_set.scss
│ │ │ ├── _flash_display.scss
│ │ │ ├── _flash_message.scss
│ │ │ ├── _footer.scss
│ │ │ ├── _grid.scss
│ │ │ ├── _headers_list.scss
│ │ │ ├── _inlineError.scss
│ │ │ ├── _invoice_list.scss
│ │ │ ├── _ip_list.scss
│ │ │ ├── _ip_pool_rule_list.scss
│ │ │ ├── _large_list.scss
│ │ │ ├── _limit.scss
│ │ │ ├── _login_form.scss
│ │ │ ├── _mail_graph.scss
│ │ │ ├── _message_activity.scss
│ │ │ ├── _message_header.scss
│ │ │ ├── _message_list.scss
│ │ │ ├── _message_properties_page.scss
│ │ │ ├── _message_search.scss
│ │ │ ├── _multibox.scss
│ │ │ ├── _nav_bar.scss
│ │ │ ├── _new_message_type.scss
│ │ │ ├── _no_data.scss
│ │ │ ├── _page_content.scss
│ │ │ ├── _page_header.scss
│ │ │ ├── _pagination.scss
│ │ │ ├── _rentention_limits.scss
│ │ │ ├── _route_list.scss
│ │ │ ├── _route_name_input.scss
│ │ │ ├── _server_header.scss
│ │ │ ├── _sidebar.scss
│ │ │ ├── _sidebar_server_list.scss
│ │ │ ├── _simple_pagination.scss
│ │ │ ├── _site_content.scss
│ │ │ ├── _site_header.scss
│ │ │ ├── _spam_check_list.scss
│ │ │ ├── _starter_credit_pack.scss
│ │ │ ├── _sub_page_box.scss
│ │ │ ├── _suppression_list.scss
│ │ │ ├── _suspension_box.scss
│ │ │ ├── _title_with_links.scss
│ │ │ ├── _user_list.scss
│ │ │ ├── _webhook_list.scss
│ │ │ └── _webhook_request_list.scss
│ │ ├── elements/
│ │ │ ├── _bar.scss
│ │ │ ├── _button.scss
│ │ │ ├── _code_block.scss
│ │ │ ├── _input.scss
│ │ │ ├── _label.scss
│ │ │ ├── _misc.scss
│ │ │ └── _spam_range.scss
│ │ ├── global/
│ │ │ ├── _fonts.scss
│ │ │ ├── _mixins.scss
│ │ │ ├── _reset.scss
│ │ │ ├── _utility.scss
│ │ │ └── _variables.scss
│ │ └── vendor/
│ │ └── _chartist.scss
│ ├── controllers/
│ │ ├── address_endpoints_controller.rb
│ │ ├── application_controller.rb
│ │ ├── concerns/
│ │ │ ├── .keep
│ │ │ └── within_organization.rb
│ │ ├── credentials_controller.rb
│ │ ├── domains_controller.rb
│ │ ├── help_controller.rb
│ │ ├── http_endpoints_controller.rb
│ │ ├── ip_addresses_controller.rb
│ │ ├── ip_pool_rules_controller.rb
│ │ ├── ip_pools_controller.rb
│ │ ├── legacy_api/
│ │ │ ├── base_controller.rb
│ │ │ ├── messages_controller.rb
│ │ │ └── send_controller.rb
│ │ ├── messages_controller.rb
│ │ ├── organization_ip_pools_controller.rb
│ │ ├── organizations_controller.rb
│ │ ├── routes_controller.rb
│ │ ├── servers_controller.rb
│ │ ├── sessions_controller.rb
│ │ ├── smtp_endpoints_controller.rb
│ │ ├── track_domains_controller.rb
│ │ ├── user_controller.rb
│ │ ├── users_controller.rb
│ │ ├── webhooks_controller.rb
│ │ └── well_known_controller.rb
│ ├── helpers/
│ │ └── application_helper.rb
│ ├── lib/
│ │ ├── dkim_header.rb
│ │ ├── dns_resolver.rb
│ │ ├── message_dequeuer/
│ │ │ ├── base.rb
│ │ │ ├── incoming_message_processor.rb
│ │ │ ├── initial_processor.rb
│ │ │ ├── outgoing_message_processor.rb
│ │ │ ├── single_message_processor.rb
│ │ │ └── state.rb
│ │ ├── message_dequeuer.rb
│ │ ├── query_string.rb
│ │ ├── received_header.rb
│ │ ├── reply_separator.rb
│ │ ├── smtp_client/
│ │ │ ├── endpoint.rb
│ │ │ ├── server.rb
│ │ │ └── ssl_modes.rb
│ │ ├── smtp_server/
│ │ │ ├── client.rb
│ │ │ └── server.rb
│ │ └── worker/
│ │ ├── jobs/
│ │ │ ├── base_job.rb
│ │ │ ├── process_queued_messages_job.rb
│ │ │ └── process_webhook_requests_job.rb
│ │ └── process.rb
│ ├── mailers/
│ │ ├── app_mailer.rb
│ │ └── application_mailer.rb
│ ├── models/
│ │ ├── additional_route_endpoint.rb
│ │ ├── address_endpoint.rb
│ │ ├── application_record.rb
│ │ ├── bounce_message.rb
│ │ ├── concerns/
│ │ │ ├── .keep
│ │ │ ├── has_authentication.rb
│ │ │ ├── has_dns_checks.rb
│ │ │ ├── has_locking.rb
│ │ │ ├── has_message.rb
│ │ │ ├── has_soft_destroy.rb
│ │ │ └── has_uuid.rb
│ │ ├── credential.rb
│ │ ├── domain.rb
│ │ ├── http_endpoint.rb
│ │ ├── incoming_message_prototype.rb
│ │ ├── ip_address.rb
│ │ ├── ip_pool.rb
│ │ ├── ip_pool_rule.rb
│ │ ├── organization.rb
│ │ ├── organization_ip_pool.rb
│ │ ├── organization_user.rb
│ │ ├── outgoing_message_prototype.rb
│ │ ├── queued_message.rb
│ │ ├── route.rb
│ │ ├── scheduled_task.rb
│ │ ├── server.rb
│ │ ├── smtp_endpoint.rb
│ │ ├── statistic.rb
│ │ ├── track_domain.rb
│ │ ├── user.rb
│ │ ├── user_invite.rb
│ │ ├── webhook.rb
│ │ ├── webhook_event.rb
│ │ ├── webhook_request.rb
│ │ └── worker_role.rb
│ ├── scheduled_tasks/
│ │ ├── action_deletions_scheduled_task.rb
│ │ ├── application_scheduled_task.rb
│ │ ├── check_all_dns_scheduled_task.rb
│ │ ├── cleanup_authie_sessions_scheduled_task.rb
│ │ ├── expire_held_messages_scheduled_task.rb
│ │ ├── process_message_retention_scheduled_task.rb
│ │ ├── prune_suppression_lists_scheduled_task.rb
│ │ ├── prune_webhook_requests_scheduled_task.rb
│ │ ├── send_notifications_scheduled_task.rb
│ │ └── tidy_queued_messages_task.rb
│ ├── senders/
│ │ ├── base_sender.rb
│ │ ├── http_sender.rb
│ │ ├── send_result.rb
│ │ └── smtp_sender.rb
│ ├── services/
│ │ └── webhook_delivery_service.rb
│ ├── util/
│ │ ├── has_prometheus_metrics.rb
│ │ ├── health_server.rb
│ │ └── user_creator.rb
│ └── views/
│ ├── address_endpoints/
│ │ ├── _form.html.haml
│ │ ├── edit.html.haml
│ │ ├── index.html.haml
│ │ └── new.html.haml
│ ├── app_mailer/
│ │ ├── password_reset.text.erb
│ │ ├── server_send_limit_approaching.text.erb
│ │ ├── server_send_limit_exceeded.text.erb
│ │ ├── server_suspended.text.erb
│ │ ├── test_message.text.erb
│ │ └── verify_domain.text.erb
│ ├── credentials/
│ │ ├── _form.html.haml
│ │ ├── edit.html.haml
│ │ ├── index.html.haml
│ │ └── new.html.haml
│ ├── domains/
│ │ ├── _nav.html.haml
│ │ ├── _verify_with_dns.html.haml
│ │ ├── _verify_with_email.html.haml
│ │ ├── index.html.haml
│ │ ├── new.html.haml
│ │ ├── setup.html.haml
│ │ └── verify.html.haml
│ ├── help/
│ │ ├── _header.html.haml
│ │ ├── incoming.html.haml
│ │ └── outgoing.html.haml
│ ├── http_endpoints/
│ │ ├── _form.html.haml
│ │ ├── edit.html.haml
│ │ ├── index.html.haml
│ │ └── new.html.haml
│ ├── ip_addresses/
│ │ ├── _form.html.haml
│ │ ├── edit.html.haml
│ │ └── new.html.haml
│ ├── ip_pool_rules/
│ │ ├── _form.html.haml
│ │ ├── edit.html.haml
│ │ ├── index.html.haml
│ │ └── new.html.haml
│ ├── ip_pools/
│ │ ├── _form.html.haml
│ │ ├── edit.html.haml
│ │ ├── index.html.haml
│ │ └── new.html.haml
│ ├── layouts/
│ │ ├── application.html.haml
│ │ └── sub.html.haml
│ ├── messages/
│ │ ├── _deliveries.html.haml
│ │ ├── _header.html.haml
│ │ ├── _index.html.haml
│ │ ├── _list.html.haml
│ │ ├── _message_header.html.haml
│ │ ├── _search.html.haml
│ │ ├── activity.html.haml
│ │ ├── attachments.html.haml
│ │ ├── headers.html.haml
│ │ ├── held.html.haml
│ │ ├── html.html.haml
│ │ ├── incoming.html.haml
│ │ ├── new.html.haml
│ │ ├── outgoing.html.haml
│ │ ├── plain.html.haml
│ │ ├── show.html.haml
│ │ ├── spam_checks.html.haml
│ │ └── suppressions.html.haml
│ ├── organization_ip_pools/
│ │ ├── _nav.html.haml
│ │ └── index.html.haml
│ ├── organizations/
│ │ ├── _nav.html.haml
│ │ ├── delete.html.haml
│ │ ├── edit.html.haml
│ │ ├── index.html.haml
│ │ └── new.html.haml
│ ├── routes/
│ │ ├── _form.html.haml
│ │ ├── _header.html.haml
│ │ ├── edit.html.haml
│ │ ├── index.html.haml
│ │ └── new.html.haml
│ ├── servers/
│ │ ├── _form.html.haml
│ │ ├── _header.html.haml
│ │ ├── _settings_header.html.haml
│ │ ├── _sidebar.html.haml
│ │ ├── advanced.html.haml
│ │ ├── delete.html.haml
│ │ ├── edit.html.haml
│ │ ├── index.html.haml
│ │ ├── limits.html.haml
│ │ ├── new.html.haml
│ │ ├── queue.html.haml
│ │ ├── retention.html.haml
│ │ ├── show.html.haml
│ │ └── spam.html.haml
│ ├── sessions/
│ │ ├── begin_password_reset.html.haml
│ │ ├── finish_password_reset.html.haml
│ │ └── new.html.haml
│ ├── shared/
│ │ └── _message_db_pagination.html.haml
│ ├── smtp_endpoints/
│ │ ├── _form.html.haml
│ │ ├── edit.html.haml
│ │ ├── index.html.haml
│ │ └── new.html.haml
│ ├── track_domains/
│ │ ├── _form.html.haml
│ │ ├── edit.html.haml
│ │ ├── index.html.haml
│ │ └── new.html.haml
│ ├── user/
│ │ └── edit.html.haml
│ ├── users/
│ │ ├── _form.html.haml
│ │ ├── edit.html.haml
│ │ ├── index.html.haml
│ │ └── new.html.haml
│ └── webhooks/
│ ├── _form.html.haml
│ ├── _header.html.haml
│ ├── edit.html.haml
│ ├── history.html.haml
│ ├── history_request.html.haml
│ ├── index.html.haml
│ └── new.html.haml
├── bin/
│ ├── bundle
│ ├── dev
│ ├── postal
│ ├── rails
│ ├── rake
│ ├── rspec
│ ├── setup
│ └── update
├── config/
│ ├── application.rb
│ ├── boot.rb
│ ├── database.yml
│ ├── environment.rb
│ ├── environments/
│ │ ├── development.rb
│ │ ├── production.rb
│ │ └── test.rb
│ ├── examples/
│ │ ├── development.yml
│ │ └── test.yml
│ ├── initializers/
│ │ ├── _wait_for_migrations.rb
│ │ ├── application_controller_renderer.rb
│ │ ├── assets.rb
│ │ ├── backtrace_silencers.rb
│ │ ├── content_security_policy.rb
│ │ ├── cookies_serializer.rb
│ │ ├── filter_parameter_logging.rb
│ │ ├── inflections.rb
│ │ ├── logging.rb
│ │ ├── mail_extensions.rb
│ │ ├── mime_types.rb
│ │ ├── new_framework_defaults_7_0.rb
│ │ ├── omniauth.rb
│ │ ├── permissions_policy.rb
│ │ ├── postal.rb
│ │ ├── record_key_for_dom.rb
│ │ ├── secret_key.rb
│ │ ├── secure_headers.rb
│ │ ├── sentry.rb
│ │ ├── session_store.rb
│ │ ├── smtp.rb
│ │ ├── smtp_extensions.rb
│ │ ├── trusted_proxies.rb
│ │ ├── wrap_parameters.rb
│ │ └── zeitwerk.rb
│ ├── locales/
│ │ └── en.yml
│ ├── puma.rb
│ └── routes.rb
├── config.ru
├── db/
│ ├── migrate/
│ │ ├── 20161003195209_create_authie_sessions.authie.rb
│ │ ├── 20161003195210_add_indexes_to_authie_sessions.authie.rb
│ │ ├── 20161003195211_add_parent_id_to_authie_sessions.authie.rb
│ │ ├── 20161003195212_add_two_factor_auth_fields_to_authie.authie.rb
│ │ ├── 20170418200606_initial_schema.rb
│ │ ├── 20170421195414_add_token_hashes_to_authie_sessions.authie.rb
│ │ ├── 20170421195415_add_index_to_token_hashes_on_authie_sessions.authie.rb
│ │ ├── 20170428153353_remove_type_from_ip_pools.rb
│ │ ├── 20180216114344_add_host_to_authie_sessions.authie.rb
│ │ ├── 20200717083943_add_uuid_to_credentials.rb
│ │ ├── 20210727210551_add_priority_to_ip_addresses.rb
│ │ ├── 20240206173036_add_privacy_mode_to_servers.rb
│ │ ├── 20240213165450_create_worker_roles.rb
│ │ ├── 20240213171830_create_scheduled_tasks.rb
│ │ ├── 20240214132253_add_lock_fields_to_webhook_requests.rb
│ │ ├── 20240223141500_add_two_factor_required_to_sessions.authie.rb
│ │ ├── 20240223141501_add_countries_to_authie_sessions.authie.rb
│ │ └── 20240311205229_add_oidc_fields_to_user.rb
│ ├── schema.rb
│ └── seeds.rb
├── doc/
│ └── config/
│ ├── configuration.md
│ ├── environment-variables.md
│ └── yaml.yml
├── docker/
│ ├── ci-config/
│ │ └── signing.key
│ └── wait-for.sh
├── docker-compose.yml
├── lib/
│ ├── assets/
│ │ └── .keep
│ ├── migration_waiter.rb
│ ├── postal/
│ │ ├── config.rb
│ │ ├── config_schema.rb
│ │ ├── error.rb
│ │ ├── helm_config_exporter.rb
│ │ ├── helpers.rb
│ │ ├── http.rb
│ │ ├── legacy_config_source.rb
│ │ ├── message_db/
│ │ │ ├── click.rb
│ │ │ ├── connection_pool.rb
│ │ │ ├── database.rb
│ │ │ ├── delivery.rb
│ │ │ ├── live_stats.rb
│ │ │ ├── load.rb
│ │ │ ├── message.rb
│ │ │ ├── migration.rb
│ │ │ ├── migrations/
│ │ │ │ ├── 01_create_migrations.rb
│ │ │ │ ├── 02_create_messages.rb
│ │ │ │ ├── 03_create_deliveries.rb
│ │ │ │ ├── 04_create_live_stats.rb
│ │ │ │ ├── 05_create_raw_message_sizes.rb
│ │ │ │ ├── 06_create_clicks.rb
│ │ │ │ ├── 07_create_loads.rb
│ │ │ │ ├── 08_create_stats.rb
│ │ │ │ ├── 09_create_links.rb
│ │ │ │ ├── 10_create_spam_checks.rb
│ │ │ │ ├── 11_add_time_to_deliveries.rb
│ │ │ │ ├── 12_add_hold_expiry.rb
│ │ │ │ ├── 13_add_index_to_message_status.rb
│ │ │ │ ├── 14_create_suppressions.rb
│ │ │ │ ├── 15_create_webhook_requests.rb
│ │ │ │ ├── 16_add_url_and_hook_to_webhooks.rb
│ │ │ │ ├── 17_add_replaced_link_count_to_messages.rb
│ │ │ │ ├── 18_add_endpoints_to_messages.rb
│ │ │ │ ├── 19_convert_database_to_utf8mb4.rb
│ │ │ │ └── 20_increase_links_url_size.rb
│ │ │ ├── provisioner.rb
│ │ │ ├── statistics.rb
│ │ │ ├── suppression_list.rb
│ │ │ └── webhooks.rb
│ │ ├── message_inspection.rb
│ │ ├── message_inspector.rb
│ │ ├── message_inspectors/
│ │ │ ├── clamav.rb
│ │ │ ├── rspamd.rb
│ │ │ └── spam_assassin.rb
│ │ ├── message_parser.rb
│ │ ├── signer.rb
│ │ ├── spam_check.rb
│ │ └── yaml_config_exporter.rb
│ ├── postal.rb
│ ├── tasks/
│ │ ├── .keep
│ │ ├── auto_annotate_models.rake
│ │ └── postal.rake
│ └── tracking_middleware.rb
├── log/
│ └── .keep
├── public/
│ ├── 404.html
│ ├── 422.html
│ ├── 500.html
│ └── robots.txt
├── release-please-config.json
├── resource/
│ └── postfix-bounce.msg
├── script/
│ ├── default_dkim_record.rb
│ ├── generate_tls_certificate.rb
│ ├── insert-bounce.rb
│ ├── make_user.rb
│ ├── queue_size.rb
│ ├── send_html_email.rb
│ ├── smtp_server.rb
│ ├── test_app_smtp.rb
│ ├── version.rb
│ └── worker.rb
├── spec/
│ ├── apis/
│ │ └── legacy_api/
│ │ ├── messages/
│ │ │ ├── deliveries_spec.rb
│ │ │ └── message_spec.rb
│ │ └── send/
│ │ ├── message_spec.rb
│ │ └── raw_spec.rb
│ ├── examples/
│ │ ├── dkim_signing/
│ │ │ ├── email1.msg
│ │ │ └── email2.msg
│ │ └── full_legacy_config_file.yml
│ ├── factories/
│ │ ├── address_endpoint_factory.rb
│ │ ├── credential_factory.rb
│ │ ├── domain_factory.rb
│ │ ├── http_endpoint_factory.rb
│ │ ├── ip_address_factory.rb
│ │ ├── ip_pool_factory.rb
│ │ ├── ip_pool_rule_factory.rb
│ │ ├── organization_factory.rb
│ │ ├── queued_message_factory.rb
│ │ ├── route_factory.rb
│ │ ├── server_factory.rb
│ │ ├── smtp_endpoint_factory.rb
│ │ ├── track_domain_factory.rb
│ │ ├── user_factory.rb
│ │ ├── webhook_factory.rb
│ │ ├── webhook_request_factory.rb
│ │ └── worker_role_factory.rb
│ ├── helpers/
│ │ ├── general_helpers.rb
│ │ ├── message_db_mocking.rb
│ │ ├── message_factory.rb
│ │ └── test_logger.rb
│ ├── lib/
│ │ ├── dkim_header_spec.rb
│ │ ├── dns_resolver_spec.rb
│ │ ├── message_dequeuer/
│ │ │ ├── base_spec.rb
│ │ │ ├── incoming_message_processor_spec.rb
│ │ │ ├── initial_message_processor_spec.rb
│ │ │ ├── outgoing_message_processor_spec.rb
│ │ │ ├── single_message_processor_spec.rb
│ │ │ └── state_spec.rb
│ │ ├── message_dequeuer_spec.rb
│ │ ├── postal/
│ │ │ ├── legacy_config_source_spec.rb
│ │ │ ├── message_db/
│ │ │ │ ├── connection_pool_spec.rb
│ │ │ │ └── database_spec.rb
│ │ │ ├── message_parser_spec.rb
│ │ │ └── signer_spec.rb
│ │ ├── postal_spec.rb
│ │ ├── query_string_spec.rb
│ │ ├── received_header_spec.rb
│ │ ├── smtp_client/
│ │ │ ├── endpoint_spec.rb
│ │ │ └── server_spec.rb
│ │ ├── smtp_server/
│ │ │ ├── client/
│ │ │ │ ├── auth_spec.rb
│ │ │ │ ├── data_spec.rb
│ │ │ │ ├── finished_spec.rb
│ │ │ │ ├── helo_spec.rb
│ │ │ │ ├── mail_from_spec.rb
│ │ │ │ ├── proxy_spec.rb
│ │ │ │ └── rcpt_to_spec.rb
│ │ │ └── client_spec.rb
│ │ └── worker/
│ │ └── jobs/
│ │ ├── process_queued_messages_job_spec.rb
│ │ └── process_webhook_requests_job_spec.rb
│ ├── models/
│ │ ├── domain_spec.rb
│ │ ├── organization_spec.rb
│ │ ├── outgoing_message_prototype_spec.rb
│ │ ├── queued_message_spec.rb
│ │ ├── server_spec.rb
│ │ ├── user/
│ │ │ ├── authentication_spec.rb
│ │ │ └── oidc_spec.rb
│ │ ├── user_spec.rb
│ │ └── worker_role_spec.rb
│ ├── rails_helper.rb
│ ├── scheduled_tasks/
│ │ └── tidy_queued_messages_task_spec.rb
│ ├── senders/
│ │ └── smtp_sender_spec.rb
│ ├── services/
│ │ └── webhook_delivery_service_spec.rb
│ └── spec_helper.rb
├── tmp/
│ └── .keep
└── vendor/
└── assets/
├── javascripts/
│ └── .keep
└── stylesheets/
└── .keep
================================================
FILE CONTENTS
================================================
================================================
FILE: .dockerignore
================================================
.byebug_history
.cache
.git/*
.github/*
.vscode/*
.yardoc/*
/.bundle
config/postal/*
doc/*
Dockerfile
log/*
node_modules
Procfile.local
Procfile*
public/assets
storage/*
tmp/*
vendor/bundle
vendor/bundle
================================================
FILE: .github/ISSUE_TEMPLATE/bug_report.md
================================================
---
name: 🐛 Bug report
about: Create a report to help us improve Postal and fix issues.
title: ''
labels: ''
assignees: ''
---
## Describe the bug
A clear and concise description of what the bug is.
## To Reproduce
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
## Expected behaviour
A clear and concise description of what you expected to happen.
## Screenshots
If applicable, add screenshots to help explain your problem.
## Environment details
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
- Type [e.g. desktop, mobile etc...]
## Additional information/context
Add any other context about the problem here. It is particularily useful to include log extracts (after removing private information).
================================================
FILE: .github/ISSUE_TEMPLATE/config.yml
================================================
blank_issues_enabled: false
contact_links:
- name: 💻 Installation help
url: https://github.com/postalhq/postal/discussions/new?category=Installation-help
about: If you have questions about running Postal on your servers, use GitHub Discussions.
- name: 🙏 Help with using Postal
url: https://github.com/postalserver/postal/discussions/new?category=Help-with-using-Postal
about: If you need help using Postal's features, use GitHub Discussions.
- name: 🦊 Feature Suggestions
url: https://github.com/postalhq/postal/discussions/new?category=Feature-Suggestions
about: Suggest a new feature that should be added to Postal.
================================================
FILE: .github/workflows/ci.yml
================================================
---
name: CI
on: [push]
jobs:
release-please:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
outputs:
release_created: ${{ steps.release-please.outputs.release_created }}
tag_name: ${{ steps.release-please.outputs.tag_name }} # e.g. v1.0.0
version: ${{ steps.release-please.outputs.version }} # e.g. 1.0.0
all: ${{ toJSON(steps.release-please.outputs) }}
steps:
- uses: google-github-actions/release-please-action@v3
id: release-please
with:
command: manifest
build:
name: CI Image Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v4
with:
push: true
tags: ghcr.io/postalserver/postal:ci-${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
target: ci
platforms: linux/amd64
test:
name: Test Suite
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: docker compose pull
env:
POSTAL_IMAGE: ghcr.io/postalserver/postal:ci-${{ github.sha }}
- run: docker compose run postal sh -c 'bundle exec rspec'
env:
POSTAL_IMAGE: ghcr.io/postalserver/postal:ci-${{ github.sha }}
release-branch:
name: Release (branch)
runs-on: ubuntu-latest
needs: [build]
if: >-
startsWith(github.ref, 'refs/heads/') &&
startsWith(github.ref, 'refs/heads/release-please-') != true &&
startsWith(github.ref, 'refs/heads/dependabot/') != true
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: info
run: |
IMAGE=ghcr.io/postalserver/postal
REF="${GITHUB_REF#refs/heads/}"
if [ -z "$REF" ]; then exit 1; fi
VER="$(git describe --tags 2>/dev/null)"
echo "version=${VER}" >> "$GITHUB_OUTPUT"
echo "branch=${REF}" >> "$GITHUB_OUTPUT"
echo 'tags<<EOF' >> "$GITHUB_OUTPUT"
if [[ "$REF" == "main" ]]; then
echo "${IMAGE}:latest" >> "$GITHUB_OUTPUT"
else
echo "${IMAGE}:branch-${REF}" >> "$GITHUB_OUTPUT"
fi
echo 'EOF' >> "$GITHUB_OUTPUT"
- uses: docker/build-push-action@v4
with:
push: true
tags: ${{ steps.info.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
target: full
platforms: linux/amd64
build-args: |
VERSION=${{ steps.info.outputs.version }}
BRANCH=${{ steps.info.outputs.branch }}
publish-image:
name: Publish Image
runs-on: ubuntu-latest
needs: [build, test, release-please]
if: ${{ needs.release-please.outputs.release_created }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v4
with:
push: true
tags: |
ghcr.io/postalserver/postal:stable
ghcr.io/postalserver/postal:${{ needs.release-please.outputs.version }}
cache-from: type=gha
cache-to: type=gha,mode=max
target: full
build-args: |
VERSION=${{ needs.release-please.outputs.version }}
platforms: linux/amd64
================================================
FILE: .github/workflows/close.yml
================================================
name: 'Close stale issues and PRs'
on:
schedule:
- cron: '30 1 * * *'
workflow_dispatch:
permissions:
issues: write
pull-requests: write
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v9
with:
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.'
stale-pr-message: 'This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.'
close-issue-message: 'This issue was closed because it has been stalled for 5 days with no activity.'
close-pr-message: 'This PR was closed because it has been stalled for 10 days with no activity.'
stale-issue-label: stale
stale-pr-label: stale
days-before-issue-stale: 30
days-before-pr-stale: 45
days-before-issue-close: 5
days-before-pr-close: 10
exempt-all-assignees: true
exempt-all-milestones: true
exempt-issue-labels: bug,enhancement,docs,install,feature
================================================
FILE: .gitignore
================================================
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'
# Ignore bundler config.
/.bundle
# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep
# Ignore Byebug command history file.
.byebug_history
config/postal.yml
config/smtp.cert
config/smtp.key
config/signing.key
config/postal/**/*
spec/config/postal.local.yml
public/assets
vendor/bundle
Procfile.local
VERSION
BRANCH
.rubocop-https*
.env*
================================================
FILE: .release-please-manifest.json
================================================
{
".": "3.3.5"
}
================================================
FILE: .rubocop.yml
================================================
AllCops:
TargetRubyVersion: 3.0
NewCops: enable
Exclude:
- "bin/*"
- "db/schema.rb"
# Fixes missing gem exception when running Rubocop on GitHub Actions.
- "vendor/bundle/**/*"
- lib/tasks/auto_annotate_models.rake
# Always use double quotes
Style/StringLiterals:
EnforcedStyle: double_quotes
AutoCorrect: true
# We prefer arrays of symbols to look like an array of symbols.
# For example: [:one, :two, :three] as opposed to %i[one two three]
Style/SymbolArray:
EnforcedStyle: brackets
# There should always be empty lines inside a class. For example
#
# class MyExample
#
# def some_method
# end
#
# end
Layout/EmptyLinesAroundClassBody:
EnforcedStyle: empty_lines
# We want to keep attr_* definitions separated on their own lines, rather than
# all of them collapsed into a single attr_* call. The collapsed/grouped variant
# is harder to read, and harder to see what's been changed in diffs.
Style/AccessorGrouping:
Enabled: false
# Blocks are slightly different to classes, in these cases there should
# not be new lines around the contents of the block.
#
# proc do
# # Do something
# end
Layout/EmptyLinesAroundBlockBody:
EnforcedStyle: no_empty_lines
# Modules are the same as classes unless they're being used for namespacing
# purposes in which case there should not be new lines.
Layout/EmptyLinesAroundModuleBody:
EnforcedStyle: empty_lines_except_namespace
# Space is required following -> when writing a lambda:
#
# somethign = -> (var) { block }
Layout/SpaceInLambdaLiteral:
EnforcedStyle: require_space
Layout/FirstHashElementIndentation:
Enabled: false
# We don't mind setting assignments in conditions so this has been disabled to
# allow `if something = something_else` without worrying about brackets.
Lint/AssignmentInCondition:
Enabled: false
# Top level documentation is quite rare...
Style/Documentation:
Enabled: false
# We want to allow inner slashes in a regexp to be used when using /xxx/ form.
Style/RegexpLiteral:
AllowInnerSlashes: true
# Blocks of if statements are perfectly fine and usually more readable than
# putting everything onto a single line just because we can.
Style/IfUnlessModifier:
Enabled: false
# We prefer assignments to happen within the condition rather than setting a
# variable to the result of a condition.
Style/ConditionalAssignment:
EnforcedStyle: assign_inside_condition
IncludeTernaryExpressions: false
# Empty methods should not be compacted onto a single line
Style/EmptyMethod:
EnforcedStyle: expanded
# As above, just flag them.
Lint/UnusedBlockArgument:
AutoCorrect: false
# While we don't want to make heavy use of get_ or set_ methods we do often need
# to use these when we want to refer to actually getting or setting something
# (usually from another API).
Naming/AccessorMethodName:
Enabled: false
# If we want a boolean called :true, we should be allowed that. These are likely
# not mistakes.
Lint/BooleanSymbol:
Enabled: false
# Using block.map(&:upcase) is not always the neatest way to show something. For
# example if you have a block that just calls one thing, you don't want it
# collapsed.
#
# action do |user|
# user.delete
# end
#
# This should be action(&:delete) because it is not clear what is actually
# happening without the context of knowing what the inner variable should be
# called.
Style/SymbolProc:
Enabled: false
# Allow a maxmium of 5 arguments and don't include keyword arguments
Metrics/ParameterLists:
Max: 5
CountKeywordArgs: false
# This cop checks for chaining of a block after another block that spans multiple lines.
Style/MultilineBlockChain:
Exclude:
- "spec/**/*.rb"
Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: consistent_comma
Metrics/AbcSize:
Enabled: false
Style/FrozenStringLiteralComment:
Enabled: true
SafeAutoCorrect: true
Naming/PredicateName:
Enabled: false
Layout/LineLength:
# We want to reduce this back down to 120 but there are a fair number of offences
# of this which need addressing individually and carefully.
Max: 200
Metrics/PerceivedComplexity:
# As above, we want to enable this again in the future, but for now we'll just
# disable it entirely.
Enabled: false
Metrics/CyclomaticComplexity:
# As above.
Enabled: false
Metrics/MethodLength:
# As above.
Enabled: false
Metrics/BlockNesting:
# As above.
Enabled: false
Style/StringConcatenation:
Enabled: false
Metrics/BlockLength:
Enabled: false
Metrics/ClassLength:
Enabled: false
Metrics/ModuleLength:
Enabled: false
Lint/UnusedMethodArgument:
Enabled: false
Style/SpecialGlobalVars:
Enabled: false
================================================
FILE: .ruby-version
================================================
3.4.6
================================================
FILE: CHANGELOG.md
================================================
# CHANGELOG
This file contains all the latest changes and updates to Postal.
## [3.3.5](https://github.com/postalserver/postal/compare/3.3.4...3.3.5) (2026-02-01)
### Bug Fixes
* **deliveries:** escape delivery details to prevent HTML injection ([11419f9](https://github.com/postalserver/postal/commit/11419f99140e13688a9613cab3ee03f8d3cbae45))
* **health_server:** use rackup handler instead of rack handler ([7c47422](https://github.com/postalserver/postal/commit/7c47422c865e738c4d6af0fed1cca4405288341f))
* oidc scopes are invalid when concatenated ([#3332](https://github.com/postalserver/postal/issues/3332)) ([9c5f96a](https://github.com/postalserver/postal/commit/9c5f96ae90cf06dcd5db776806865752f667bd95))
* typo in process logging ([#3212](https://github.com/postalserver/postal/issues/3212)) ([b7e5232](https://github.com/postalserver/postal/commit/b7e5232e077b3c9b7a999dcb6676fba0ec61458e))
* typo in the credentials page ([fd3c7cc](https://github.com/postalserver/postal/commit/fd3c7ccdf6dc4ee0a76c9523cbd735159e4b8000))
* update url for v2 config ([#3225](https://github.com/postalserver/postal/issues/3225)) ([e00098b](https://github.com/postalserver/postal/commit/e00098b8003cf37f2708f536871b3ade377aed2d))
### Documentation
* **process.rb:** add help about time unit used by metric ([#3339](https://github.com/postalserver/postal/issues/3339)) ([f5325c4](https://github.com/postalserver/postal/commit/f5325c49ff1152ad53eaaec98717ad3412d379ae))
### Miscellaneous Chores
* **deps:** upgrade puma, net-imap and other deps ([c03c44b](https://github.com/postalserver/postal/commit/c03c44b442a29aa9881c1e1aae60bead9776a6b6))
* **dockerfile:** reduce container size ([86de372](https://github.com/postalserver/postal/commit/86de372382bd62bdd5d1372254f8817b0360bd56))
* remove version from docker-compose.yml ([c78000c](https://github.com/postalserver/postal/commit/c78000ca8f2998aa04648f465060768db6467de6))
* upgrade resolv to 0.6.2 ([d00d978](https://github.com/postalserver/postal/commit/d00d978872a96369544303d08f6a9d11cdf56b62))
* upgrade to rails 7.1 and ruby 3.4 ([#3457](https://github.com/postalserver/postal/issues/3457)) ([ab6d443](https://github.com/postalserver/postal/commit/ab6d4430baa33a05f1aa66e776cc2a5bcaa0ede8))
* upgrade uri gem to 1.0.3 ([f193b8e](https://github.com/postalserver/postal/commit/f193b8e77fc096382ab7aaa6a2c29641b4cb12df))
## [3.3.4](https://github.com/postalserver/postal/compare/3.3.3...3.3.4) (2024-06-20)
### Bug Fixes
* fix `postal version` command ([4fa88ac](https://github.com/postalserver/postal/commit/4fa88acea0dececd0eae485506a2ad8268fbea59))
* fix issue running message pruning task ([3a33e53](https://github.com/postalserver/postal/commit/3a33e53d843584757bb00898746aa059d7616db4))
* raise NotImplementedError when no call method on a scheduled task ([2b0919c](https://github.com/postalserver/postal/commit/2b0919c1454eabea93db96f50ecbd8e36bb89f1f))
## [3.3.3](https://github.com/postalserver/postal/compare/3.3.2...3.3.3) (2024-04-18)
### Bug Fixes
* **legacy-api:** allow _expansions to be provided as true to return all expansions ([39f704c](https://github.com/postalserver/postal/commit/39f704c256fc3e71a1dc009acc77796a1efffead)), closes [#2932](https://github.com/postalserver/postal/issues/2932)
## [3.3.2](https://github.com/postalserver/postal/compare/3.3.1...3.3.2) (2024-03-21)
### Code Refactoring
* **versioning:** improve how current version and branch is determined and set ([07c6b31](https://github.com/postalserver/postal/commit/07c6b317f2b9dc04b6a8c88df1e6aa9e54597504))
## [3.3.1](https://github.com/postalserver/postal/compare/3.3.0...3.3.1) (2024-03-21)
### Bug Fixes
* **smtp-sender:** ensure relays without a host are excluded ([3a56ec8](https://github.com/postalserver/postal/commit/3a56ec8a74950e0162d98f1af5f58a67a82d6455))
* **smtp-sender:** fixes `SMTPSender.smtp_relays` ([b3264b9](https://github.com/postalserver/postal/commit/b3264b942776e254d3c351c94c435d172a514e18))
### Miscellaneous Chores
* **container:** add the branch name to the container ([bee5098](https://github.com/postalserver/postal/commit/bee509832edc151d97fe5bfc48c4973452873fc8))
* **github-actions:** don't generate commit- tags ([d65bbe0](https://github.com/postalserver/postal/commit/d65bbe0579037c5df962a18134bc007f5159d7e5))
* **github-actions:** don't run for dependabot or release-please PRs and fetch whole repo ([adaf2b0](https://github.com/postalserver/postal/commit/adaf2b07502e9ed91290873ad8465051c6fd814f))
* **github-actions:** include a version string on branch-*/latest images ([64bc7dc](https://github.com/postalserver/postal/commit/64bc7dcf7c0a8e006ab6eb6e8b4a52ad5e7e6528))
* **ui:** display branch in footer if present ([1823617](https://github.com/postalserver/postal/commit/18236171ebc398c157f2e61b15c7df9f91205284))
### Code Refactoring
* remove moonrope but maintain legacy API actions ([#2889](https://github.com/postalserver/postal/issues/2889)) ([4d9654d](https://github.com/postalserver/postal/commit/4d9654dac47d59c760be96388d0421de74d3e6ac))
## [3.3.0](https://github.com/postalserver/postal/compare/3.2.2...3.3.0) (2024-03-18)
### Features
* **prometheus:** add `postal_message_queue_latency` metric ([ee8d829](https://github.com/postalserver/postal/commit/ee8d829a854f91e476167869cafe35c2d37bb314))
* **worker:** allow number of threads to be configured ([7e2accc](https://github.com/postalserver/postal/commit/7e2acccd1ebd80750a3ebdb96cb5c36b5263cc24))
* **worker:** scale connection pool with worker threads ([ea542a0](https://github.com/postalserver/postal/commit/ea542a0694b3465b04fd3ebc439837df414deb1e))
### Bug Fixes
* **message-dequeuer:** ability to disable batching ([4fcb9e9](https://github.com/postalserver/postal/commit/4fcb9e9a2e34be5aa4bdf13f0529f40e564b72b4))
### Miscellaneous Chores
* **config-docs:** update docs for latest oidc defaults ([364eba6](https://github.com/postalserver/postal/commit/364eba6c5fce2f08a36489f42856ad5024a2062c))
* **config-docs:** update proxy protocol to mention v1 ([45dd8aa](https://github.com/postalserver/postal/commit/45dd8aaac56f15481cb7bf9081401cb28dc1e707))
## [3.2.2](https://github.com/postalserver/postal/compare/3.2.1...3.2.2) (2024-03-14)
### Bug Fixes
* don't use authentication on org & server deletion ([be45652](https://github.com/postalserver/postal/commit/be456523dd3aacb5c3eb45c9261da97ebffe603c))
* **smtp-server:** fixes proxy protocol ([9240612](https://github.com/postalserver/postal/commit/92406129cfcf1a06499a6f5aa18c73f1d6195793))
### Miscellaneous Chores
* allow config location message to be suppressed ([f760cdb](https://github.com/postalserver/postal/commit/f760cdb5a1d53e9c30ee495d129cbf12603a3cbd))
* hide further config messages ([1c67f72](https://github.com/postalserver/postal/commit/1c67f72209c93404d7024ce3d15f6f54f2d707c4))
* suppress config location on default-dkim-record ([aa76aae](https://github.com/postalserver/postal/commit/aa76aae2322af41af1bd60cfe1d69a11ac76324e))
### Tests
* add tests for the legacy API ([3d208d6](https://github.com/postalserver/postal/commit/3d208d632f4fc8a4adbfdb2bf4b377271eae6692))
## [3.2.1](https://github.com/postalserver/postal/compare/3.2.0...3.2.1) (2024-03-13)
### Bug Fixes
* fixes `postal default-dkim-record` ([58dddeb](https://github.com/postalserver/postal/commit/58dddebeb81dc6fab945d2b10a91588eddc471c2))
## [3.2.0](https://github.com/postalserver/postal/compare/3.1.1...3.2.0) (2024-03-13)
### Features
* add sha256 signatures to outgoing http requests ([#2874](https://github.com/postalserver/postal/issues/2874)) ([96d7365](https://github.com/postalserver/postal/commit/96d73653d7cb4dde1fbe74ccb3596147ef8cd9ed))
* automatically remove queued messages with stale locks ([#2872](https://github.com/postalserver/postal/issues/2872)) ([d84152e](https://github.com/postalserver/postal/commit/d84152eb5df6f963426d6ba8d02d39b3c146c8a5))
* openid connect support ([#2873](https://github.com/postalserver/postal/issues/2873)) ([5ed94f6](https://github.com/postalserver/postal/commit/5ed94f6f855735aa00544b2574dfb9e65d559a38))
### Bug Fixes
* **smtp-server:** add additional information to cram-md5 log entries ([9982bb8](https://github.com/postalserver/postal/commit/9982bb8c31ee4885d188666e2e8afdc218528df7))
### Styles
* **rubocop:** Style/TrailingCommaInArrayLiteral ([4e13577](https://github.com/postalserver/postal/commit/4e13577891dc827244abc6bf6d9ab4ee45860556))
### Miscellaneous Chores
* regenerate config docs ([5d8213a](https://github.com/postalserver/postal/commit/5d8213a98735f07fdf1700c7d01597654f41dbd0))
## [3.1.1](https://github.com/postalserver/postal/compare/3.1.0...3.1.1) (2024-03-08)
### Bug Fixes
* don't override paths in dockerfile ([9399e32](https://github.com/postalserver/postal/commit/9399e3223467cdacd010e70b58ad6093e128213d))
### Tests
* **smtp-sender:** add more tests for AUTH LOGIN ([22dcd49](https://github.com/postalserver/postal/commit/22dcd4901f188915cf4b3c758c6f2fc637a4e1e3))
## [3.1.0](https://github.com/postalserver/postal/compare/3.0.2...3.1.0) (2024-03-06)
### Features
* configurable trusted proxies for web requests ([3785c99](https://github.com/postalserver/postal/commit/3785c998513c634d225b489ccb43e926ce3f270a))
### Bug Fixes
* **message-dequeuer:** ensure SMTP endpoints are sent to SMTP sender appropriately ([e2d642c](https://github.com/postalserver/postal/commit/e2d642c0cbf443550886d90abc3a6edf3e4bc4fc)), closes [#2853](https://github.com/postalserver/postal/issues/2853)
* **smtp-server:** listen on all interfaces by default ([d1e5b68](https://github.com/postalserver/postal/commit/d1e5b68200ea4b9710cc8714afb3271bad1f4f66)), closes [#2852](https://github.com/postalserver/postal/issues/2852)
* **smtp-server:** remove ::ffff: from the start of ipv4 addresses ([0dc7359](https://github.com/postalserver/postal/commit/0dc7359431001c9ef1222913f8d1344093397596))
* **smtp-server:** reset ansi sequence after logging ([9bf6152](https://github.com/postalserver/postal/commit/9bf6152060ffb8b611b66818c1d1ac7c929b7ffe))
* **ui:** fixes typo on queue page ([33513a7](https://github.com/postalserver/postal/commit/33513a77c0df24d832ab7ed5237d68e2b1bde887))
* **web-server:** allow for trusted proxies not be set ([4e1deb2](https://github.com/postalserver/postal/commit/4e1deb2d2aeb61d9dddb3729916411c94e73c1c6))
### Styles
* **rubocop:** use _ when not using a variable in helm config exporter ([2c20ba6](https://github.com/postalserver/postal/commit/2c20ba65f64ccb0f8174e3f523dedb3806478782))
## [3.0.2](https://github.com/postalserver/postal/compare/3.0.1...3.0.2) (2024-03-05)
### Bug Fixes
* default to listening on all addresses when using legacy config ([48f6494](https://github.com/postalserver/postal/commit/48f6494240eb0374d5f865425b362e6f306b2653))
### Miscellaneous Chores
* removing arm64 support until we can get a reasonable build pipeline sorted ([e8e44f5](https://github.com/postalserver/postal/commit/e8e44f54b09426c8a04e466bc037851a0833d124))
## [3.0.1](https://github.com/postalserver/postal/compare/3.0.0...3.0.1) (2024-03-05)
### Bug Fixes
* fix issue with sending mail when smtp relays are configured ([6dd6e29](https://github.com/postalserver/postal/commit/6dd6e29929c70eaa8b9d3b33c184996b0b6abb82))
## [3.0.0](https://github.com/postalserver/postal/compare/2.3.2...3.0.0) (2024-03-04)
This version of Postal introduces a number of larger changes. Please be sure to follow the [upgrade guide](https://docs.postalserver.io/getting-started/upgrade-to-v3) when upgrading to Postal v3. Highlights include:
* Removal of RabbitMQ dependency
* Removal of `cron` and `requeuer` processes
* Improved logging
* Improved configuration
* Adds prometheus metric exporters for workers and SMTP servers
* Only accepted RFC-compliant end-of-DATA sequences (to avoid SMTP smuggling)
### Features
* add health server and prometheus metrics to worker ([a2eb70e](https://github.com/postalserver/postal/commit/a2eb70e))
* add option to delay starting processes until all migrations are run ([1c5ff5a](https://github.com/postalserver/postal/commit/1c5ff5a))
* add prometheus metrics to smtp server ([2e7b36c](https://github.com/postalserver/postal/commit/2e7b36c))
* add prometheus metrics to worker ([bea7450](https://github.com/postalserver/postal/commit/bea7450))
* more consistent logging ([044058d](https://github.com/postalserver/postal/commit/044058d))
* new background work process ([dc8e895](https://github.com/postalserver/postal/commit/dc8e895))
* new configuration system (and schema) (#2819) ([0163ac3](https://github.com/postalserver/postal/commit/0163ac3))
* only accept RFC-compliant End-of-DATA sequence ([0140dc4](https://github.com/postalserver/postal/commit/0140dc4))
* add "postal:update" task ([b35eea6](https://github.com/postalserver/postal/commit/b35eea6338f1888bfac2ed377d0a412680483e90))
* add helm env var config exporter ([8938988](https://github.com/postalserver/postal/commit/893898835dcd9684ae3401549389b173a3feb1fb))
* include list-unsubscribe-post header in dkim signatures ([e1bae60](https://github.com/postalserver/postal/commit/e1bae60768c4cf151d5a6a141985c78753dce02d)), closes [#2789](https://github.com/postalserver/postal/issues/2789) [#2788](https://github.com/postalserver/postal/issues/2788)
* support for additional SMTP client options ([0daa667](https://github.com/postalserver/postal/commit/0daa667b55fd9b948da643d37ec438e341809369))
### Bug Fixes
* fixes potential issue if machine hostname cannot be determined ([0fcf778](https://github.com/postalserver/postal/commit/0fcf778))
* raise an error if MX lookup times out during sending ([fadca88](https://github.com/postalserver/postal/commit/fadca88)), closes [#2833](https://github.com/postalserver/postal/issues/2833)
* set correct component in health server log lines ([a7a9a18](https://github.com/postalserver/postal/commit/a7a9a18))
* translate unicode domain names to Punycode for compatibility with DNS (#2823) ([be0df7b](https://github.com/postalserver/postal/commit/be0df7b))
* remove user email verification ([e05f0b3](https://github.com/postalserver/postal/commit/e05f0b3616da8b962b763c48a2139882fd88047a))
* unescape in URLs which are stored for tracking ([1da1182](https://github.com/postalserver/postal/commit/1da1182c23e9673d8f109d8ed29e80983cdccabf)), closes [#2568](https://github.com/postalserver/postal/issues/2568) [#907](https://github.com/postalserver/postal/issues/907) [#115](https://github.com/postalserver/postal/issues/115)
* update wording about tracking domain cnames ([0d3eccb](https://github.com/postalserver/postal/commit/0d3eccb368630b4fd21bd858a7829ec00c35f153)), closes [#2808](https://github.com/postalserver/postal/issues/2808)
### Documentation
* add message_db.encoding to config docs ([0c1f925](https://github.com/postalserver/postal/commit/0c1f925))
* add new repo readme welcome image ([afa1726](https://github.com/postalserver/postal/commit/afa1726))
* add quick contributing instructions ([8d21adc](https://github.com/postalserver/postal/commit/8d21adc))
* update SECURITY policy ([cfc1c9b](https://github.com/postalserver/postal/commit/cfc1c9b))
* update docs for how IP address allocation works ([07eb152](https://github.com/postalserver/postal/commit/07eb152)), closes [#2209](https://github.com/postalserver/postal/issues/2209)
### Miscellaneous Chores
* upgrade bundler to 2.5.6 ([1ae8ef6](https://github.com/postalserver/postal/commit/1ae8ef6))
* upgrade rails to 7.0 and other dependencies ([ecd09a2](https://github.com/postalserver/postal/commit/ecd09a2))
* upgrade ruby to 3.2.2 and nodejs to 20.x ([72715fe](https://github.com/postalserver/postal/commit/72715fe))
## [2.3.2](https://github.com/postalserver/postal/compare/2.3.1...2.3.2) (2024-03-01)
### Bug Fixes
* truncate output and details in deliveries to 250 characters ([694240d](https://github.com/postalserver/postal/commit/694240ddcdef1df9b32888de8fb743d2dee86462)), closes [#2831](https://github.com/postalserver/postal/issues/2831)
## [2.3.1](https://github.com/postalserver/postal/compare/2.3.0...2.3.1) (2024-02-23)
### Bug Fixes
* update raw headers after changing messages to during parsing ([2834e2c](https://github.com/postalserver/postal/commit/2834e2c37971db9b0b0498e38b382cf1f8ee26eb)), closes [#2816](https://github.com/postalserver/postal/issues/2816)
### Miscellaneous Chores
* **github-actions:** add 'docs' label to exclude from staleness checks ([57b72fb](https://github.com/postalserver/postal/commit/57b72fb4b7f7fc934cfa23906de65b8f6d6d1978))
* **github-actions:** add action to close stale issues and PRs ([d90a456](https://github.com/postalserver/postal/commit/d90a456dfa661d87e820160d2045c73c765564d2))
* **github-actions:** allow stale action to be run on demand ([559b08d](https://github.com/postalserver/postal/commit/559b08ddd31ecd904fd09c1e2822161b853166b9))
## [2.3.0](https://github.com/postalserver/postal/compare/2.2.2...2.3.0) (2024-02-13)
### Features
* privacy mode ([15f9671](https://github.com/postalserver/postal/commit/15f9671b667cf369255aaa27ee4257267990095c))
* remove strip_received_headers config option ([ed2e62b](https://github.com/postalserver/postal/commit/ed2e62b94fe76d7aeca0ede98f11a1c4f94c5996))
### Bug Fixes
* add ruby platform to gemfile ([1fceef7](https://github.com/postalserver/postal/commit/1fceef7cea76352fd6166fb3f1e8d0ff8591078e))
* explicitly disable TLS & starttls for unknown SSL modes ([42ab5b3](https://github.com/postalserver/postal/commit/42ab5b3a6b21992c89f8479137699dc9090f0ccc)), closes [#2564](https://github.com/postalserver/postal/issues/2564)
* fix bug with received header in SMTP server ([ba5bfbd](https://github.com/postalserver/postal/commit/ba5bfbd6a0af9ea33bedb2948822417bd1a3fbc5))
* retry mysql connections on message DB pool ([f9f7fb3](https://github.com/postalserver/postal/commit/f9f7fb30fee46b661b6dccde4362383ea591532b))
* use correct method for disconnecting smtp connections ([7c23994](https://github.com/postalserver/postal/commit/7c23994d243ec7d9a17ee053f8c3fa8de0a33097))
### Styles
* **rubocop:** disable complexity cops for now ([930cf39](https://github.com/postalserver/postal/commit/930cf39dba37401f90e293c938dee07daf3d9a31))
* **rubocop:** disable Style/SpecialGlobalVars ([be97f43](https://github.com/postalserver/postal/commit/be97f4330897f96085eb29ed7019b1a3e50af88e))
* **rubocop:** disable Style/StringConcatenation cop ([d508772](https://github.com/postalserver/postal/commit/d508772a40ef26e5c3a8304aa1f2b8c7985081bd))
* **rubocop:** Layout/* ([0e0aca0](https://github.com/postalserver/postal/commit/0e0aca06c90f6d2f4db1c4090a35c4537c76e13a))
* **rubocop:** Layout/EmptyLineAfterMagicComment ([0e4ed5c](https://github.com/postalserver/postal/commit/0e4ed5ca0393f9a56e1efa7ae377d2e4b876bfe1))
* **rubocop:** Layout/EmptyLines ([0cf35a8](https://github.com/postalserver/postal/commit/0cf35a83926d499a279775bcc32dd4ea79b7a8c9))
* **rubocop:** Layout/EmptyLinesAroundBlockBody ([cfd8d63](https://github.com/postalserver/postal/commit/cfd8d63321d1821aad7fa9d6b8462c3d551aca61))
* **rubocop:** Layout/LeadingCommentSpace ([59f299b](https://github.com/postalserver/postal/commit/59f299b704533488b74075beb8692397eb434aab))
* **rubocop:** Layout/LineLength ([e142d0d](https://github.com/postalserver/postal/commit/e142d0da5fbee19e6f9f1741ff9dee0a2d7dd169))
* **rubocop:** Layout/MultilineMethodCallBraceLayout ([a5d5ba5](https://github.com/postalserver/postal/commit/a5d5ba5326728413bb95456e92c854977d225a7f))
* **rubocop:** Lint/DuplicateBranch ([a1dc0f7](https://github.com/postalserver/postal/commit/a1dc0f77ac69937d7f30c9401608dfbe66987d45))
* **rubocop:** Lint/DuplicateMethods ([bab6346](https://github.com/postalserver/postal/commit/bab6346239e4f50bdd51101c45f3a0cd66f47096))
* **rubocop:** Lint/IneffectiveAccessModifier ([6ad56ee](https://github.com/postalserver/postal/commit/6ad56ee9c9e5bad19b065fcec3ada3280adbb1f4))
* **rubocop:** Lint/MissingSuper ([4674e63](https://github.com/postalserver/postal/commit/4674e63b5ff84307f5b772e870e88109af2daf52))
* **rubocop:** Lint/RedundantStringCoercion ([12a5ef3](https://github.com/postalserver/postal/commit/12a5ef3279bf6c1e5c38bf7e846de1d17bf98c09))
* **rubocop:** Lint/ShadowedException ([0966b44](https://github.com/postalserver/postal/commit/0966b44018bc1e2f131358635776fcc3b75ee8eb))
* **rubocop:** Lint/ShadowingOuterLocalVariable ([7119e86](https://github.com/postalserver/postal/commit/7119e8642dffeee7a27f90145073e45664ea58d3))
* **rubocop:** Lint/SuppressedException ([278ef08](https://github.com/postalserver/postal/commit/278ef0886ac53e6bed15793301dc69c95a37dbde))
* **rubocop:** Lint/UnderscorePrefixedVariableName ([ec7dcf4](https://github.com/postalserver/postal/commit/ec7dcf4f9a0bdb367a90f1a3b35336909ebc60d7))
* **rubocop:** Lint/UnusedBlockArgument ([ee94e4e](https://github.com/postalserver/postal/commit/ee94e4e1a013bbe8fbdd8ef94f15ed0fa20709ac))
* **rubocop:** Lint/UselessAssignment ([7590a46](https://github.com/postalserver/postal/commit/7590a462341bddd412e660db9546ba1909aea9d7))
* **rubocop:** Naming/FileName ([919a601](https://github.com/postalserver/postal/commit/919a60116c5d81ed787061ff4614da4f1e067d4e))
* **rubocop:** Naming/MemoizedInstanceVariableName ([9563f30](https://github.com/postalserver/postal/commit/9563f30c96fba12073e845319b8d79a542d88109))
* **rubocop:** relax method length and block nexting for now ([b0ac9ef](https://github.com/postalserver/postal/commit/b0ac9ef0b96ab78c2961f45b6e9f20f87a6f1d07))
* **rubocop:** remaining offences ([ec63666](https://github.com/postalserver/postal/commit/ec636661d5c4b9e8f48e6f263ffef834acb68b39))
* **rubocop:** Security/YAMLLoad ([389ea77](https://github.com/postalserver/postal/commit/389ea7705047bf8700836137514b2497af3c6c01))
* **rubocop:** Style/AndOr ([b9f3f31](https://github.com/postalserver/postal/commit/b9f3f313f8ec992917bad3a51f0481f89675e935))
* **rubocop:** Style/ClassAndModuleChildren ([e896f46](https://github.com/postalserver/postal/commit/e896f4689a8fc54979f0a6c2b7ce14746856bad6))
* **rubocop:** Style/For ([04a3483](https://github.com/postalserver/postal/commit/04a34831c74a3a44547f93100c35db650bc4eef6))
* **rubocop:** Style/FrozenStringLiteralComment ([6ab36c0](https://github.com/postalserver/postal/commit/6ab36c09c966eb9a8b8ada52155f74d2537977f2))
* **rubocop:** Style/GlobalStdStream ([75be690](https://github.com/postalserver/postal/commit/75be6907483ea25f828461eb790d3f6f46ca683b))
* **rubocop:** Style/GlobalVars ([157d114](https://github.com/postalserver/postal/commit/157d11457c520147807901b75b3ba22d29172f24))
* **rubocop:** Style/HashEachMethods ([c995027](https://github.com/postalserver/postal/commit/c995027ff53962ae49341372f75e2bf43ecde0d2))
* **rubocop:** Style/HashExcept ([83ac764](https://github.com/postalserver/postal/commit/83ac76451071f097e7197f77fc5ad16e9cf58593))
* **rubocop:** Style/IdenticalConditionalBranches ([6a58ecf](https://github.com/postalserver/postal/commit/6a58ecf605250b8fa891cb14fca0c0e0ce0d7eb9))
* **rubocop:** Style/MissingRespondToMissing ([ffcb707](https://github.com/postalserver/postal/commit/ffcb707247fe2a69905aa6e4dc668abeb9924611))
* **rubocop:** Style/MultilineBlockChain ([c6326a6](https://github.com/postalserver/postal/commit/c6326a6524e6d71d23bc2c256f3f9416c38b0846))
* **rubocop:** Style/MutableConstant ([129dffa](https://github.com/postalserver/postal/commit/129dffab9ed8726ca4066e7052adc699129de2d2))
* **rubocop:** Style/NumericPredicate ([c558f1c](https://github.com/postalserver/postal/commit/c558f1c69ce9498564161d8cef3fcb8213103498))
* **rubocop:** Style/PreferredHashMethods ([013b3ea](https://github.com/postalserver/postal/commit/013b3ea9315c14f24b08574d68e1688f33d78b8d))
* **rubocop:** Style/SafeNavigation ([00a02f2](https://github.com/postalserver/postal/commit/00a02f2655b6e3296ad0e7ea9b9872da936b56ed))
* **rubocop:** Style/SelectByRegexp ([9ce28a4](https://github.com/postalserver/postal/commit/9ce28a427fadf6fafd942e009792be4b5539d40d))
* **rubocop:** Style/StringLiterals ([b4cc812](https://github.com/postalserver/postal/commit/b4cc81264c85d5f0061e5b5121a30d7bdcabc189))
* **rubocop:** Style/WordArray ([bd85920](https://github.com/postalserver/postal/commit/bd8592056573d1c6933d753ed50bdf9a7466e761))
* **rubocop:** update rubocop rules ([6d4dea7](https://github.com/postalserver/postal/commit/6d4dea7f7f0145ff2b99cf2505bc70a3e5925256))
### Miscellaneous Chores
* annotate models ([6214892](https://github.com/postalserver/postal/commit/6214892710e21c2aa29a319d5809f7bdf0d50529))
* silence message DB migrations during provisioning ([c83601a](https://github.com/postalserver/postal/commit/c83601af69f35e338b1f7c10ef7994f74b96f8bf))
### Code Refactoring
* remove reloading on the smtp server ([c3c304e](https://github.com/postalserver/postal/commit/c3c304e98b3274433248792b6403acf63d7a513b))
### Tests
* add initial tests for Postal::SMTPServer::Client ([dece1d4](https://github.com/postalserver/postal/commit/dece1d487ac2fdce104700939a79a5579b60a0cb))
* FactoryBot.lint will lint all registered factories ([25d7d66](https://github.com/postalserver/postal/commit/25d7d66b4709fe5442d554097a6ef074aeb15f72))
* remove FACTORIES_EXCLUDED_FROM_LINT ([1cf665a](https://github.com/postalserver/postal/commit/1cf665a0cf61d1eae3d08bdadf6fccaab6413023))
## [2.2.2](https://github.com/postalserver/postal/compare/2.2.1...2.2.2) (2024-02-06)
### Bug Fixes
* adds new connection pool which will discard failed clients ([54306a9](https://github.com/postalserver/postal/commit/54306a974802c2e4d17e0980531e2d0dba08150a)), closes [#2780](https://github.com/postalserver/postal/issues/2780)
* re-add reconnect: true to database ([7bc5230](https://github.com/postalserver/postal/commit/7bc5230cbaae58fb6f8512d1d1b0e6a2eb989b56))
* upgrade nokogiri ([f05c2e4](https://github.com/postalserver/postal/commit/f05c2e4503688e59a5ef513a5a1064d0ebbb5813))
### Tests
* rename database spec file ([b9edcf5](https://github.com/postalserver/postal/commit/b9edcf5b7dda7f4976a9d3f90668bbdacea57350))
## [2.2.1](https://github.com/postalserver/postal/compare/2.2.0...2.2.1) (2024-02-03)
### Bug Fixes
* fixes issue starting application in production mode ([4528a14](https://github.com/postalserver/postal/commit/4528a14d273c141e5719f19c3b08c00364b47638))
### Code Refactoring
* remove Postal.database_url ([96ba4b8](https://github.com/postalserver/postal/commit/96ba4b8f309cfcd1d605e5c7fc05507b21c78c6f))
## [2.2.0](https://github.com/postalserver/postal/compare/2.1.6...2.2.0) (2024-02-01)
### Features
* load signing key path from POSTAL_SIGNING_KEY_PATH ([4a46f69](https://github.com/postalserver/postal/commit/4a46f690de3010f1ae4d6c17739530a4eae35c09))
* support for configuring postal with environment variables ([854aa5e](https://github.com/postalserver/postal/commit/854aa5ebc87de692b4691d48759aefd6fae9d133))
### Bug Fixes
* don't use indifferent access for job params ([2bad645](https://github.com/postalserver/postal/commit/2bad645d980ad4b712a3c863b5350e4ee2895071)), closes [#2477](https://github.com/postalserver/postal/issues/2477) [#2714](https://github.com/postalserver/postal/issues/2714) [#2476](https://github.com/postalserver/postal/issues/2476) [#2500](https://github.com/postalserver/postal/issues/2500)
* extract x-postal-tag before holding ([6b2bf90](https://github.com/postalserver/postal/commit/6b2bf9062d662ede14617c4995ffaacca023a3b1)), closes [#2684](https://github.com/postalserver/postal/issues/2684)
* fixes error messages in web ui ([71f51db](https://github.com/postalserver/postal/commit/71f51db3c2515addaf8b280667555427d64796be))
* ignore message DB migrations in autoloader ([3fb40e4](https://github.com/postalserver/postal/commit/3fb40e4e247893b314e42affa4604a7a71a52c59))
* move tracking middleware before host authorization ([49cceaa](https://github.com/postalserver/postal/commit/49cceaa6ca862965448041279fc439ecba163ff8)), closes [#2415](https://github.com/postalserver/postal/issues/2415)
* use utc timestamps when determining raw table names ([ce19bf7](https://github.com/postalserver/postal/commit/ce19bf7988d522bf46aabf68090751427e286ffc))
### Miscellaneous Chores
* add binstubs for bundle and rspec ([41f6cf4](https://github.com/postalserver/postal/commit/41f6cf4d909518526af55ecb3fcccfa8fb8e1da2))
* add script to send html emails to a local SMTP server ([8794a2f](https://github.com/postalserver/postal/commit/8794a2f44783658a075a6f3985079ae4743412b1))
### Code Refactoring
* remove explicit autoload ([0f9882f](https://github.com/postalserver/postal/commit/0f9882f13204124df630606b1b9e36787c9c4011))
* remove Postal::Job.perform method ([990b575](https://github.com/postalserver/postal/commit/990b575902c45bb1678cc95f53ef3166c4b7092e))
## [2.1.6](https://github.com/postalserver/postal/compare/2.1.5...2.1.6) (2024-01-30)
### Miscellaneous Chores
* **build:** fixes docker login action credentials ([8810856](https://github.com/postalserver/postal/commit/88108566f8ab33f1a4263a36a5c1ffc071645ac3))
* update release please to include more categories in changelog ([e156c21](https://github.com/postalserver/postal/commit/e156c21dee304de7d10c2958c493cce73c2d8fea))
## [2.1.5](https://github.com/postalserver/postal/compare/2.1.4...2.1.5) (2024-01-30)
### Bug Fixes
* duplicate string before modifying it to prevent frozen string errors ([f0a8aca](https://github.com/postalserver/postal/commit/f0a8aca6e10064fb16daefff9e22dcc20a831868))
* fixed typo (rfc number) ([2f62baa](https://github.com/postalserver/postal/commit/2f62baa238fc1102706ee4acf079b7a876b05283))
* fixes typo in on track domains page ([77bd77b](https://github.com/postalserver/postal/commit/77bd77b629fcbc44b8d27deb0d33a457b02309f2))
* mail view encoding issue [#2462](https://github.com/postalserver/postal/issues/2462) ([#2596](https://github.com/postalserver/postal/issues/2596)) ([59f4478](https://github.com/postalserver/postal/commit/59f44781973489817efb5b3435d95d25f44f90ce))
* match IPv4 mapped IPv6 addresses when searching for SMTP-IP credentials ([8b525d0](https://github.com/postalserver/postal/commit/8b525d0381a9e0113af808b9ec2eb47bf78ec60b))
## 2.1.4
### Bug Fixes
- Move RubyVer functionality to Utilities module ([5998bf](https://github.com/postalserver/postal/commit/5998bf376a274df19f29877e7f68ea75f298c9f9))
## 2.1.3
### Features
- Upgrade to Ruby 3.2.1 & Rails 6.1 ([957b78](https://github.com/postalserver/postal/commit/957b784658cda8c4c95cf1f2b65e05d99d23d427))
- Make resent-sender header optional ([c6fb8d](https://github.com/postalserver/postal/commit/c6fb8d223bdeaccdc9e8bdbd031fe3f325ac0677))
- Log CRAM-MD5 authentication failures ([9b1ed1](https://github.com/postalserver/postal/commit/9b1ed1e7e16a8f55a5bd7b7ce72195a08ca2968d))
- Always use multipart/alternative parts in generated emails ([d0db13](https://github.com/postalserver/postal/commit/d0db1345a2bf8f538b01b974e74391da6fffe2b1))
### Bug Fixes
- Use non-blocking function to negotiate TLS connections ([a7dd19](https://github.com/postalserver/postal/commit/a7dd19baac8300f4d8ee89d0050479e08fdf9176))
- Fix to newline conversion process ([9f4ef8](https://github.com/postalserver/postal/commit/9f4ef8f57a839c5529b4f00a36b832740386b4ed))
- Remove custom scrollbars ([b22f1b](https://github.com/postalserver/postal/commit/b22f1bdb2e2d66b096ca993d6a5f4f708274a4a2))
- Truncate 'output' field to avoid overflowing varchar(512) in database ([a188a1](https://github.com/postalserver/postal/commit/a188a161cbdcfd70158b09b53cef622842357c26))
- Fix link replacement in multipart messsages ([7ea00d](https://github.com/postalserver/postal/commit/7ea00dfa3bc3c7650cc2b134beacbff22101a913))
- Fix confusing error message when deleting IP pools ([cefc7d](https://github.com/postalserver/postal/commit/cefc7d17b82f610001859a8e323ee1dfde149ba5))
- Connect to correct IP rather than hostname suring SMTP delivery ([159509](https://github.com/postalserver/postal/commit/159509a3ed29ae33cba522b255904992922dcfdf))
- Change retry timings to avoid re-sending messages too early ([c8d27b](https://github.com/postalserver/postal/commit/c8d27b2963af122d6555abdf0742d2d2d6f11ce5))
## 2.1.2
### Features
- support for AMQPS for rabbitmq connections ([9f0697](https://github.com/postalserver/postal/commit/9f0697f194209f5fae5e451ba8fb888413fe37fa))
### Bug Fixes
- retry connections without SSL when SSL issue is encountered during smtp sending ([0dc682](https://github.com/postalserver/postal/commit/0dc6824a8f0315ea42b08f7e6812b821b62489c9))
## 2.1.1
### Features
- allow @ and % in webhook urls ([c60c69](https://github.com/postalserver/postal/commit/c60c69db1800775776da4c28c68001f230fe5888))
### Bug Fixes
- fixes broken styling on errors ([a0c87e](https://github.com/postalserver/postal/commit/a0c87e7bf16a19f06c13797e3329a4fed91370a1))
- use the Postal logger system for the rails log ([5b04fa](https://github.com/postalserver/postal/commit/5b04faca39c69757bd7d695b82984f8b4a41cac3))
## 2.1.0
### Features
- support for configuring the default spam threshold values for new servers ([724325](https://github.com/postalserver/postal/commit/724325a1b97d61ef1e134240e4f70aaad39dbf98))
- support for using rspamd for spam filtering ([a1277b](https://github.com/postalserver/postal/commit/a1277baba56ea6d6b4da4bba87b00cd3dbf0305e))
### Bug Fixes
- **dkim:** fixes timing race condition when signing emails ([232b60](https://github.com/postalserver/postal/commit/232b605f5bb8ab61156e1fb9860705fed017ed41))
- **docker:** fixes issue caused by changes to underlying ruby:2.6 image ([6570ff](https://github.com/postalserver/postal/commit/6570ff1f7797ff9a307dd96ed4ff37be14bf79ab))
## 2.0.0
### Features
- **ui:** add footer with links to docs and discussions ([1247da](https://github.com/postalserver/postal/commit/1247dae2e060a695a13a30ba072ca5e6dea45202))
### Bug Fixes
- **dkim:** ensure DKIM-Signature headers are appropriately wrapped ([476129](https://github.com/postalserver/postal/commit/476129cc1ba44e9014768d5ba7193587f78cb5d5))
- **docs:** update port numbers to specify the actual port number the SMTP server is listening on ([4404b3](https://github.com/postalserver/postal/commit/4404b3e02c1722808157c3f590310ead9e28641d))
- **logging:** fix spelling of graylog ([2a11e0](https://github.com/postalserver/postal/commit/2a11e0c0a5b7c7f630af28cf4af5511d9bce6dda))
## 2.0.0-beta.1
### Features
- **config:** support for loading a postal.local.yml config file from the config root if it exists ([8e3294](https://github.com/postalhq/postal/commit/8e3294ba1af4b797d36bd1ca9226190ed80f65cc))
- **smtp_server:** allow bind address to be configured ([4a410c](https://github.com/postalhq/postal/commit/4a410c8c9f6fa1ef993a68c37afeaf31230585f7))
- add priorities to IP address assignment ([21a8d8](https://github.com/postalhq/postal/commit/21a8d890459958375d4a49a5b7f31f4900a9e8b1))
### Bug Fixes
- **dkim:** fixes bug with signing dkim bodies ([189dfa](https://github.com/postalhq/postal/commit/189dfa509b4750f1e4cc6f43f6565edd3a35139c))
- **smtp_server:** attempt to redact plain-text passwords from log output ([fcb636](https://github.com/postalhq/postal/commit/fcb63616e1ce578d7d4fd1c96ddc4ee0f7a71534))
- **smtp_server:** fixes issue with malformed rcpt to ([e0ba05](https://github.com/postalhq/postal/commit/e0ba05acb11108d98a460ae3fac653ceefb5f672))
- **smtp_server:** refactor mx lookups to randomly order mx records with the same priority ([bc2239](https://github.com/postalhq/postal/commit/bc22394fdd4f26dddd576840b49d7c25802cda7d))
- **smtp_server:** updated line split logic, normalize all linebreaks to \r\n ([e8ba9e](https://github.com/postalhq/postal/commit/e8ba9ee4276e81af84ecb6ff6f0c024ef99f6ddc))
- add resolv 0.2.1 ([eef1a3](https://github.com/postalhq/postal/commit/eef1a365a28e133750c4d5a4ac0eeeed223e303d))
- always obey POSTAL_CONFIG_ROOT ([1d22ca](https://github.com/postalhq/postal/commit/1d22ca0f85b58b04aedde9071d9fc5ecd44af4de))
- fix issue with determining if an SMTP connection is encrypted or not ([73870d](https://github.com/postalhq/postal/commit/73870d6a92400fc8ec1493016817dfac074ffd06))
- remove a few leftover fast server artifacts ([5cd06e](https://github.com/postalhq/postal/commit/5cd06e126b6caac502245754b360194365152415))
- replace Fixnum with Integer ([52a23f](https://github.com/postalhq/postal/commit/52a23fa86f94c14dfc7edccbf414dda34c46bc12))
================================================
FILE: CONTRIBUTING.md
================================================
# Contributing to Postal
This doc explains how to go about running Postal in development to allow you to make contributions to the project.
## Dependencies
You will need a MySQL database server to get started. Postal needs to be able to make databases within that server whenever new mail servers are created so the permissions that you use should be suitable for that.
You'll also need Ruby. Postal currently uses Ruby 3.2.2. Install that using whichever version manager takes your fancy - rbenv, asdf, rvm etc.
## Clone
You'll need to clone the repository
```
git clone git@github.com:postalserver/postal
```
Once cloned, you can install the Ruby dependencies using bundler.
```
bundle install
```
## Configuration
Configuration is handled using a config file. This lives in `config/postal/postal.yml`. An example configuration file is provided in `config/examples/development.yml`. This example is for development use only and not an example for production use.
You'll also need a key for signing. You can generate one of these like this:
```
openssl genrsa -out config/postal/signing.key 2048
```
If you're running the tests (and you probably should be), you'll find an example file for test configuration in `config/examples/test.yml`. This should be placed in `config/postal/postal.test.yml` with the appropriate values.
If you prefer, you can configure Postal using environment variables. These should be placed in `.env` or `.env.test` as apprpriate.
## Running
The neatest way to run postal is to ensure that `./bin` is your `$PATH` and then use one of the following commands.
* `bin/dev` - will run all components of the application using Foreman
* `bin/postal` - will run the Postal binary providing access to running individual components or other tools.
## Database initialization
Use the commands below to initialize your database and make your first user.
```
postal initialize
postal make-user
```
================================================
FILE: Dockerfile
================================================
FROM ruby:3.4.6-slim-bookworm AS base
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN apt-get update \
&& apt-get install --no-install-recommends -y curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN (curl -sL https://deb.nodesource.com/setup_20.x | bash -)
# Install main dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
netcat-openbsd \
libmariadb-dev \
libcap2-bin \
nano \
libyaml-dev \
nodejs \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN setcap 'cap_net_bind_service=+ep' /usr/local/bin/ruby
# Configure 'postal' to work everywhere (when the binary exists
# later in this process)
ENV PATH="/opt/postal/app/bin:${PATH}"
# Setup an application
RUN useradd -r -d /opt/postal -m -s /bin/bash -u 999 postal
USER postal
RUN mkdir -p /opt/postal/app /opt/postal/config
WORKDIR /opt/postal/app
# Install bundler
RUN gem install bundler -v 2.7.2 --no-doc
# Install the latest and active gem dependencies and re-run
# the appropriate commands to handle installs.
COPY --chown=postal Gemfile Gemfile.lock ./
RUN bundle install
# Copy the application (and set permissions)
COPY ./docker/wait-for.sh /docker-entrypoint.sh
COPY --chown=postal . .
# Export the version
ARG VERSION
ARG BRANCH
RUN if [ "$VERSION" != "" ]; then echo $VERSION > VERSION; fi \
&& if [ "$BRANCH" != "" ]; then echo $BRANCH > BRANCH; fi
# Set paths for when running in a container
ENV POSTAL_CONFIG_FILE_PATH=/config/postal.yml
# Set the CMD
ENTRYPOINT [ "/docker-entrypoint.sh" ]
CMD ["postal"]
# ci target - use --target=ci to skip asset compilation
FROM base AS ci
# full target - default if no --target option is given
FROM base AS full
RUN RAILS_GROUPS=assets bundle exec rake assets:precompile
RUN touch /opt/postal/app/public/assets/.prebuilt
================================================
FILE: Gemfile
================================================
# frozen_string_literal: true
source "https://rubygems.org"
gem "abbrev"
gem "authie"
gem "autoprefixer-rails"
gem "bcrypt"
gem "chronic"
gem "domain_name"
gem "dotenv"
gem "dynamic_form"
gem "execjs", "~> 2.7", "< 2.8"
gem "gelf"
gem "haml"
gem "hashie"
gem "highline", require: false
gem "jwt"
gem "kaminari"
gem "klogger-logger"
gem "konfig-config", "~> 3.0"
gem "logger"
gem "mail"
gem "mutex_m"
gem "mysql2"
gem "nifty-utils"
gem "nilify_blanks"
gem "nio4r"
gem "ostruct"
gem "prometheus-client"
gem "puma"
gem "rackup"
gem "rails", "= 7.1.5.2"
gem "resolv"
gem "secure_headers"
gem "sentry-rails"
gem "turbolinks", "~> 5"
gem "webrick"
group :oidc do
# These are gems which are needed for OpenID connect. They are only required by the application
# when OIDC is enabled in the Postal configuration.
gem "omniauth_openid_connect"
gem "omniauth-rails_csrf_protection"
end
group :development, :assets do
gem "coffee-rails", "~> 5.0"
gem "jquery-rails"
gem "sass-rails"
gem "uglifier", ">= 1.3.0"
end
group :development do
gem "annotate"
gem "rubocop"
gem "rubocop-rails"
end
group :test do
gem "database_cleaner-active_record"
gem "factory_bot_rails"
gem "rspec"
gem "rspec-rails"
gem "shoulda-matchers"
gem "timecop"
gem "webmock"
end
================================================
FILE: MIT-LICENCE
================================================
Copyright 2017-2024 Krystal Hosting Ltd
Copyright 2024 Adam Cooke
Copyright 2024 Charlie Smurthwaite
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
================================================
FILE: Procfile.dev
================================================
web: unset PORT; bundle exec puma -C config/puma.rb
worker: bundle exec ruby script/worker.rb
smtp: unset PORT; bundle exec ruby script/smtp_server.rb
================================================
FILE: README.md
================================================

**Postal** is a complete and fully featured mail server for use by websites & web servers. Think Sendgrid, Mailgun or Postmark but open source and ready for you to run on your own servers.
* [Documentation](https://docs.postalserver.io)
* [Installation Instructions](https://docs.postalserver.io/getting-started)
* [FAQs](https://docs.postalserver.io/welcome/faqs) & [Features](https://docs.postalserver.io/welcome/feature-list)
* [Discussions](https://github.com/postalserver/postal/discussions) - ask for help or request a feature
* [Join us on Discord](https://discord.postalserver.io)
================================================
FILE: Rakefile
================================================
# frozen_string_literal: true
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require_relative "config/application"
Rails.application.load_tasks
================================================
FILE: SECURITY.md
================================================
# Security Policy
## Supported Versions
We only support updates to the 3.x versions of Postal.
| Version | Supported |
| ------- | ------------------ |
| 3.x.x | :white_check_mark: |
| < 3.0 | :x: |
## Reporting a Vulnerability
If you discover a vulnerability in Postal, please do not post an issue on GitHub. Instead you should send an
e-mail to security@postalserver.io with details. We will get back to you directly.
================================================
FILE: app/assets/config/manifest.js
================================================
//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css
//= link application/application.css
//= link application/application.js
================================================
FILE: app/assets/images/.keep
================================================
================================================
FILE: app/assets/javascripts/application/application.coffee
================================================
#= require jquery
#= require jquery_ujs
#= require turbolinks
#= require_tree ./vendor/.
#= require_self
#= require_tree .
$ ->
isFirefox = -> !!navigator.userAgent.match(/firefox/i)
$('html').addClass('browser-firefox') if isFirefox()
$(document).on 'turbolinks:load', ->
$('.js-multibox').multibox({inputCount: 6, classNames: {container: "multibox", input: 'input input--text multibox__input'}})
$(document).on 'keyup', (event)->
return if $(event.target).is('input, select, textarea')
if event.keyCode == 83
$('.js-focus-on-s').focus()
event.preventDefault()
if event.keyCode == 70
$('.js-focus-on-f').focus()
event.preventDefault()
$(document).on 'click', 'html.main .flashMessage', ->
$(this).hide 'fast', ->
$(this).remove()
$(document).on 'click', '.js-toggle-helpbox', ->
helpBox = $('.js-helpbox')
if helpBox.hasClass('is-hidden')
helpBox.removeClass('is-hidden')
else
helpBox.addClass('is-hidden')
return false
$(document).on 'input', 'input[type=range]', ->
value = $(this).val()
updateAttr = $(this).attr('data-update')
if updateAttr && updateAttr.length
$("." + $(this).attr('data-update')).text(parseFloat(value, 10).toFixed(1))
$(document).on 'change', '.js-checkbox-list-toggle', ->
$this = $(this)
value = $this.val()
$list = $this.parent().find('.checkboxList')
if value == 'false' then $list.show() else $list.hide()
$(document).on 'click', '.js-toggle', ->
$link = $(this)
element = $link.attr('data-element')
$(element, $link.parent()).toggle()
false
toggleCredentialInputs = (type)->
$('[data-credential-key-type]').hide()
$('[data-credential-key-type] input').attr('disabled', true)
if type == 'SMTP-IP'
$('[data-credential-key-type=smtp-ip]').show()
$('[data-credential-key-type=smtp-ip] input').attr('disabled', false)
else
$('[data-credential-key-type=all]').show()
$(document).on 'change', 'select#credential_type', ->
value = $(this).val()
toggleCredentialInputs(value)
$(document).on 'turbolinks:load', ->
credentialTypeInput = $('select#credential_type')
if credentialTypeInput.length
toggleCredentialInputs(credentialTypeInput.val())
================================================
FILE: app/assets/javascripts/application/elements/ajax.coffee
================================================
onStart = (event) ->
$('.flashMessage').remove()
$('input, select, textarea').blur()
$target = $(event.target)
if $target.is('form')
$('.js-form-submit', $target).addClass('is-spinning')
if $target.hasClass('button')
$($target).addClass('is-spinning')
onComplete = (event, xhr)->
$target = $(event.target)
if xhr.responseJSON
data = xhr.responseJSON
if data.redirect_to
Turbolinks.clearCache()
Turbolinks.visit(data.redirect_to, {"action":"replace"})
console.log "Redirected to #{data.redirect_to}"
if data.alert
unSpin($target)
alert(data.alert)
if data.form_errors
if $target.is('form')
unSpin($target)
handleErrors($target, data.form_errors)
if data.flash
unSpin($target)
$('body .flashMessage').remove()
for key, value of data.flash
$message = $("<div class='flashMessage flashMessage--#{key}'>#{value}</div>")
$('body').prepend($message)
if data.region_html
unSpin($target)
$('.js-ajax-region').replaceWith(data.region_html)
$('[autofocus]', '.js-ajax-region').focus()
else
console.log "Unsupported return."
unSpin = ($target)->
$target.removeClass('is-spinning')
$('.js-form-submit', $target).removeClass('is-spinning')
handleErrors = (form, errors)->
html = $("<div class='formErrors errorExplanation'><ul></ul</div>")
list = $('ul', html)
$.each errors, ->
list.append("<li>#{this}</li>")
$('.formErrors', form).remove()
form.prepend($(html))
console.log errors
$ ->
$.ajaxSettings.dataType = 'json'
$(document)
.on 'ajax:before', onStart
.on 'ajax:complete', onComplete
================================================
FILE: app/assets/javascripts/application/elements/mail_graph.coffee
================================================
$(document).on 'turbolinks:load', ->
mailGraph = $('.mailGraph')
if mailGraph.length
data = JSON.parse(mailGraph.attr('data-data'))
incomingMail = []
outgoingMail = []
for d in data
incomingMail.push(d.incoming)
outgoingMail.push(d.outgoing)
data =
series: [outgoingMail, incomingMail]
options =
fullWidth: true
axisY:
offset:40
axisX:
showGrid: false
offset: 0
showLabel: true
height: '230px'
showArea: true
high: if incomingMail? && incomingMail.length then undefined else 1000
chartPadding:
top:0
right:0
bottom:0
left:0
new Chartist.Line '.mailGraph__graph', data, options
================================================
FILE: app/assets/javascripts/application/elements/remembering.coffee
================================================
$ ->
$(document).on 'click', '.js-remember a', ->
$parent = $(this).parents('.js-remember')
value = $(this).attr('data-remember')
$parent.remove()
if value == 'yes'
$.post('/persist')
false
================================================
FILE: app/assets/javascripts/application/elements/searchable.coffee
================================================
ENTER = 13
DOWN_ARROW = 40
UP_ARROW = 38
filterList = ($container, query) ->
$items = getItems($container)
index = $container.data('searchifyIndex')
re = new RegExp(query, 'g')
$matches = $items.filter (i, item) ->
value = $(item).data('value')
re.test(value)
$items.addClass('is-hidden').filter($matches).removeClass('is-hidden')
toggleState($container, $matches.length > 0)
if index?
index = 0
$container.data('searchifyIndex', index)
highlightItem($container, $matches, index)
getContainer = ($el) ->
$el.closest('.js-searchable')
getEmpty = ($container) ->
$('.js-searchable__empty', $container)
getList = ($container) ->
$('.js-searchable__list', $container)
getItems = ($container) ->
$('.js-searchable__item', $container)
highlightItem = ($container, $scope, index) ->
$items = getItems($container)
$items.removeClass('is-highlighted')
$scope.eq(index).addClass('is-highlighted') if index? && $scope.length
highlightNext = ($container) ->
$matches = getMatches($container)
index = $container.data('searchifyIndex')
return unless $matches.length
if index?
return if index == $matches.length - 1
newIndex = index + 1
else
newIndex = 0
$container.data('searchifyIndex', newIndex)
highlightItem($container, $matches, newIndex)
highlightPrev = ($container) ->
$matches = getMatches($container)
index = $container.data('searchifyIndex')
return unless $matches.length
if index?
return if index == 0
newIndex = index - 1
else
newIndex = 0
$container.data('searchifyIndex', newIndex)
highlightItem($container, $matches, newIndex)
getMatches = ($container) ->
$items = getItems($container)
$items.filter(':not(.is-hidden)')
searchify = (str) ->
str.toLowerCase().replace(/\W/g, '')
selectHighlighted = ($container) ->
index = $container.data('searchifyIndex')
$matches = getMatches($container)
return unless index? && $matches.length
url = $matches.eq(index).data('url')
Turbolinks.visit(url)
showAll = ($container) ->
$items = getItems($container)
index = $container.data('searchifyIndex')
$items.removeClass('is-hidden')
toggleState($container, true)
if index?
index = 0
$container.data('searchifyIndex', index)
highlightItem($container, $items, index)
toggleState = ($container, predicate) ->
$empty = getEmpty($container)
$list = getList($container)
$empty.toggleClass('is-hidden', predicate)
$list.toggleClass('is-hidden', !predicate)
# Event Handlers
handleInput = (event) ->
$input = $(event.target)
$container = getContainer($input)
query = searchify($input.val())
if query.length then filterList($container, query) else showAll($container)
handleKeydown = (event) ->
$container = getContainer($(event.target))
keyCode = event.keyCode
if keyCode == DOWN_ARROW
event.preventDefault()
highlightNext($container)
else if keyCode == ENTER
event.preventDefault()
selectHighlighted($container)
else if keyCode == UP_ARROW
event.preventDefault()
highlightPrev($container)
$ ->
$(document)
.on('input', '.js-searchable__input', handleInput)
.on('keydown', '.js-searchable__input', handleKeydown)
================================================
FILE: app/assets/javascripts/application/vendor/chartist.js
================================================
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module unless amdModuleId is set
define([], function () {
return (root['Chartist'] = factory());
});
} else if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory();
} else {
root['Chartist'] = factory();
}
}(this, function () {
/* Chartist.js 0.9.8
* Copyright © 2016 Gion Kunz
* Free to use under either the WTFPL license or the MIT license.
* https://raw.githubusercontent.com/gionkunz/chartist-js/master/LICENSE-WTFPL
* https://raw.githubusercontent.com/gionkunz/chartist-js/master/LICENSE-MIT
*/
/**
* The core module of Chartist that is mainly providing static functions and higher level functions for chart modules.
*
* @module Chartist.Core
*/
var Chartist = {
version: '0.9.8'
};
(function (window, document, Chartist) {
'use strict';
/**
* This object contains all namespaces used within Chartist.
*
* @memberof Chartist.Core
* @type {{svg: string, xmlns: string, xhtml: string, xlink: string, ct: string}}
*/
Chartist.namespaces = {
svg: 'http://www.w3.org/2000/svg',
xmlns: 'http://www.w3.org/2000/xmlns/',
xhtml: 'http://www.w3.org/1999/xhtml',
xlink: 'http://www.w3.org/1999/xlink',
ct: 'http://gionkunz.github.com/chartist-js/ct'
};
/**
* Helps to simplify functional style code
*
* @memberof Chartist.Core
* @param {*} n This exact value will be returned by the noop function
* @return {*} The same value that was provided to the n parameter
*/
Chartist.noop = function (n) {
return n;
};
/**
* Generates a-z from a number 0 to 26
*
* @memberof Chartist.Core
* @param {Number} n A number from 0 to 26 that will result in a letter a-z
* @return {String} A character from a-z based on the input number n
*/
Chartist.alphaNumerate = function (n) {
// Limit to a-z
return String.fromCharCode(97 + n % 26);
};
/**
* Simple recursive object extend
*
* @memberof Chartist.Core
* @param {Object} target Target object where the source will be merged into
* @param {Object...} sources This object (objects) will be merged into target and then target is returned
* @return {Object} An object that has the same reference as target but is extended and merged with the properties of source
*/
Chartist.extend = function (target) {
target = target || {};
var sources = Array.prototype.slice.call(arguments, 1);
sources.forEach(function(source) {
for (var prop in source) {
if (typeof source[prop] === 'object' && source[prop] !== null && !(source[prop] instanceof Array)) {
target[prop] = Chartist.extend({}, target[prop], source[prop]);
} else {
target[prop] = source[prop];
}
}
});
return target;
};
/**
* Replaces all occurrences of subStr in str with newSubStr and returns a new string.
*
* @memberof Chartist.Core
* @param {String} str
* @param {String} subStr
* @param {String} newSubStr
* @return {String}
*/
Chartist.replaceAll = function(str, subStr, newSubStr) {
return str.replace(new RegExp(subStr, 'g'), newSubStr);
};
/**
* Converts a number to a string with a unit. If a string is passed then this will be returned unmodified.
*
* @memberof Chartist.Core
* @param {Number} value
* @param {String} unit
* @return {String} Returns the passed number value with unit.
*/
Chartist.ensureUnit = function(value, unit) {
if(typeof value === 'number') {
value = value + unit;
}
return value;
};
/**
* Converts a number or string to a quantity object.
*
* @memberof Chartist.Core
* @param {String|Number} input
* @return {Object} Returns an object containing the value as number and the unit as string.
*/
Chartist.quantity = function(input) {
if (typeof input === 'string') {
var match = (/^(\d+)\s*(.*)$/g).exec(input);
return {
value : +match[1],
unit: match[2] || undefined
};
}
return { value: input };
};
/**
* This is a wrapper around document.querySelector that will return the query if it's already of type Node
*
* @memberof Chartist.Core
* @param {String|Node} query The query to use for selecting a Node or a DOM node that will be returned directly
* @return {Node}
*/
Chartist.querySelector = function(query) {
return query instanceof Node ? query : document.querySelector(query);
};
/**
* Functional style helper to produce array with given length initialized with undefined values
*
* @memberof Chartist.Core
* @param length
* @return {Array}
*/
Chartist.times = function(length) {
return Array.apply(null, new Array(length));
};
/**
* Sum helper to be used in reduce functions
*
* @memberof Chartist.Core
* @param previous
* @param current
* @return {*}
*/
Chartist.sum = function(previous, current) {
return previous + (current ? current : 0);
};
/**
* Multiply helper to be used in `Array.map` for multiplying each value of an array with a factor.
*
* @memberof Chartist.Core
* @param {Number} factor
* @returns {Function} Function that can be used in `Array.map` to multiply each value in an array
*/
Chartist.mapMultiply = function(factor) {
return function(num) {
return num * factor;
};
};
/**
* Add helper to be used in `Array.map` for adding a addend to each value of an array.
*
* @memberof Chartist.Core
* @param {Number} addend
* @returns {Function} Function that can be used in `Array.map` to add a addend to each value in an array
*/
Chartist.mapAdd = function(addend) {
return function(num) {
return num + addend;
};
};
/**
* Map for multi dimensional arrays where their nested arrays will be mapped in serial. The output array will have the length of the largest nested array. The callback function is called with variable arguments where each argument is the nested array value (or undefined if there are no more values).
*
* @memberof Chartist.Core
* @param arr
* @param cb
* @return {Array}
*/
Chartist.serialMap = function(arr, cb) {
var result = [],
length = Math.max.apply(null, arr.map(function(e) {
return e.length;
}));
Chartist.times(length).forEach(function(e, index) {
var args = arr.map(function(e) {
return e[index];
});
result[index] = cb.apply(null, args);
});
return result;
};
/**
* This helper function can be used to round values with certain precision level after decimal. This is used to prevent rounding errors near float point precision limit.
*
* @memberof Chartist.Core
* @param {Number} value The value that should be rounded with precision
* @param {Number} [digits] The number of digits after decimal used to do the rounding
* @returns {number} Rounded value
*/
Chartist.roundWithPrecision = function(value, digits) {
var precision = Math.pow(10, digits || Chartist.precision);
return Math.round(value * precision) / precision;
};
/**
* Precision level used internally in Chartist for rounding. If you require more decimal places you can increase this number.
*
* @memberof Chartist.Core
* @type {number}
*/
Chartist.precision = 8;
/**
* A map with characters to escape for strings to be safely used as attribute values.
*
* @memberof Chartist.Core
* @type {Object}
*/
Chartist.escapingMap = {
'&': '&',
'<': '<',
'>': '>',
'"': '"',
'\'': '''
};
/**
* This function serializes arbitrary data to a string. In case of data that can't be easily converted to a string, this function will create a wrapper object and serialize the data using JSON.stringify. The outcoming string will always be escaped using Chartist.escapingMap.
* If called with null or undefined the function will return immediately with null or undefined.
*
* @memberof Chartist.Core
* @param {Number|String|Object} data
* @return {String}
*/
Chartist.serialize = function(data) {
if(data === null || data === undefined) {
return data;
} else if(typeof data === 'number') {
data = ''+data;
} else if(typeof data === 'object') {
data = JSON.stringify({data: data});
}
return Object.keys(Chartist.escapingMap).reduce(function(result, key) {
return Chartist.replaceAll(result, key, Chartist.escapingMap[key]);
}, data);
};
/**
* This function de-serializes a string previously serialized with Chartist.serialize. The string will always be unescaped using Chartist.escapingMap before it's returned. Based on the input value the return type can be Number, String or Object. JSON.parse is used with try / catch to see if the unescaped string can be parsed into an Object and this Object will be returned on success.
*
* @memberof Chartist.Core
* @param {String} data
* @return {String|Number|Object}
*/
Chartist.deserialize = function(data) {
if(typeof data !== 'string') {
return data;
}
data = Object.keys(Chartist.escapingMap).reduce(function(result, key) {
return Chartist.replaceAll(result, Chartist.escapingMap[key], key);
}, data);
try {
data = JSON.parse(data);
data = data.data !== undefined ? data.data : data;
} catch(e) {}
return data;
};
/**
* Create or reinitialize the SVG element for the chart
*
* @memberof Chartist.Core
* @param {Node} container The containing DOM Node object that will be used to plant the SVG element
* @param {String} width Set the width of the SVG element. Default is 100%
* @param {String} height Set the height of the SVG element. Default is 100%
* @param {String} className Specify a class to be added to the SVG element
* @return {Object} The created/reinitialized SVG element
*/
Chartist.createSvg = function (container, width, height, className) {
var svg;
width = width || '100%';
height = height || '100%';
// Check if there is a previous SVG element in the container that contains the Chartist XML namespace and remove it
// Since the DOM API does not support namespaces we need to manually search the returned list http://www.w3.org/TR/selectors-api/
Array.prototype.slice.call(container.querySelectorAll('svg')).filter(function filterChartistSvgObjects(svg) {
return svg.getAttributeNS(Chartist.namespaces.xmlns, 'ct');
}).forEach(function removePreviousElement(svg) {
container.removeChild(svg);
});
// Create svg object with width and height or use 100% as default
svg = new Chartist.Svg('svg').attr({
width: width,
height: height
}).addClass(className).attr({
style: 'width: ' + width + '; height: ' + height + ';'
});
// Add the DOM node to our container
container.appendChild(svg._node);
return svg;
};
/**
* Ensures that the data object passed as second argument to the charts is present and correctly initialized.
*
* @param {Object} data The data object that is passed as second argument to the charts
* @return {Object} The normalized data object
*/
Chartist.normalizeData = function(data) {
// Ensure data is present otherwise enforce
data = data || {series: [], labels: []};
data.series = data.series || [];
data.labels = data.labels || [];
// Check if we should generate some labels based on existing series data
if (data.series.length > 0 && data.labels.length === 0) {
var normalized = Chartist.getDataArray(data),
labelCount;
// If all elements of the normalized data array are arrays we're dealing with
// data from Bar or Line charts and we need to find the largest series if they are un-even
if (normalized.every(function(value) {
return value instanceof Array;
})) {
// Getting the series with the the most elements
labelCount = Math.max.apply(null, normalized.map(function(series) {
return series.length;
}));
} else {
// We're dealing with Pie data so we just take the normalized array length
labelCount = normalized.length;
}
// Setting labels to an array with emptry strings using our labelCount estimated above
data.labels = Chartist.times(labelCount).map(function() {
return '';
});
}
return data;
};
/**
* Reverses the series, labels and series data arrays.
*
* @memberof Chartist.Core
* @param data
*/
Chartist.reverseData = function(data) {
data.labels.reverse();
data.series.reverse();
for (var i = 0; i < data.series.length; i++) {
if(typeof(data.series[i]) === 'object' && data.series[i].data !== undefined) {
data.series[i].data.reverse();
} else if(data.series[i] instanceof Array) {
data.series[i].reverse();
}
}
};
/**
* Convert data series into plain array
*
* @memberof Chartist.Core
* @param {Object} data The series object that contains the data to be visualized in the chart
* @param {Boolean} reverse If true the whole data is reversed by the getDataArray call. This will modify the data object passed as first parameter. The labels as well as the series order is reversed. The whole series data arrays are reversed too.
* @param {Boolean} multi Create a multi dimensional array from a series data array where a value object with `x` and `y` values will be created.
* @return {Array} A plain array that contains the data to be visualized in the chart
*/
Chartist.getDataArray = function (data, reverse, multi) {
// If the data should be reversed but isn't we need to reverse it
// If it's reversed but it shouldn't we need to reverse it back
// That's required to handle data updates correctly and to reflect the responsive configurations
if(reverse && !data.reversed || !reverse && data.reversed) {
Chartist.reverseData(data);
data.reversed = !data.reversed;
}
// Recursively walks through nested arrays and convert string values to numbers and objects with value properties
// to values. Check the tests in data core -> data normalization for a detailed specification of expected values
function recursiveConvert(value) {
if(Chartist.isFalseyButZero(value)) {
// This is a hole in data and we should return undefined
return undefined;
} else if((value.data || value) instanceof Array) {
return (value.data || value).map(recursiveConvert);
} else if(value.hasOwnProperty('value')) {
return recursiveConvert(value.value);
} else {
if(multi) {
var multiValue = {};
// Single series value arrays are assumed to specify the Y-Axis value
// For example: [1, 2] => [{x: undefined, y: 1}, {x: undefined, y: 2}]
// If multi is a string then it's assumed that it specified which dimension should be filled as default
if(typeof multi === 'string') {
multiValue[multi] = Chartist.getNumberOrUndefined(value);
} else {
multiValue.y = Chartist.getNumberOrUndefined(value);
}
multiValue.x = value.hasOwnProperty('x') ? Chartist.getNumberOrUndefined(value.x) : multiValue.x;
multiValue.y = value.hasOwnProperty('y') ? Chartist.getNumberOrUndefined(value.y) : multiValue.y;
return multiValue;
} else {
return Chartist.getNumberOrUndefined(value);
}
}
}
return data.series.map(recursiveConvert);
};
/**
* Converts a number into a padding object.
*
* @memberof Chartist.Core
* @param {Object|Number} padding
* @param {Number} [fallback] This value is used to fill missing values if a incomplete padding object was passed
* @returns {Object} Returns a padding object containing top, right, bottom, left properties filled with the padding number passed in as argument. If the argument is something else than a number (presumably already a correct padding object) then this argument is directly returned.
*/
Chartist.normalizePadding = function(padding, fallback) {
fallback = fallback || 0;
return typeof padding === 'number' ? {
top: padding,
right: padding,
bottom: padding,
left: padding
} : {
top: typeof padding.top === 'number' ? padding.top : fallback,
right: typeof padding.right === 'number' ? padding.right : fallback,
bottom: typeof padding.bottom === 'number' ? padding.bottom : fallback,
left: typeof padding.left === 'number' ? padding.left : fallback
};
};
Chartist.getMetaData = function(series, index) {
var value = series.data ? series.data[index] : series[index];
return value ? Chartist.serialize(value.meta) : undefined;
};
/**
* Calculate the order of magnitude for the chart scale
*
* @memberof Chartist.Core
* @param {Number} value The value Range of the chart
* @return {Number} The order of magnitude
*/
Chartist.orderOfMagnitude = function (value) {
return Math.floor(Math.log(Math.abs(value)) / Math.LN10);
};
/**
* Project a data length into screen coordinates (pixels)
*
* @memberof Chartist.Core
* @param {Object} axisLength The svg element for the chart
* @param {Number} length Single data value from a series array
* @param {Object} bounds All the values to set the bounds of the chart
* @return {Number} The projected data length in pixels
*/
Chartist.projectLength = function (axisLength, length, bounds) {
return length / bounds.range * axisLength;
};
/**
* Get the height of the area in the chart for the data series
*
* @memberof Chartist.Core
* @param {Object} svg The svg element for the chart
* @param {Object} options The Object that contains all the optional values for the chart
* @return {Number} The height of the area in the chart for the data series
*/
Chartist.getAvailableHeight = function (svg, options) {
return Math.max((Chartist.quantity(options.height).value || svg.height()) - (options.chartPadding.top + options.chartPadding.bottom) - options.axisX.offset, 0);
};
/**
* Get highest and lowest value of data array. This Array contains the data that will be visualized in the chart.
*
* @memberof Chartist.Core
* @param {Array} data The array that contains the data to be visualized in the chart
* @param {Object} options The Object that contains the chart options
* @param {String} dimension Axis dimension 'x' or 'y' used to access the correct value and high / low configuration
* @return {Object} An object that contains the highest and lowest value that will be visualized on the chart.
*/
Chartist.getHighLow = function (data, options, dimension) {
// TODO: Remove workaround for deprecated global high / low config. Axis high / low configuration is preferred
options = Chartist.extend({}, options, dimension ? options['axis' + dimension.toUpperCase()] : {});
var highLow = {
high: options.high === undefined ? -Number.MAX_VALUE : +options.high,
low: options.low === undefined ? Number.MAX_VALUE : +options.low
};
var findHigh = options.high === undefined;
var findLow = options.low === undefined;
// Function to recursively walk through arrays and find highest and lowest number
function recursiveHighLow(data) {
if(data === undefined) {
return undefined;
} else if(data instanceof Array) {
for (var i = 0; i < data.length; i++) {
recursiveHighLow(data[i]);
}
} else {
var value = dimension ? +data[dimension] : +data;
if (findHigh && value > highLow.high) {
highLow.high = value;
}
if (findLow && value < highLow.low) {
highLow.low = value;
}
}
}
// Start to find highest and lowest number recursively
if(findHigh || findLow) {
recursiveHighLow(data);
}
// Overrides of high / low based on reference value, it will make sure that the invisible reference value is
// used to generate the chart. This is useful when the chart always needs to contain the position of the
// invisible reference value in the view i.e. for bipolar scales.
if (options.referenceValue || options.referenceValue === 0) {
highLow.high = Math.max(options.referenceValue, highLow.high);
highLow.low = Math.min(options.referenceValue, highLow.low);
}
// If high and low are the same because of misconfiguration or flat data (only the same value) we need
// to set the high or low to 0 depending on the polarity
if (highLow.high <= highLow.low) {
// If both values are 0 we set high to 1
if (highLow.low === 0) {
highLow.high = 1;
} else if (highLow.low < 0) {
// If we have the same negative value for the bounds we set bounds.high to 0
highLow.high = 0;
} else if (highLow.high > 0) {
// If we have the same positive value for the bounds we set bounds.low to 0
highLow.low = 0;
} else {
// If data array was empty, values are Number.MAX_VALUE and -Number.MAX_VALUE. Set bounds to prevent errors
highLow.high = 1;
highLow.low = 0;
}
}
return highLow;
};
/**
* Checks if the value is a valid number or string with a number.
*
* @memberof Chartist.Core
* @param value
* @returns {Boolean}
*/
Chartist.isNum = function(value) {
return !isNaN(value) && isFinite(value);
};
/**
* Returns true on all falsey values except the numeric value 0.
*
* @memberof Chartist.Core
* @param value
* @returns {boolean}
*/
Chartist.isFalseyButZero = function(value) {
return !value && value !== 0;
};
/**
* Returns a number if the passed parameter is a valid number or the function will return undefined. On all other values than a valid number, this function will return undefined.
*
* @memberof Chartist.Core
* @param value
* @returns {*}
*/
Chartist.getNumberOrUndefined = function(value) {
return isNaN(+value) ? undefined : +value;
};
/**
* Gets a value from a dimension `value.x` or `value.y` while returning value directly if it's a valid numeric value. If the value is not numeric and it's falsey this function will return undefined.
*
* @param value
* @param dimension
* @returns {*}
*/
Chartist.getMultiValue = function(value, dimension) {
if(Chartist.isNum(value)) {
return +value;
} else if(value) {
return value[dimension || 'y'] || 0;
} else {
return 0;
}
};
/**
* Pollard Rho Algorithm to find smallest factor of an integer value. There are more efficient algorithms for factorization, but this one is quite efficient and not so complex.
*
* @memberof Chartist.Core
* @param {Number} num An integer number where the smallest factor should be searched for
* @returns {Number} The smallest integer factor of the parameter num.
*/
Chartist.rho = function(num) {
if(num === 1) {
return num;
}
function gcd(p, q) {
if (p % q === 0) {
return q;
} else {
return gcd(q, p % q);
}
}
function f(x) {
return x * x + 1;
}
var x1 = 2, x2 = 2, divisor;
if (num % 2 === 0) {
return 2;
}
do {
x1 = f(x1) % num;
x2 = f(f(x2)) % num;
divisor = gcd(Math.abs(x1 - x2), num);
} while (divisor === 1);
return divisor;
};
/**
* Calculate and retrieve all the bounds for the chart and return them in one array
*
* @memberof Chartist.Core
* @param {Number} axisLength The length of the Axis used for
* @param {Object} highLow An object containing a high and low property indicating the value range of the chart.
* @param {Number} scaleMinSpace The minimum projected length a step should result in
* @param {Boolean} onlyInteger
* @return {Object} All the values to set the bounds of the chart
*/
Chartist.getBounds = function (axisLength, highLow, scaleMinSpace, onlyInteger) {
var i,
optimizationCounter = 0,
newMin,
newMax,
bounds = {
high: highLow.high,
low: highLow.low
};
bounds.valueRange = bounds.high - bounds.low;
bounds.oom = Chartist.orderOfMagnitude(bounds.valueRange);
bounds.step = Math.pow(10, bounds.oom);
bounds.min = Math.floor(bounds.low / bounds.step) * bounds.step;
bounds.max = Math.ceil(bounds.high / bounds.step) * bounds.step;
bounds.range = bounds.max - bounds.min;
bounds.numberOfSteps = Math.round(bounds.range / bounds.step);
// Optimize scale step by checking if subdivision is possible based on horizontalGridMinSpace
// If we are already below the scaleMinSpace value we will scale up
var length = Chartist.projectLength(axisLength, bounds.step, bounds);
var scaleUp = length < scaleMinSpace;
var smallestFactor = onlyInteger ? Chartist.rho(bounds.range) : 0;
// First check if we should only use integer steps and if step 1 is still larger than scaleMinSpace so we can use 1
if(onlyInteger && Chartist.projectLength(axisLength, 1, bounds) >= scaleMinSpace) {
bounds.step = 1;
} else if(onlyInteger && smallestFactor < bounds.step && Chartist.projectLength(axisLength, smallestFactor, bounds) >= scaleMinSpace) {
// If step 1 was too small, we can try the smallest factor of range
// If the smallest factor is smaller than the current bounds.step and the projected length of smallest factor
// is larger than the scaleMinSpace we should go for it.
bounds.step = smallestFactor;
} else {
// Trying to divide or multiply by 2 and find the best step value
while (true) {
if (scaleUp && Chartist.projectLength(axisLength, bounds.step, bounds) <= scaleMinSpace) {
bounds.step *= 2;
} else if (!scaleUp && Chartist.projectLength(axisLength, bounds.step / 2, bounds) >= scaleMinSpace) {
bounds.step /= 2;
if(onlyInteger && bounds.step % 1 !== 0) {
bounds.step *= 2;
break;
}
} else {
break;
}
if(optimizationCounter++ > 1000) {
throw new Error('Exceeded maximum number of iterations while optimizing scale step!');
}
}
}
// step must not be less than EPSILON to create values that can be represented as floating number.
var EPSILON = 2.221E-16;
bounds.step = Math.max(bounds.step, EPSILON);
// Narrow min and max based on new step
newMin = bounds.min;
newMax = bounds.max;
while(newMin + bounds.step <= bounds.low) {
newMin += bounds.step;
}
while(newMax - bounds.step >= bounds.high) {
newMax -= bounds.step;
}
bounds.min = newMin;
bounds.max = newMax;
bounds.range = bounds.max - bounds.min;
var values = [];
for (i = bounds.min; i <= bounds.max; i += bounds.step) {
var value = Chartist.roundWithPrecision(i);
if (value !== values[values.length - 1]) {
values.push(i);
}
}
bounds.values = values;
return bounds;
};
/**
* Calculate cartesian coordinates of polar coordinates
*
* @memberof Chartist.Core
* @param {Number} centerX X-axis coordinates of center point of circle segment
* @param {Number} centerY X-axis coordinates of center point of circle segment
* @param {Number} radius Radius of circle segment
* @param {Number} angleInDegrees Angle of circle segment in degrees
* @return {{x:Number, y:Number}} Coordinates of point on circumference
*/
Chartist.polarToCartesian = function (centerX, centerY, radius, angleInDegrees) {
var angleInRadians = (angleInDegrees - 90) * Math.PI / 180.0;
return {
x: centerX + (radius * Math.cos(angleInRadians)),
y: centerY + (radius * Math.sin(angleInRadians))
};
};
/**
* Initialize chart drawing rectangle (area where chart is drawn) x1,y1 = bottom left / x2,y2 = top right
*
* @memberof Chartist.Core
* @param {Object} svg The svg element for the chart
* @param {Object} options The Object that contains all the optional values for the chart
* @param {Number} [fallbackPadding] The fallback padding if partial padding objects are used
* @return {Object} The chart rectangles coordinates inside the svg element plus the rectangles measurements
*/
Chartist.createChartRect = function (svg, options, fallbackPadding) {
var hasAxis = !!(options.axisX || options.axisY);
var yAxisOffset = hasAxis ? options.axisY.offset : 0;
var xAxisOffset = hasAxis ? options.axisX.offset : 0;
// If width or height results in invalid value (including 0) we fallback to the unitless settings or even 0
var width = svg.width() || Chartist.quantity(options.width).value || 0;
var height = svg.height() || Chartist.quantity(options.height).value || 0;
var normalizedPadding = Chartist.normalizePadding(options.chartPadding, fallbackPadding);
// If settings were to small to cope with offset (legacy) and padding, we'll adjust
width = Math.max(width, yAxisOffset + normalizedPadding.left + normalizedPadding.right);
height = Math.max(height, xAxisOffset + normalizedPadding.top + normalizedPadding.bottom);
var chartRect = {
padding: normalizedPadding,
width: function () {
return this.x2 - this.x1;
},
height: function () {
return this.y1 - this.y2;
}
};
if(hasAxis) {
if (options.axisX.position === 'start') {
chartRect.y2 = normalizedPadding.top + xAxisOffset;
chartRect.y1 = Math.max(height - normalizedPadding.bottom, chartRect.y2 + 1);
} else {
chartRect.y2 = normalizedPadding.top;
chartRect.y1 = Math.max(height - normalizedPadding.bottom - xAxisOffset, chartRect.y2 + 1);
}
if (options.axisY.position === 'start') {
chartRect.x1 = normalizedPadding.left + yAxisOffset;
chartRect.x2 = Math.max(width - normalizedPadding.right, chartRect.x1 + 1);
} else {
chartRect.x1 = normalizedPadding.left;
chartRect.x2 = Math.max(width - normalizedPadding.right - yAxisOffset, chartRect.x1 + 1);
}
} else {
chartRect.x1 = normalizedPadding.left;
chartRect.x2 = Math.max(width - normalizedPadding.right, chartRect.x1 + 1);
chartRect.y2 = normalizedPadding.top;
chartRect.y1 = Math.max(height - normalizedPadding.bottom, chartRect.y2 + 1);
}
return chartRect;
};
/**
* Creates a grid line based on a projected value.
*
* @memberof Chartist.Core
* @param position
* @param index
* @param axis
* @param offset
* @param length
* @param group
* @param classes
* @param eventEmitter
*/
Chartist.createGrid = function(position, index, axis, offset, length, group, classes, eventEmitter) {
var positionalData = {};
positionalData[axis.units.pos + '1'] = position;
positionalData[axis.units.pos + '2'] = position;
positionalData[axis.counterUnits.pos + '1'] = offset;
positionalData[axis.counterUnits.pos + '2'] = offset + length;
var gridElement = group.elem('line', positionalData, classes.join(' '));
// Event for grid draw
eventEmitter.emit('draw',
Chartist.extend({
type: 'grid',
axis: axis,
index: index,
group: group,
element: gridElement
}, positionalData)
);
};
/**
* Creates a label based on a projected value and an axis.
*
* @memberof Chartist.Core
* @param position
* @param length
* @param index
* @param labels
* @param axis
* @param axisOffset
* @param labelOffset
* @param group
* @param classes
* @param useForeignObject
* @param eventEmitter
*/
Chartist.createLabel = function(position, length, index, labels, axis, axisOffset, labelOffset, group, classes, useForeignObject, eventEmitter) {
var labelElement;
var positionalData = {};
positionalData[axis.units.pos] = position + labelOffset[axis.units.pos];
positionalData[axis.counterUnits.pos] = labelOffset[axis.counterUnits.pos];
positionalData[axis.units.len] = length;
positionalData[axis.counterUnits.len] = Math.max(0, axisOffset - 10);
if(useForeignObject) {
// We need to set width and height explicitly to px as span will not expand with width and height being
// 100% in all browsers
var content = '<span class="' + classes.join(' ') + '" style="' +
axis.units.len + ': ' + Math.round(positionalData[axis.units.len]) + 'px; ' +
axis.counterUnits.len + ': ' + Math.round(positionalData[axis.counterUnits.len]) + 'px">' +
labels[index] + '</span>';
labelElement = group.foreignObject(content, Chartist.extend({
style: 'overflow: visible;'
}, positionalData));
} else {
labelElement = group.elem('text', positionalData, classes.join(' ')).text(labels[index]);
}
eventEmitter.emit('draw', Chartist.extend({
type: 'label',
axis: axis,
index: index,
group: group,
element: labelElement,
text: labels[index]
}, positionalData));
};
/**
* Helper to read series specific options from options object. It automatically falls back to the global option if
* there is no option in the series options.
*
* @param {Object} series Series object
* @param {Object} options Chartist options object
* @param {string} key The options key that should be used to obtain the options
* @returns {*}
*/
Chartist.getSeriesOption = function(series, options, key) {
if(series.name && options.series && options.series[series.name]) {
var seriesOptions = options.series[series.name];
return seriesOptions.hasOwnProperty(key) ? seriesOptions[key] : options[key];
} else {
return options[key];
}
};
/**
* Provides options handling functionality with callback for options changes triggered by responsive options and media query matches
*
* @memberof Chartist.Core
* @param {Object} options Options set by user
* @param {Array} responsiveOptions Optional functions to add responsive behavior to chart
* @param {Object} eventEmitter The event emitter that will be used to emit the options changed events
* @return {Object} The consolidated options object from the defaults, base and matching responsive options
*/
Chartist.optionsProvider = function (options, responsiveOptions, eventEmitter) {
var baseOptions = Chartist.extend({}, options),
currentOptions,
mediaQueryListeners = [],
i;
function updateCurrentOptions(mediaEvent) {
var previousOptions = currentOptions;
currentOptions = Chartist.extend({}, baseOptions);
if (responsiveOptions) {
for (i = 0; i < responsiveOptions.length; i++) {
var mql = window.matchMedia(responsiveOptions[i][0]);
if (mql.matches) {
currentOptions = Chartist.extend(currentOptions, responsiveOptions[i][1]);
}
}
}
if(eventEmitter && mediaEvent) {
eventEmitter.emit('optionsChanged', {
previousOptions: previousOptions,
currentOptions: currentOptions
});
}
}
function removeMediaQueryListeners() {
mediaQueryListeners.forEach(function(mql) {
mql.removeListener(updateCurrentOptions);
});
}
if (!window.matchMedia) {
throw 'window.matchMedia not found! Make sure you\'re using a polyfill.';
} else if (responsiveOptions) {
for (i = 0; i < responsiveOptions.length; i++) {
var mql = window.matchMedia(responsiveOptions[i][0]);
mql.addListener(updateCurrentOptions);
mediaQueryListeners.push(mql);
}
}
// Execute initially without an event argument so we get the correct options
updateCurrentOptions();
return {
removeMediaQueryListeners: removeMediaQueryListeners,
getCurrentOptions: function getCurrentOptions() {
return Chartist.extend({}, currentOptions);
}
};
};
/**
* Splits a list of coordinates and associated values into segments. Each returned segment contains a pathCoordinates
* valueData property describing the segment.
*
* With the default options, segments consist of contiguous sets of points that do not have an undefined value. Any
* points with undefined values are discarded.
*
* **Options**
* The following options are used to determine how segments are formed
* ```javascript
* var options = {
* // If fillHoles is true, undefined values are simply discarded without creating a new segment. Assuming other options are default, this returns single segment.
* fillHoles: false,
* // If increasingX is true, the coordinates in all segments have strictly increasing x-values.
* increasingX: false
* };
* ```
*
* @memberof Chartist.Core
* @param {Array} pathCoordinates List of point coordinates to be split in the form [x1, y1, x2, y2 ... xn, yn]
* @param {Array} values List of associated point values in the form [v1, v2 .. vn]
* @param {Object} options Options set by user
* @return {Array} List of segments, each containing a pathCoordinates and valueData property.
*/
Chartist.splitIntoSegments = function(pathCoordinates, valueData, options) {
var defaultOptions = {
increasingX: false,
fillHoles: false
};
options = Chartist.extend({}, defaultOptions, options);
var segments = [];
var hole = true;
for(var i = 0; i < pathCoordinates.length; i += 2) {
// If this value is a "hole" we set the hole flag
if(valueData[i / 2].value === undefined) {
if(!options.fillHoles) {
hole = true;
}
} else {
if(options.increasingX && i >= 2 && pathCoordinates[i] <= pathCoordinates[i-2]) {
// X is not increasing, so we need to make sure we start a new segment
hole = true;
}
// If it's a valid value we need to check if we're coming out of a hole and create a new empty segment
if(hole) {
segments.push({
pathCoordinates: [],
valueData: []
});
// As we have a valid value now, we are not in a "hole" anymore
hole = false;
}
// Add to the segment pathCoordinates and valueData
segments[segments.length - 1].pathCoordinates.push(pathCoordinates[i], pathCoordinates[i + 1]);
segments[segments.length - 1].valueData.push(valueData[i / 2]);
}
}
return segments;
};
}(window, document, Chartist));
;/**
* Chartist path interpolation functions.
*
* @module Chartist.Interpolation
*/
/* global Chartist */
(function(window, document, Chartist) {
'use strict';
Chartist.Interpolation = {};
/**
* This interpolation function does not smooth the path and the result is only containing lines and no curves.
*
* @example
* var chart = new Chartist.Line('.ct-chart', {
* labels: [1, 2, 3, 4, 5],
* series: [[1, 2, 8, 1, 7]]
* }, {
* lineSmooth: Chartist.Interpolation.none({
* fillHoles: false
* })
* });
*
*
* @memberof Chartist.Interpolation
* @return {Function}
*/
Chartist.Interpolation.none = function(options) {
var defaultOptions = {
fillHoles: false
};
options = Chartist.extend({}, defaultOptions, options);
return function none(pathCoordinates, valueData) {
var path = new Chartist.Svg.Path();
var hole = true;
for(var i = 0; i < pathCoordinates.length; i += 2) {
var currX = pathCoordinates[i];
var currY = pathCoordinates[i + 1];
var currData = valueData[i / 2];
if(currData.value !== undefined) {
if(hole) {
path.move(currX, currY, false, currData);
} else {
path.line(currX, currY, false, currData);
}
hole = false;
} else if(!options.fillHoles) {
hole = true;
}
}
return path;
};
};
/**
* Simple smoothing creates horizontal handles that are positioned with a fraction of the length between two data points. You can use the divisor option to specify the amount of smoothing.
*
* Simple smoothing can be used instead of `Chartist.Smoothing.cardinal` if you'd like to get rid of the artifacts it produces sometimes. Simple smoothing produces less flowing lines but is accurate by hitting the points and it also doesn't swing below or above the given data point.
*
* All smoothing functions within Chartist are factory functions that accept an options parameter. The simple interpolation function accepts one configuration parameter `divisor`, between 1 and ∞, which controls the smoothing characteristics.
*
* @example
* var chart = new Chartist.Line('.ct-chart', {
* labels: [1, 2, 3, 4, 5],
* series: [[1, 2, 8, 1, 7]]
* }, {
* lineSmooth: Chartist.Interpolation.simple({
* divisor: 2,
* fillHoles: false
* })
* });
*
*
* @memberof Chartist.Interpolation
* @param {Object} options The options of the simple interpolation factory function.
* @return {Function}
*/
Chartist.Interpolation.simple = function(options) {
var defaultOptions = {
divisor: 2,
fillHoles: false
};
options = Chartist.extend({}, defaultOptions, options);
var d = 1 / Math.max(1, options.divisor);
return function simple(pathCoordinates, valueData) {
var path = new Chartist.Svg.Path();
var prevX, prevY, prevData;
for(var i = 0; i < pathCoordinates.length; i += 2) {
var currX = pathCoordinates[i];
var currY = pathCoordinates[i + 1];
var length = (currX - prevX) * d;
var currData = valueData[i / 2];
if(currData.value !== undefined) {
if(prevData === undefined) {
path.move(currX, currY, false, currData);
} else {
path.curve(
prevX + length,
prevY,
currX - length,
currY,
currX,
currY,
false,
currData
);
}
prevX = currX;
prevY = currY;
prevData = currData;
} else if(!options.fillHoles) {
prevX = currX = prevData = undefined;
}
}
return path;
};
};
/**
* Cardinal / Catmull-Rome spline interpolation is the default smoothing function in Chartist. It produces nice results where the splines will always meet the points. It produces some artifacts though when data values are increased or decreased rapidly. The line may not follow a very accurate path and if the line should be accurate this smoothing function does not produce the best results.
*
* Cardinal splines can only be created if there are more than two data points. If this is not the case this smoothing will fallback to `Chartist.Smoothing.none`.
*
* All smoothing functions within Chartist are factory functions that accept an options parameter. The cardinal interpolation function accepts one configuration parameter `tension`, between 0 and 1, which controls the smoothing intensity.
*
* @example
* var chart = new Chartist.Line('.ct-chart', {
* labels: [1, 2, 3, 4, 5],
* series: [[1, 2, 8, 1, 7]]
* }, {
* lineSmooth: Chartist.Interpolation.cardinal({
* tension: 1,
* fillHoles: false
* })
* });
*
* @memberof Chartist.Interpolation
* @param {Object} options The options of the cardinal factory function.
* @return {Function}
*/
Chartist.Interpolation.cardinal = function(options) {
var defaultOptions = {
tension: 1,
fillHoles: false
};
options = Chartist.extend({}, defaultOptions, options);
var t = Math.min(1, Math.max(0, options.tension)),
c = 1 - t;
return function cardinal(pathCoordinates, valueData) {
// First we try to split the coordinates into segments
// This is necessary to treat "holes" in line charts
var segments = Chartist.splitIntoSegments(pathCoordinates, valueData, {
fillHoles: options.fillHoles
});
if(!segments.length) {
// If there were no segments return 'Chartist.Interpolation.none'
return Chartist.Interpolation.none()([]);
} else if(segments.length > 1) {
// If the split resulted in more that one segment we need to interpolate each segment individually and join them
// afterwards together into a single path.
var paths = [];
// For each segment we will recurse the cardinal function
segments.forEach(function(segment) {
paths.push(cardinal(segment.pathCoordinates, segment.valueData));
});
// Join the segment path data into a single path and return
return Chartist.Svg.Path.join(paths);
} else {
// If there was only one segment we can proceed regularly by using pathCoordinates and valueData from the first
// segment
pathCoordinates = segments[0].pathCoordinates;
valueData = segments[0].valueData;
// If less than two points we need to fallback to no smoothing
if(pathCoordinates.length <= 4) {
return Chartist.Interpolation.none()(pathCoordinates, valueData);
}
var path = new Chartist.Svg.Path().move(pathCoordinates[0], pathCoordinates[1], false, valueData[0]),
z;
for (var i = 0, iLen = pathCoordinates.length; iLen - 2 * !z > i; i += 2) {
var p = [
{x: +pathCoordinates[i - 2], y: +pathCoordinates[i - 1]},
{x: +pathCoordinates[i], y: +pathCoordinates[i + 1]},
{x: +pathCoordinates[i + 2], y: +pathCoordinates[i + 3]},
{x: +pathCoordinates[i + 4], y: +pathCoordinates[i + 5]}
];
if (z) {
if (!i) {
p[0] = {x: +pathCoordinates[iLen - 2], y: +pathCoordinates[iLen - 1]};
} else if (iLen - 4 === i) {
p[3] = {x: +pathCoordinates[0], y: +pathCoordinates[1]};
} else if (iLen - 2 === i) {
p[2] = {x: +pathCoordinates[0], y: +pathCoordinates[1]};
p[3] = {x: +pathCoordinates[2], y: +pathCoordinates[3]};
}
} else {
if (iLen - 4 === i) {
p[3] = p[2];
} else if (!i) {
p[0] = {x: +pathCoordinates[i], y: +pathCoordinates[i + 1]};
}
}
path.curve(
(t * (-p[0].x + 6 * p[1].x + p[2].x) / 6) + (c * p[2].x),
(t * (-p[0].y + 6 * p[1].y + p[2].y) / 6) + (c * p[2].y),
(t * (p[1].x + 6 * p[2].x - p[3].x) / 6) + (c * p[2].x),
(t * (p[1].y + 6 * p[2].y - p[3].y) / 6) + (c * p[2].y),
p[2].x,
p[2].y,
false,
valueData[(i + 2) / 2]
);
}
return path;
}
};
};
/**
* Monotone Cubic spline interpolation produces a smooth curve which preserves monotonicity. Unlike cardinal splines, the curve will not extend beyond the range of y-values of the original data points.
*
* Monotone Cubic splines can only be created if there are more than two data points. If this is not the case this smoothing will fallback to `Chartist.Smoothing.none`.
*
* The x-values of subsequent points must be increasing to fit a Monotone Cubic spline. If this condition is not met for a pair of adjacent points, then there will be a break in the curve between those data points.
*
* All smoothing functions within Chartist are factory functions that accept an options parameter.
*
* @example
* var chart = new Chartist.Line('.ct-chart', {
* labels: [1, 2, 3, 4, 5],
* series: [[1, 2, 8, 1, 7]]
* }, {
* lineSmooth: Chartist.Interpolation.monotoneCubic({
* fillHoles: false
* })
* });
*
* @memberof Chartist.Interpolation
* @param {Object} options The options of the monotoneCubic factory function.
* @return {Function}
*/
Chartist.Interpolation.monotoneCubic = function(options) {
var defaultOptions = {
fillHoles: false
};
options = Chartist.extend({}, defaultOptions, options);
return function monotoneCubic(pathCoordinates, valueData) {
// First we try to split the coordinates into segments
// This is necessary to treat "holes" in line charts
var segments = Chartist.splitIntoSegments(pathCoordinates, valueData, {
fillHoles: options.fillHoles,
increasingX: true
});
if(!segments.length) {
// If there were no segments return 'Chartist.Interpolation.none'
return Chartist.Interpolation.none()([]);
} else if(segments.length > 1) {
// If the split resulted in more that one segment we need to interpolate each segment individually and join them
// afterwards together into a single path.
var paths = [];
// For each segment we will recurse the monotoneCubic fn function
segments.forEach(function(segment) {
paths.push(monotoneCubic(segment.pathCoordinates, segment.valueData));
});
// Join the segment path data into a single path and return
return Chartist.Svg.Path.join(paths);
} else {
// If there was only one segment we can proceed regularly by using pathCoordinates and valueData from the first
// segment
pathCoordinates = segments[0].pathCoordinates;
valueData = segments[0].valueData;
// If less than three points we need to fallback to no smoothing
if(pathCoordinates.length <= 4) {
return Chartist.Interpolation.none()(pathCoordinates, valueData);
}
var xs = [],
ys = [],
i,
n = pathCoordinates.length / 2,
ms = [],
ds = [], dys = [], dxs = [],
path;
// Populate x and y coordinates into separate arrays, for readability
for(i = 0; i < n; i++) {
xs[i] = pathCoordinates[i * 2];
ys[i] = pathCoordinates[i * 2 + 1];
}
// Calculate deltas and derivative
for(i = 0; i < n - 1; i++) {
dys[i] = ys[i + 1] - ys[i];
dxs[i] = xs[i + 1] - xs[i];
ds[i] = dys[i] / dxs[i];
}
// Determine desired slope (m) at each point using Fritsch-Carlson method
// See: http://math.stackexchange.com/questions/45218/implementation-of-monotone-cubic-interpolation
ms[0] = ds[0];
ms[n - 1] = ds[n - 2];
for(i = 1; i < n - 1; i++) {
if(ds[i] === 0 || ds[i - 1] === 0 || (ds[i - 1] > 0) !== (ds[i] > 0)) {
ms[i] = 0;
} else {
ms[i] = 3 * (dxs[i - 1] + dxs[i]) / (
(2 * dxs[i] + dxs[i - 1]) / ds[i - 1] +
(dxs[i] + 2 * dxs[i - 1]) / ds[i]);
if(!isFinite(ms[i])) {
ms[i] = 0;
}
}
}
// Now build a path from the slopes
path = new Chartist.Svg.Path().move(xs[0], ys[0], false, valueData[0]);
for(i = 0; i < n - 1; i++) {
path.curve(
// First control point
xs[i] + dxs[i] / 3,
ys[i] + ms[i] * dxs[i] / 3,
// Second control point
xs[i + 1] - dxs[i] / 3,
ys[i + 1] - ms[i + 1] * dxs[i] / 3,
// End point
xs[i + 1],
ys[i + 1],
false,
valueData[i + 1]
);
}
return path;
}
};
};
/**
* Step interpolation will cause the line chart to move in steps rather than diagonal or smoothed lines. This interpolation will create additional points that will also be drawn when the `showPoint` option is enabled.
*
* All smoothing functions within Chartist are factory functions that accept an options parameter. The step interpolation function accepts one configuration parameter `postpone`, that can be `true` or `false`. The default value is `true` and will cause the step to occur where the value actually changes. If a different behaviour is needed where the step is shifted to the left and happens before the actual value, this option can be set to `false`.
*
* @example
* var chart = new Chartist.Line('.ct-chart', {
* labels: [1, 2, 3, 4, 5],
* series: [[1, 2, 8, 1, 7]]
* }, {
* lineSmooth: Chartist.Interpolation.step({
* postpone: true,
* fillHoles: false
* })
* });
*
* @memberof Chartist.Interpolation
* @param options
* @returns {Function}
*/
Chartist.Interpolation.step = function(options) {
var defaultOptions = {
postpone: true,
fillHoles: false
};
options = Chartist.extend({}, defaultOptions, options);
return function step(pathCoordinates, valueData) {
var path = new Chartist.Svg.Path();
var prevX, prevY, prevData;
for (var i = 0; i < pathCoordinates.length; i += 2) {
var currX = pathCoordinates[i];
var currY = pathCoordinates[i + 1];
var currData = valueData[i / 2];
// If the current point is also not a hole we can draw the step lines
if(currData.value !== undefined) {
if(prevData === undefined) {
path.move(currX, currY, false, currData);
} else {
if(options.postpone) {
// If postponed we should draw the step line with the value of the previous value
path.line(currX, prevY, false, prevData);
} else {
// If not postponed we should draw the step line with the value of the current value
path.line(prevX, currY, false, currData);
}
// Line to the actual point (this should only be a Y-Axis movement
path.line(currX, currY, false, currData);
}
prevX = currX;
prevY = currY;
prevData = currData;
} else if(!options.fillHoles) {
prevX = prevY = prevData = undefined;
}
}
return path;
};
};
}(window, document, Chartist));
;/**
* A very basic event module that helps to generate and catch events.
*
* @module Chartist.Event
*/
/* global Chartist */
(function (window, document, Chartist) {
'use strict';
Chartist.EventEmitter = function () {
var handlers = [];
/**
* Add an event handler for a specific event
*
* @memberof Chartist.Event
* @param {String} event The event name
* @param {Function} handler A event handler function
*/
function addEventHandler(event, handler) {
handlers[event] = handlers[event] || [];
handlers[event].push(handler);
}
/**
* Remove an event handler of a specific event name or remove all event handlers for a specific event.
*
* @memberof Chartist.Event
* @param {String} event The event name where a specific or all handlers should be removed
* @param {Function} [handler] An optional event handler function. If specified only this specific handler will be removed and otherwise all handlers are removed.
*/
function removeEventHandler(event, handler) {
// Only do something if there are event handlers with this name existing
if(handlers[event]) {
// If handler is set we will look for a specific handler and only remove this
if(handler) {
handlers[event].splice(handlers[event].indexOf(handler), 1);
if(handlers[event].length === 0) {
delete handlers[event];
}
} else {
// If no handler is specified we remove all handlers for this event
delete handlers[event];
}
}
}
/**
* Use this function to emit an event. All handlers that are listening for this event will be triggered with the data parameter.
*
* @memberof Chartist.Event
* @param {String} event The event name that should be triggered
* @param {*} data Arbitrary data that will be passed to the event handler callback functions
*/
function emit(event, data) {
// Only do something if there are event handlers with this name existing
if(handlers[event]) {
handlers[event].forEach(function(handler) {
handler(data);
});
}
// Emit event to star event handlers
if(handlers['*']) {
handlers['*'].forEach(function(starHandler) {
starHandler(event, data);
});
}
}
return {
addEventHandler: addEventHandler,
removeEventHandler: removeEventHandler,
emit: emit
};
};
}(window, document, Chartist));
;/**
* This module provides some basic prototype inheritance utilities.
*
* @module Chartist.Class
*/
/* global Chartist */
(function(window, document, Chartist) {
'use strict';
function listToArray(list) {
var arr = [];
if (list.length) {
for (var i = 0; i < list.length; i++) {
arr.push(list[i]);
}
}
return arr;
}
/**
* Method to extend from current prototype.
*
* @memberof Chartist.Class
* @param {Object} properties The object that serves as definition for the prototype that gets created for the new class. This object should always contain a constructor property that is the desired constructor for the newly created class.
* @param {Object} [superProtoOverride] By default extens will use the current class prototype or Chartist.class. With this parameter you can specify any super prototype that will be used.
* @return {Function} Constructor function of the new class
*
* @example
* var Fruit = Class.extend({
* color: undefined,
* sugar: undefined,
*
* constructor: function(color, sugar) {
* this.color = color;
* this.sugar = sugar;
* },
*
* eat: function() {
* this.sugar = 0;
* return this;
* }
* });
*
* var Banana = Fruit.extend({
* length: undefined,
*
* constructor: function(length, sugar) {
* Banana.super.constructor.call(this, 'Yellow', sugar);
* this.length = length;
* }
* });
*
* var banana = new Banana(20, 40);
* console.log('banana instanceof Fruit', banana instanceof Fruit);
* console.log('Fruit is prototype of banana', Fruit.prototype.isPrototypeOf(banana));
* console.log('bananas prototype is Fruit', Object.getPrototypeOf(banana) === Fruit.prototype);
* console.log(banana.sugar);
* console.log(banana.eat().sugar);
* console.log(banana.color);
*/
function extend(properties, superProtoOverride) {
var superProto = superProtoOverride || this.prototype || Chartist.Class;
var proto = Object.create(superProto);
Chartist.Class.cloneDefinitions(proto, properties);
var constr = function() {
var fn = proto.constructor || function () {},
instance;
// If this is linked to the Chartist namespace the constructor was not called with new
// To provide a fallback we will instantiate here and return the instance
instance = this === Chartist ? Object.create(proto) : this;
fn.apply(instance, Array.prototype.slice.call(arguments, 0));
// If this constructor was not called with new we need to return the instance
// This will not harm when the constructor has been called with new as the returned value is ignored
return instance;
};
constr.prototype = proto;
constr.super = superProto;
constr.extend = this.extend;
return constr;
}
// Variable argument list clones args > 0 into args[0] and retruns modified args[0]
function cloneDefinitions() {
var args = listToArray(arguments);
var target = args[0];
args.splice(1, args.length - 1).forEach(function (source) {
Object.getOwnPropertyNames(source).forEach(function (propName) {
// If this property already exist in target we delete it first
delete target[propName];
// Define the property with the descriptor from source
Object.defineProperty(target, propName,
Object.getOwnPropertyDescriptor(source, propName));
});
});
return target;
}
Chartist.Class = {
extend: extend,
cloneDefinitions: cloneDefinitions
};
}(window, document, Chartist));
;/**
* Base for all chart types. The methods in Chartist.Base are inherited to all chart types.
*
* @module Chartist.Base
*/
/* global Chartist */
(function(window, document, Chartist) {
'use strict';
// TODO: Currently we need to re-draw the chart on window resize. This is usually very bad and will affect performance.
// This is done because we can't work with relative coordinates when drawing the chart because SVG Path does not
// work with relative positions yet. We need to check if we can do a viewBox hack to switch to percentage.
// See http://mozilla.6506.n7.nabble.com/Specyfing-paths-with-percentages-unit-td247474.html
// Update: can be done using the above method tested here: http://codepen.io/gionkunz/pen/KDvLj
// The problem is with the label offsets that can't be converted into percentage and affecting the chart container
/**
* Updates the chart which currently does a full reconstruction of the SVG DOM
*
* @param {Object} [data] Optional data you'd like to set for the chart before it will update. If not specified the update method will use the data that is already configured with the chart.
* @param {Object} [options] Optional options you'd like to add to the previous options for the chart before it will update. If not specified the update method will use the options that have been already configured with the chart.
* @param {Boolean} [override] If set to true, the passed options will be used to extend the options that have been configured already. Otherwise the chart default options will be used as the base
* @memberof Chartist.Base
*/
function update(data, options, override) {
if(data) {
this.data = data;
// Event for data transformation that allows to manipulate the data before it gets rendered in the charts
this.eventEmitter.emit('data', {
type: 'update',
data: this.data
});
}
if(options) {
this.options = Chartist.extend({}, override ? this.options : this.defaultOptions, options);
// If chartist was not initialized yet, we just set the options and leave the rest to the initialization
// Otherwise we re-create the optionsProvider at this point
if(!this.initializeTimeoutId) {
this.optionsProvider.removeMediaQueryListeners();
this.optionsProvider = Chartist.optionsProvider(this.options, this.responsiveOptions, this.eventEmitter);
}
}
// Only re-created the chart if it has been initialized yet
if(!this.initializeTimeoutId) {
this.createChart(this.optionsProvider.getCurrentOptions());
}
// Return a reference to the chart object to chain up calls
return this;
}
/**
* This method can be called on the API object of each chart and will un-register all event listeners that were added to other components. This currently includes a window.resize listener as well as media query listeners if any responsive options have been provided. Use this function if you need to destroy and recreate Chartist charts dynamically.
*
* @memberof Chartist.Base
*/
function detach() {
// Only detach if initialization already occurred on this chart. If this chart still hasn't initialized (therefore
// the initializationTimeoutId is still a valid timeout reference, we will clear the timeout
if(!this.initializeTimeoutId) {
window.removeEventListener('resize', this.resizeListener);
this.optionsProvider.removeMediaQueryListeners();
} else {
window.clearTimeout(this.initializeTimeoutId);
}
return this;
}
/**
* Use this function to register event handlers. The handler callbacks are synchronous and will run in the main thread rather than the event loop.
*
* @memberof Chartist.Base
* @param {String} event Name of the event. Check the examples for supported events.
* @param {Function} handler The handler function that will be called when an event with the given name was emitted. This function will receive a data argument which contains event data. See the example for more details.
*/
function on(event, handler) {
this.eventEmitter.addEventHandler(event, handler);
return this;
}
/**
* Use this function to un-register event handlers. If the handler function parameter is omitted all handlers for the given event will be un-registered.
*
* @memberof Chartist.Base
* @param {String} event Name of the event for which a handler should be removed
* @param {Function} [handler] The handler function that that was previously used to register a new event handler. This handler will be removed from the event handler list. If this parameter is omitted then all event handlers for the given event are removed from the list.
*/
function off(event, handler) {
this.eventEmitter.removeEventHandler(event, handler);
return this;
}
function initialize() {
// Add window resize listener that re-creates the chart
window.addEventListener('resize', this.resizeListener);
// Obtain current options based on matching media queries (if responsive options are given)
// This will also register a listener that is re-creating the chart based on media changes
this.optionsProvider = Chartist.optionsProvider(this.options, this.responsiveOptions, this.eventEmitter);
// Register options change listener that will trigger a chart update
this.eventEmitter.addEventHandler('optionsChanged', function() {
this.update();
}.bind(this));
// Before the first chart creation we need to register us with all plugins that are configured
// Initialize all relevant plugins with our chart object and the plugin options specified in the config
if(this.options.plugins) {
this.options.plugins.forEach(function(plugin) {
if(plugin instanceof Array) {
plugin[0](this, plugin[1]);
} else {
plugin(this);
}
}.bind(this));
}
// Event for data transformation that allows to manipulate the data before it gets rendered in the charts
this.eventEmitter.emit('data', {
type: 'initial',
data: this.data
});
// Create the first chart
this.createChart(this.optionsProvider.getCurrentOptions());
// As chart is initialized from the event loop now we can reset our timeout reference
// This is important if the chart gets initialized on the same element twice
this.initializeTimeoutId = undefined;
}
/**
* Constructor of chart base class.
*
* @param query
* @param data
* @param defaultOptions
* @param options
* @param responsiveOptions
* @constructor
*/
function Base(query, data, defaultOptions, options, responsiveOptions) {
this.container = Chartist.querySelector(query);
this.data = data;
this.defaultOptions = defaultOptions;
this.options = options;
this.responsiveOptions = responsiveOptions;
this.eventEmitter = Chartist.EventEmitter();
this.supportsForeignObject = Chartist.Svg.isSupported('Extensibility');
this.supportsAnimations = Chartist.Svg.isSupported('AnimationEventsAttribute');
this.resizeListener = function resizeListener(){
this.update();
}.bind(this);
if(this.container) {
// If chartist was already initialized in this container we are detaching all event listeners first
if(this.container.__chartist__) {
this.container.__chartist__.detach();
}
this.container.__chartist__ = this;
}
// Using event loop for first draw to make it possible to register event listeners in the same call stack where
// the chart was created.
this.initializeTimeoutId = setTimeout(initialize.bind(this), 0);
}
// Creating the chart base class
Chartist.Base = Chartist.Class.extend({
constructor: Base,
optionsProvider: undefined,
container: undefined,
svg: undefined,
eventEmitter: undefined,
createChart: function() {
throw new Error('Base chart type can\'t be instantiated!');
},
update: update,
detach: detach,
on: on,
off: off,
version: Chartist.version,
supportsForeignObject: false
});
}(window, document, Chartist));
;/**
* Chartist SVG module for simple SVG DOM abstraction
*
* @module Chartist.Svg
*/
/* global Chartist */
(function(window, document, Chartist) {
'use strict';
/**
* Chartist.Svg creates a new SVG object wrapper with a starting element. You can use the wrapper to fluently create sub-elements and modify them.
*
* @memberof Chartist.Svg
* @constructor
* @param {String|Element} name The name of the SVG element to create or an SVG dom element which should be wrapped into Chartist.Svg
* @param {Object} attributes An object with properties that will be added as attributes to the SVG element that is created. Attributes with undefined values will not be added.
* @param {String} className This class or class list will be added to the SVG element
* @param {Object} parent The parent SVG wrapper object where this newly created wrapper and it's element will be attached to as child
* @param {Boolean} insertFirst If this param is set to true in conjunction with a parent element the newly created element will be added as first child element in the parent element
*/
function Svg(name, attributes, className, parent, insertFirst) {
// If Svg is getting called with an SVG element we just return the wrapper
if(name instanceof Element) {
this._node = name;
} else {
this._node = document.createElementNS(Chartist.namespaces.svg, name);
// If this is an SVG element created then custom namespace
if(name === 'svg') {
this.attr({
'xmlns:ct': Chartist.namespaces.ct
});
}
}
if(attributes) {
this.attr(attributes);
}
if(className) {
this.addClass(className);
}
if(parent) {
if (insertFirst && parent._node.firstChild) {
parent._node.insertBefore(this._node, parent._node.firstChild);
} else {
parent._node.appendChild(this._node);
}
}
}
/**
* Set attributes on the current SVG element of the wrapper you're currently working on.
*
* @memberof Chartist.Svg
* @param {Object|String} attributes An object with properties that will be added as attributes to the SVG element that is created. Attributes with undefined values will not be added. If this parameter is a String then the function is used as a getter and will return the attribute value.
* @param {String} ns If specified, the attribute will be obtained using getAttributeNs. In order to write namepsaced attributes you can use the namespace:attribute notation within the attributes object.
* @return {Object|String} The current wrapper object will be returned so it can be used for chaining or the attribute value if used as getter function.
*/
function attr(attributes, ns) {
if(typeof attributes === 'string') {
if(ns) {
return this._node.getAttributeNS(ns, attributes);
} else {
return this._node.getAttribute(attributes);
}
}
Object.keys(attributes).forEach(function(key) {
// If the attribute value is undefined we can skip this one
if(attributes[key] === undefined) {
return;
}
if (key.indexOf(':') !== -1) {
var namespacedAttribute = key.split(':');
this._node.setAttributeNS(Chartist.namespaces[namespacedAttribute[0]], key, attributes[key]);
} else {
this._node.setAttribute(key, attributes[key]);
}
}.bind(this));
return this;
}
/**
* Create a new SVG element whose wrapper object will be selected for further operations. This way you can also create nested groups easily.
*
* @memberof Chartist.Svg
* @param {String} name The name of the SVG element that should be created as child element of the currently selected element wrapper
* @param {Object} [attributes] An object with properties that will be added as attributes to the SVG element that is created. Attributes with undefined values will not be added.
* @param {String} [className] This class or class list will be added to the SVG element
* @param {Boolean} [insertFirst] If this param is set to true in conjunction with a parent element the newly created element will be added as first child element in the parent element
* @return {Chartist.Svg} Returns a Chartist.Svg wrapper object that can be used to modify the containing SVG data
*/
function elem(name, attributes, className, insertFirst) {
return new Chartist.Svg(name, attributes, className, this, insertFirst);
}
/**
* Returns the parent Chartist.SVG wrapper object
*
* @memberof Chartist.Svg
* @return {Chartist.Svg} Returns a Chartist.Svg wrapper around the parent node of the current node. If the parent node is not existing or it's not an SVG node then this function will return null.
*/
function parent() {
return this._node.parentNode instanceof SVGElement ? new Chartist.Svg(this._node.parentNode) : null;
}
/**
* This method returns a Chartist.Svg wrapper around the root SVG element of the current tree.
*
* @memberof Chartist.Svg
* @return {Chartist.Svg} The root SVG element wrapped in a Chartist.Svg element
*/
function root() {
var node = this._node;
while(node.nodeName !== 'svg') {
node = node.parentNode;
}
return new Chartist.Svg(node);
}
/**
* Find the first child SVG element of the current element that matches a CSS selector. The returned object is a Chartist.Svg wrapper.
*
* @memberof Chartist.Svg
* @param {String} selector A CSS selector that is used to query for child SVG elements
* @return {Chartist.Svg} The SVG wrapper for the element found or null if no element was found
*/
function querySelector(selector) {
var foundNode = this._node.querySelector(selector);
return foundNode ? new Chartist.Svg(foundNode) : null;
}
/**
* Find the all child SVG elements of the current element that match a CSS selector. The returned object is a Chartist.Svg.List wrapper.
*
* @memberof Chartist.Svg
* @param {String} selector A CSS selector that is used to query for child SVG elements
* @return {Chartist.Svg.List} The SVG wrapper list for the element found or null if no element was found
*/
function querySelectorAll(selector) {
var foundNodes = this._node.querySelectorAll(selector);
return foundNodes.length ? new Chartist.Svg.List(foundNodes) : null;
}
/**
* This method creates a foreignObject (see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/foreignObject) that allows to embed HTML content into a SVG graphic. With the help of foreignObjects you can enable the usage of regular HTML elements inside of SVG where they are subject for SVG positioning and transformation but the Browser will use the HTML rendering capabilities for the containing DOM.
*
* @memberof Chartist.Svg
* @param {Node|String} content The DOM Node, or HTML string that will be converted to a DOM Node, that is then placed into and wrapped by the foreignObject
* @param {String} [attributes] An object with properties that will be added as attributes to the foreignObject element that is created. Attributes with undefined values will not be added.
* @param {String} [className] This class or class list will be added to the SVG element
* @param {Boolean} [insertFirst] Specifies if the foreignObject should be inserted as first child
* @return {Chartist.Svg} New wrapper object that wraps the foreignObject element
*/
function foreignObject(content, attributes, className, insertFirst) {
// If content is string then we convert it to DOM
// TODO: Handle case where content is not a string nor a DOM Node
if(typeof content === 'string') {
var container = document.createElement('div');
container.innerHTML = content;
content = container.firstChild;
}
// Adding namespace to content element
content.setAttribute('xmlns', Chartist.namespaces.xmlns);
// Creating the foreignObject without required extension attribute (as described here
// http://www.w3.org/TR/SVG/extend.html#ForeignObjectElement)
var fnObj = this.elem('foreignObject', attributes, className, insertFirst);
// Add content to foreignObjectElement
fnObj._node.appendChild(content);
return fnObj;
}
/**
* This method adds a new text element to the current Chartist.Svg wrapper.
*
* @memberof Chartist.Svg
* @param {String} t The text that should be added to the text element that is created
* @return {Chartist.Svg} The same wrapper object that was used to add the newly created element
*/
function text(t) {
this._node.appendChild(document.createTextNode(t));
return this;
}
/**
* This method will clear all child nodes of the current wrapper object.
*
* @memberof Chartist.Svg
* @return {Chartist.Svg} The same wrapper object that got emptied
*/
function empty() {
while (this._node.firstChild) {
this._node.removeChild(this._node.firstChild);
}
return this;
}
/**
* This method will cause the current wrapper to remove itself from its parent wrapper. Use this method if you'd like to get rid of an element in a given DOM structure.
*
* @memberof Chartist.Svg
* @return {Chartist.Svg} The parent wrapper object of the element that got removed
*/
function remove() {
this._node.parentNode.removeChild(this._node);
return this.parent();
}
/**
* This method will replace the element with a new element that can be created outside of the current DOM.
*
* @memberof Chartist.Svg
* @param {Chartist.Svg} newElement The new Chartist.Svg object that will be used to replace the current wrapper object
* @return {Chartist.Svg} The wrapper of the new element
*/
function replace(newElement) {
this._node.parentNode.replaceChild(newElement._node, this._node);
return newElement;
}
/**
* This method will append an element to the current element as a child.
*
* @memberof Chartist.Svg
* @param {Chartist.Svg} element The Chartist.Svg element that should be added as a child
* @param {Boolean} [insertFirst] Specifies if the element should be inserted as first child
* @return {Chartist.Svg} The wrapper of the appended object
*/
function append(element, insertFirst) {
if(insertFirst && this._node.firstChild) {
this._node.insertBefore(element._node, this._node.firstChild);
} else {
this._node.appendChild(element._node);
}
return this;
}
/**
* Returns an array of class names that are attached to the current wrapper element. This method can not be chained further.
*
* @memberof Chartist.Svg
* @return {Array} A list of classes or an empty array if there are no classes on the current element
*/
function classes() {
return this._node.getAttribute('class') ? this._node.getAttribute('class').trim().split(/\s+/) : [];
}
/**
* Adds one or a space separated list of classes to the current element and ensures the classes are only existing once.
*
* @memberof Chartist.Svg
* @param {String} names A white space separated list of class names
* @return {Chartist.Svg} The wrapper of the current element
*/
function addClass(names) {
this._node.setAttribute('class',
this.classes(this._node)
.concat(names.trim().split(/\s+/))
.filter(function(elem, pos, self) {
return self.indexOf(elem) === pos;
}).join(' ')
);
return this;
}
/**
* Removes one or a space separated list of classes from the current element.
*
* @memberof Chartist.Svg
* @param {String} names A white space separated list of class names
* @return {Chartist.Svg} The wrapper of the current element
*/
function removeClass(names) {
var removedClasses = names.trim().split(/\s+/);
this._node.setAttribute('class', this.classes(this._node).filter(function(name) {
return removedClasses.indexOf(name) === -1;
}).join(' '));
return this;
}
/**
* Removes all classes from the current element.
*
* @memberof Chartist.Svg
* @return {Chartist.Svg} The wrapper of the current element
*/
function removeAllClasses() {
this._node.setAttribute('class', '');
return this;
}
/**
* Get element height using `getBoundingClientRect`
*
* @memberof Chartist.Svg
* @return {Number} The elements height in pixels
*/
function height() {
return this._node.getBoundingClientRect().height;
}
/**
* Get element width using `getBoundingClientRect`
*
* @memberof Chartist.Core
* @return {Number} The elements width in pixels
*/
function width() {
return this._node.getBoundingClientRect().width;
}
/**
* The animate function lets you animate the current element with SMIL animations. You can add animations for multiple attributes at the same time by using an animation definition object. This object should contain SMIL animation attributes. Please refer to http://www.w3.org/TR/SVG/animate.html for a detailed specification about the available animation attributes. Additionally an easing property can be passed in the animation definition object. This can be a string with a name of an easing function in `Chartist.Svg.Easing` or an array with four numbers specifying a cubic Bézier curve.
* **An animations object could look like this:**
* ```javascript
* element.animate({
* opacity: {
* dur: 1000,
* from: 0,
* to: 1
* },
* x1: {
* dur: '1000ms',
* from: 100,
* to: 200,
* easing: 'easeOutQuart'
* },
* y1: {
* dur: '2s',
* from: 0,
* to: 100
* }
* });
* ```
* **Automatic unit conversion**
* For the `dur` and the `begin` animate attribute you can also omit a unit by passing a number. The number will automatically be converted to milli seconds.
* **Guided mode**
* The default behavior of SMIL animations with offset using the `begin` attribute is that the attribute will keep it's original value until the animation starts. Mostly this behavior is not desired as you'd like to have your element attributes already initialized with the animation `from` value even before the animation starts. Also if you don't specify `fill="freeze"` on an animate element or if you delete the animation after it's done (which is done in guided mode) the attribute will switch back to the initial value. This behavior is also not desired when performing simple one-time animations. For one-time animations you'd want to trigger animations immediately instead of relative to the document begin time. That's why in guided mode Chartist.Svg will also use the `begin` property to schedule a timeout and manually start the animation after the timeout. If you're using multiple SMIL definition objects for an attribute (in an array), guided mode will be disabled for this attribute, even if you explicitly enabled it.
* If guided mode is enabled the following behavior is added:
* - Before the animation starts (even when delayed with `begin`) the animated attribute will be set already to the `from` value of the animation
* - `begin` is explicitly set to `indefinite` so it can be started manually without relying on document begin time (creation)
* - The animate element will be forced to use `fill="freeze"`
* - The animation will be triggered with `beginElement()` in a timeout where `begin` of the definition object is interpreted in milli seconds. If no `begin` was specified the timeout is triggered immediately.
* - After the animation the element attribute value will be set to the `to` value of the animation
* - The animate element is deleted from the DOM
*
* @memberof Chartist.Svg
* @param {Object} animations An animations object where the property keys are the attributes you'd like to animate. The properties should be objects again that contain the SMIL animation attributes (usually begin, dur, from, and to). The property begin and dur is auto converted (see Automatic unit conversion). You can also schedule multiple animations for the same attribute by passing an Array of SMIL definition objects. Attributes that contain an array of SMIL definition objects will not be executed in guided mode.
* @param {Boolean} guided Specify if guided mode should be activated for this animation (see Guided mode). If not otherwise specified, guided mode will be activated.
* @param {Object} eventEmitter If specified, this event emitter will be notified when an animation starts or ends.
* @return {Chartist.Svg} The current element where the animation was added
*/
function animate(animations, guided, eventEmitter) {
if(guided === undefined) {
guided = true;
}
Object.keys(animations).forEach(function createAnimateForAttributes(attribute) {
function createAnimate(animationDefinition, guided) {
var attributeProperties = {},
animate,
timeout,
easing;
// Check if an easing is specified in the definition object and delete it from the object as it will not
// be part of the animate element attributes.
if(animationDefinition.easing) {
// If already an easing Bézier curve array we take it or we lookup a easing array in the Easing object
easing = animationDefinition.easing instanceof Array ?
animationDefinition.easing :
Chartist.Svg.Easing[animationDefinition.easing];
delete animationDefinition.easing;
}
// If numeric dur or begin was provided we assume milli seconds
animationDefinition.begin = Chartist.ensureUnit(animationDefinition.begin, 'ms');
animationDefinition.dur = Chartist.ensureUnit(animationDefinition.dur, 'ms');
if(easing) {
animationDefinition.calcMode = 'spline';
animationDefinition.keySplines = easing.join(' ');
animationDefinition.keyTimes = '0;1';
}
// Adding "fill: freeze" if we are in guided mode and set initial attribute values
if(guided) {
animationDefinition.fill = 'freeze';
// Animated property on our element should already be set to the animation from value in guided mode
attributeProperties[attribute] = animationDefinition.from;
this.attr(attributeProperties);
// In guided mode we also set begin to indefinite so we can trigger the start manually and put the begin
// which needs to be in ms aside
timeout = Chartist.quantity(animationDefinition.begin || 0).value;
animationDefinition.begin = 'indefinite';
}
animate = this.elem('animate', Chartist.extend({
attributeName: attribute
}, animationDefinition));
if(guided) {
// If guided we take the value that was put aside in timeout and trigger the animation manually with a timeout
setTimeout(function() {
// If beginElement fails we set the animated attribute to the end position and remove the animate element
// This happens if the SMIL ElementTimeControl interface is not supported or any other problems occured in
// the browser. (Currently FF 34 does not support animate elements in foreignObjects)
try {
animate._node.beginElement();
} catch(err) {
// Set animated attribute to current animated value
attributeProperties[attribute] = animationDefinition.to;
this.attr(attributeProperties);
// Remove the animate element as it's no longer required
animate.remove();
}
}.bind(this), timeout);
}
if(eventEmitter) {
animate._node.addEventListener('beginEvent', function handleBeginEvent() {
eventEmitter.emit('animationBegin', {
element: this,
animate: animate._node,
params: animationDefinition
});
}.bind(this));
}
animate._node.addEventListener('endEvent', function handleEndEvent() {
if(eventEmitter) {
eventEmitter.emit('animationEnd', {
element: this,
animate: animate._node,
params: animationDefinition
});
}
if(guided) {
// Set animated attribute to current animated value
attributeProperties[attribute] = animationDefinition.to;
this.attr(attributeProperties);
// Remove the animate element as it's no longer required
animate.remove();
}
}.bind(this));
}
// If current attribute is an array of definition objects we create an animate for each and disable guided mode
if(animations[attribute] instanceof Array) {
animations[attribute].forEach(function(animationDefinition) {
createAnimate.bind(this)(animationDefinition, false);
}.bind(this));
} else {
createAnimate.bind(this)(animations[attribute], guided);
}
}.bind(this));
return this;
}
Chartist.Svg = Chartist.Class.extend({
constructor: Svg,
attr: attr,
elem: elem,
parent: parent,
root: root,
querySelector: querySelector,
querySelectorAll: querySelectorAll,
foreignObject: foreignObject,
text: text,
empty: empty,
remove: remove,
replace: replace,
append: append,
classes: classes,
addClass: addClass,
removeClass: removeClass,
removeAllClasses: removeAllClasses,
height: height,
width: width,
animate: animate
});
/**
* This method checks for support of a given SVG feature like Extensibility, SVG-animation or the like. Check http://www.w3.org/TR/SVG11/feature for a detailed list.
*
* @memberof Chartist.Svg
* @param {String} feature The SVG 1.1 feature that should be checked for support.
* @return {Boolean} True of false if the feature is supported or not
*/
Chartist.Svg.isSupported = function(feature) {
return document.implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#' + feature, '1.1');
};
/**
* This Object contains some standard easing cubic bezier curves. Then can be used with their name in the `Chartist.Svg.animate`. You can also extend the list and use your own name in the `animate` function. Click the show code button to see the available bezier functions.
*
* @memberof Chartist.Svg
*/
var easingCubicBeziers = {
easeInSine: [0.47, 0, 0.745, 0.715],
easeOutSine: [0.39, 0.575, 0.565, 1],
easeInOutSine: [0.445, 0.05, 0.55, 0.95],
easeInQuad: [0.55, 0.085, 0.68, 0.53],
easeOutQuad: [0.25, 0.46, 0.45, 0.94],
easeInOutQuad: [0.455, 0.03, 0.515, 0.955],
easeInCubic: [0.55, 0.055, 0.675, 0.19],
easeOutCubic: [0.215, 0.61, 0.355, 1],
easeInOutCubic: [0.645, 0.045, 0.355, 1],
easeInQuart: [0.895, 0.03, 0.685, 0.22],
easeOutQuart: [0.165, 0.84, 0.44, 1],
easeInOutQuart: [0.77, 0, 0.175, 1],
easeInQuint: [0.755, 0.05, 0.855, 0.06],
easeOutQuint: [0.23, 1, 0.32, 1],
easeInOutQuint: [0.86, 0, 0.07, 1],
easeInExpo: [0.95, 0.05, 0.795, 0.035],
easeOutExpo: [0.19, 1, 0.22, 1],
easeInOutExpo: [1, 0, 0, 1],
easeInCirc: [0.6, 0.04, 0.98, 0.335],
easeOutCirc: [0.075, 0.82, 0.165, 1],
easeInOutCirc: [0.785, 0.135, 0.15, 0.86],
easeInBack: [0.6, -0.28, 0.735, 0.045],
easeOutBack: [0.175, 0.885, 0.32, 1.275],
easeInOutBack: [0.68, -0.55, 0.265, 1.55]
};
Chartist.Svg.Easing = easingCubicBeziers;
/**
* This helper class is to wrap multiple `Chartist.Svg` elements into a list where you can call the `Chartist.Svg` functions on all elements in the list with one call. This is helpful when you'd like to perform calls with `Chartist.Svg` on multiple elements.
* An instance of this class is also returned by `Chartist.Svg.querySelectorAll`.
*
* @memberof Chartist.Svg
* @param {Array<Node>|NodeList} nodeList An Array of SVG DOM nodes or a SVG DOM NodeList (as returned by document.querySelectorAll)
* @constructor
*/
function SvgList(nodeList) {
var list = this;
this.svgElements = [];
for(var i = 0; i < nodeList.length; i++) {
this.svgElements.push(new Chartist.Svg(nodeList[i]));
}
// Add delegation methods for Chartist.Svg
Object.keys(Chartist.Svg.prototype).filter(function(prototypeProperty) {
return ['constructor',
'parent',
'querySelector',
'querySelectorAll',
'replace',
'append',
'classes',
'height',
'width'].indexOf(prototypeProperty) === -1;
}).forEach(function(prototypeProperty) {
list[prototypeProperty] = function() {
var args = Array.prototype.slice.call(arguments, 0);
list.svgElements.forEach(function(element) {
Chartist.Svg.prototype[prototypeProperty].apply(element, args);
});
return list;
};
});
}
Chartist.Svg.List = Chartist.Class.extend({
constructor: SvgList
});
}(window, document, Chartist));
;/**
* Chartist SVG path module for SVG path description creation and modification.
*
* @module Chartist.Svg.Path
*/
/* global Chartist */
(function(window, document, Chartist) {
'use strict';
/**
* Contains the descriptors of supported element types in a SVG path. Currently only move, line and curve are supported.
*
* @memberof Chartist.Svg.Path
* @type {Object}
*/
var elementDescriptions = {
m: ['x', 'y'],
l: ['x', 'y'],
c: ['x1', 'y1', 'x2', 'y2', 'x', 'y'],
a: ['rx', 'ry', 'xAr', 'lAf', 'sf', 'x', 'y']
};
/**
* Default options for newly created SVG path objects.
*
* @memberof Chartist.Svg.Path
* @type {Object}
*/
var defaultOptions = {
// The accuracy in digit count after the decimal point. This will be used to round numbers in the SVG path. If this option is set to false then no rounding will be performed.
accuracy: 3
};
function element(command, params, pathElements, pos, relative, data) {
var pathElement = Chartist.extend({
command: relative ? command.toLowerCase() : command.toUpperCase()
}, params, data ? { data: data } : {} );
pathElements.splice(pos, 0, pathElement);
}
function forEachParam(pathElements, cb) {
pathElements.forEach(function(pathElement, pathElementIndex) {
elementDescriptions[pathElement.command.toLowerCase()].forEach(function(paramName, paramIndex) {
cb(pathElement, paramName, pathElementIndex, paramIndex, pathElements);
});
});
}
/**
* Used to construct a new path object.
*
* @memberof Chartist.Svg.Path
* @param {Boolean} close If set to true then this path will be closed when stringified (with a Z at the end)
* @param {Object} options Options object that overrides the default objects. See default options for more details.
* @constructor
*/
function SvgPath(close, options) {
this.pathElements = [];
this.pos = 0;
this.close = close;
this.options = Chartist.extend({}, defaultOptions, options);
}
/**
* Gets or sets the current position (cursor) inside of the path. You can move around the cursor freely but limited to 0 or the count of existing elements. All modifications with element functions will insert new elements at the position of this cursor.
*
* @memberof Chartist.Svg.Path
* @param {Number} [pos] If a number is passed then the cursor is set to this position in the path element array.
* @return {Chartist.Svg.Path|Number} If the position parameter was passed then the return value will be the path object for easy call chaining. If no position parameter was passed then the current position is returned.
*/
function position(pos) {
if(pos !== undefined) {
this.pos = Math.max(0, Math.min(this.pathElements.length, pos));
return this;
} else {
return this.pos;
}
}
/**
* Removes elements from the path starting at the current position.
*
* @memberof Chartist.Svg.Path
* @param {Number} count Number of path elements that should be removed from the current position.
* @return {Chartist.Svg.Path} The current path object for easy call chaining.
*/
function remove(count) {
this.pathElements.splice(this.pos, count);
return this;
}
/**
* Use this function to add a new move SVG path element.
*
* @memberof Chartist.Svg.Path
* @param {Number} x The x coordinate for the move element.
* @param {Number} y The y coordinate for the move element.
* @param {Boolean} [relative] If set to true the move element will be created with relative coordinates (lowercase letter)
* @param {*} [data] Any data that should be stored with the element object that will be accessible in pathElement
* @return {Chartist.Svg.Path} The current path object for easy call chaining.
*/
function move(x, y, relative, data) {
element('M', {
x: +x,
y: +y
}, this.pathElements, this.pos++, relative, data);
return this;
}
/**
* Use this function to add a new line SVG path element.
*
* @memberof Chartist.Svg.Path
* @param {Number} x The x coordinate for the line element.
* @param {Number} y The y coordinate for the line element.
* @param {Boolean} [relative] If set to true the line element will be created with relative coordinates (lowercase letter)
* @param {*} [data] Any data that should be stored with the element object that will be accessible in pathElement
* @return {Chartist.Svg.Path} The current path object for easy call chaining.
*/
function line(x, y, relative, data) {
element('L', {
x: +x,
y: +y
}, this.pathElements, this.pos++, relative, data);
return this;
}
/**
* Use this function to add a new curve SVG path element.
*
* @memberof Chartist.Svg.Path
* @param {Number} x1 The x coordinate for the first control point of the bezier curve.
* @param {Number} y1 The y coordinate for the first control point of the bezier curve.
* @param {Number} x2 The x coordinate for the second control point of the bezier curve.
* @param {Number} y2 The y coordinate for the second control point of the bezier curve.
* @param {Number} x The x coordinate for the target point of the curve element.
* @param {Number} y The y coordinate for the target point of the curve element.
* @param {Boolean} [relative] If set to true the curve element will be created with relative coordinates (lowercase letter)
* @param {*} [data] Any data that should be stored with the element object that will be accessible in pathElement
* @return {Chartist.Svg.Path} The current path object for easy call chaining.
*/
function curve(x1, y1, x2, y2, x, y, relative, data) {
element('C', {
x1: +x1,
y1: +y1,
x2: +x2,
y2: +y2,
x: +x,
y: +y
}, this.pathElements, this.pos++, relative, data);
return this;
}
/**
* Use this function to add a new non-bezier curve SVG path element.
*
* @memberof Chartist.Svg.Path
* @param {Number} rx The radius to be used for the x-axis of the arc.
* @param {Number} ry The radius to be used for the y-axis of the arc.
* @param {Number} xAr Defines the orientation of the arc
* @param {Number} lAf Large arc flag
* @param {Number} sf Sweep flag
* @param {Number} x The x coordinate for the target point of the curve element.
* @param {Number} y The y coordinate for the target point of the curve element.
* @param {Boolean} [relative] If set to true the curve element will be created with relative coordinates (lowercase letter)
* @param {*} [data] Any data that should be stored with the element object that will be accessible in pathElement
* @return {Chartist.Svg.Path} The current path object for easy call chaining.
*/
function arc(rx, ry, xAr, lAf, sf, x, y, relative, data) {
element('A', {
rx: +rx,
ry: +ry,
xAr: +xAr,
lAf: +lAf,
sf: +sf,
x: +x,
y: +y
}, this.pathElements, this.pos++, relative, data);
return this;
}
/**
* Parses an SVG path seen in the d attribute of path elements, and inserts the parsed elements into the existing path object at the current cursor position. Any closing path indicators (Z at the end of the path) will be ignored by the parser as this is provided by the close option in the options of the path object.
*
* @memberof Chartist.Svg.Path
* @param {String} path Any SVG path that contains move (m), line (l) or curve (c) components.
* @return {Chartist.Svg.Path} The current path object for easy call chaining.
*/
function parse(path) {
// Parsing the SVG path string into an array of arrays [['M', '10', '10'], ['L', '100', '100']]
var chunks = path.replace(/([A-Za-z])([0-9])/g, '$1 $2')
.replace(/([0-9])([A-Za-z])/g, '$1 $2')
.split(/[\s,]+/)
.reduce(function(result, element) {
if(element.match(/[A-Za-z]/)) {
result.push([]);
}
result[result.length - 1].push(element);
return result;
}, []);
// If this is a closed path we remove the Z at the end because this is determined by the close option
if(chunks[chunks.length - 1][0].toUpperCase() === 'Z') {
chunks.pop();
}
// Using svgPathElementDescriptions to map raw path arrays into objects that contain the command and the parameters
// For example {command: 'M', x: '10', y: '10'}
var elements = chunks.map(function(chunk) {
var command = chunk.shift(),
description = elementDescriptions[command.toLowerCase()];
return Chartist.extend({
command: command
}, description.reduce(function(result, paramName, index) {
result[paramName] = +chunk[index];
return result;
}, {}));
});
// Preparing a splice call with the elements array as var arg params and insert the parsed elements at the current position
var spliceArgs = [this.pos, 0];
Array.prototype.push.apply(spliceArgs, elements);
Array.prototype.splice.apply(this.pathElements, spliceArgs);
// Increase the internal position by the element count
this.pos += elements.length;
return this;
}
/**
* This function renders to current SVG path object into a final SVG string that can be used in the d attribute of SVG path elements. It uses the accuracy option to round big decimals. If the close parameter was set in the constructor of this path object then a path closing Z will be appended to the output string.
*
* @memberof Chartist.Svg.Path
* @return {String}
*/
function stringify() {
var accuracyMultiplier = Math.pow(10, this.options.accuracy);
return this.pathElements.reduce(function(path, pathElement) {
var params = elementDescriptions[pathElement.command.toLowerCase()].map(function(paramName) {
return this.options.accuracy ?
(Math.round(pathElement[paramName] * accuracyMultiplier) / accuracyMultiplier) :
pathElement[paramName];
}.bind(this));
return path + pathElement.command + params.join(',');
}.bind(this), '') + (this.close ? 'Z' : '');
}
/**
* Scales all elements in the current SVG path object. There is an individual parameter for each coordinate. Scaling will also be done for control points of curves, affecting the given coordinate.
*
* @memberof Chartist.Svg.Path
* @param {Number} x The number which will be used to scale the x, x1 and x2 of all path elements.
* @param {Number} y The number which will be used to scale the y, y1 and y2 of all path elements.
* @return {Chartist.Svg.Path} The current path object for easy call chaining.
*/
function scale(x, y) {
forEachParam(this.pathElements, function(pathElement, paramName) {
pathElement[paramName] *= paramName[0] === 'x' ? x : y;
});
return this;
}
/**
* Translates all elements in the current SVG path object. The translation is relative and there is an individual parameter for each coordinate. Translation will also be done for control points of curves, affecting the given coordinate.
*
* @memberof Chartist.Svg.Path
* @param {Number} x The number which will be used to translate the x, x1 and x2 of all path elements.
* @param {Number} y The number which will be used to translate the y, y1 and y2 of all path elements.
* @return {Chartist.Svg.Path} The current path object for easy call chaining.
*/
function translate(x, y) {
forEachParam(this.pathElements, function(pathElement, paramName) {
pathElement[paramName] += paramName[0] === 'x' ? x : y;
});
return this;
}
/**
* This function will run over all existing path elements and then loop over their attributes. The callback function will be called for every path element attribute that exists in the current path.
* The method signature of the callback function looks like this:
* ```javascript
* function(pathElement, paramName, pathElementIndex, paramIndex, pathElements)
* ```
* If something else than undefined is returned by the callback function, this value will be used to replace the old value. This allows you to build custom transformations of path objects that can't be achieved using the basic transformation functions scale and translate.
*
* @memberof Chartist.Svg.Path
* @param {Function} transformFnc The callback function for the transformation. Check the signature in the function description.
* @return {Chartist.Svg.Path} The current path object for easy call chaining.
*/
function transform(transformFnc) {
forEachParam(this.pathElements, function(pathElement, paramName, pathElementIndex, paramIndex, pathElements) {
var transformed = transformFnc(pathElement, paramName, pathElementIndex, paramIndex, pathElements);
if(transformed || transformed === 0) {
pathElement[paramName] = transformed;
}
});
return this;
}
/**
* This function clones a whole path object with all its properties. This is a deep clone and path element objects will also be cloned.
*
* @memberof Chartist.Svg.Path
* @param {Boolean} [close] Optional option to set the new cloned path to closed. If not specified or false, the original path close option will be used.
* @return {Chartist.Svg.Path}
*/
function clone(close) {
var c = new Chartist.Svg.Path(close || this.close);
c.pos = this.pos;
c.pathElements = this.pathElements.slice().map(function cloneElements(pathElement) {
return Chartist.extend({}, pathElement);
});
c.options = Chartist.extend({}, this.options);
return c;
}
/**
* Split a Svg.Path object by a specific command in the path chain. The path chain will be split and an array of newly created paths objects will be returned. This is useful if you'd like to split an SVG path by it's move commands, for example, in order to isolate chunks of drawings.
*
* @memberof Chartist.Svg.Path
* @param {String} command The command you'd like to use to split the path
* @return {Array<Chartist.Svg.Path>}
*/
function splitByCommand(command) {
var split = [
new Chartist.Svg.Path()
];
this.pathElements.forEach(function(pathElement) {
if(pathElement.command === command.toUpperCase() && split[split.length - 1].pathElements.length !== 0) {
split.push(new Chartist.Svg.Path());
}
split[split.length - 1].pathElements.push(pathElement);
});
return split;
}
/**
* This static function on `Chartist.Svg.Path` is joining multiple paths together into one paths.
*
* @memberof Chartist.Svg.Path
* @param {Array<Chartist.Svg.Path>} paths A list of paths to be joined together. The order is important.
* @param {boolean} close If the newly created path should be a closed path
* @param {Object} options Path options for the newly created path.
* @return {Chartist.Svg.Path}
*/
function join(paths, close, options) {
var joinedPath = new Chartist.Svg.Path(close, options);
for(var i = 0; i < paths.length; i++) {
var path = paths[i];
for(var j = 0; j < path.pathElements.length; j++) {
joinedPath.pathElements.push(path.pathElements[j]);
}
}
return joinedPath;
}
Chartist.Svg.Path = Chartist.Class.extend({
constructor: SvgPath,
position: position,
remove: remove,
move: move,
line: line,
curve: curve,
arc: arc,
scale: scale,
translate: translate,
transform: transform,
parse: parse,
stringify: stringify,
clone: clone,
splitByCommand: splitByCommand
});
Chartist.Svg.Path.elementDescriptions = elementDescriptions;
Chartist.Svg.Path.join = join;
}(window, document, Chartist));
;/* global Chartist */
(function (window, document, Chartist) {
'use strict';
var axisUnits = {
x: {
pos: 'x',
len: 'width',
dir: 'horizontal',
rectStart: 'x1',
rectEnd: 'x2',
rectOffset: 'y2'
},
y: {
pos: 'y',
len: 'height',
dir: 'vertical',
rectStart: 'y2',
rectEnd: 'y1',
rectOffset: 'x1'
}
};
function Axis(units, chartRect, ticks, options) {
this.units = units;
this.counterUnits = units === axisUnits.x ? axisUnits.y : axisUnits.x;
this.chartRect = chartRect;
this.axisLength = chartRect[units.rectEnd] - chartRect[units.rectStart];
this.gridOffset = chartRect[units.rectOffset];
this.ticks = ticks;
this.options = options;
}
function createGridAndLabels(gridGroup, labelGroup, useForeignObject, chartOptions, eventEmitter) {
var axisOptions = chartOptions['axis' + this.units.pos.toUpperCase()];
var projectedValues = this.ticks.map(this.projectValue.bind(this));
var labelValues = this.ticks.map(axisOptions.labelInterpolationFnc);
projectedValues.forEach(function(projectedValue, index) {
var labelOffset = {
x: 0,
y: 0
};
// TODO: Find better solution for solving this problem
// Calculate how much space we have available for the label
var labelLength;
if(projectedValues[index + 1]) {
// If we still have one label ahead, we can calculate the distance to the next tick / label
labelLength = projectedValues[index + 1] - projectedValue;
} else {
// If we don't have a label ahead and we have only two labels in total, we just take the remaining distance to
// on the whole axis length. We limit that to a minimum of 30 pixel, so that labels close to the border will
// still be visible inside of the chart padding.
labelLength = Math.max(this.axisLength - projectedValue, 30);
}
// Skip grid lines and labels where interpolated label values are falsey (execpt for 0)
if(Chartist.isFalseyButZero(labelValues[index]) && labelValues[index] !== '') {
return;
}
// Transform to global coordinates using the chartRect
// We also need to set the label offset for the createLabel function
if(this.units.pos === 'x') {
projectedValue = this.chartRect.x1 + projectedValue;
labelOffset.x = chartOptions.axisX.labelOffset.x;
// If the labels should be positioned in start position (top side for vertical axis) we need to set a
// different offset as for positioned with end (bottom)
if(chartOptions.axisX.position === 'start') {
labelOffset.y = this.chartRect.padding.top + chartOptions.axisX.labelOffset.y + (useForeignObject ? 5 : 20);
} else {
labelOffset.y = this.chartRect.y1 + chartOptions.axisX.labelOffset.y + (useForeignObject ? 5 : 20);
}
} else {
projectedValue = this.chartRect.y1 - projectedValue;
labelOffset.y = chartOptions.axisY.labelOffset.y - (useForeignObject ? labelLength : 0);
// If the labels should be positioned in start position (left side for horizontal axis) we need to set a
// different offset as for positioned with end (right side)
if(chartOptions.axisY.position === 'start') {
labelOffset.x = useForeignObject ? this.chartRect.padding.left + chartOptions.axisY.labelOffset.x : this.chartRect.x1 - 10;
} else {
labelOffset.x = this.chartRect.x2 + chartOptions.axisY.labelOffset.x + 10;
}
}
if(axisOptions.showGrid) {
Chartist.createGrid(projectedValue, index, this, this.gridOffset, this.chartRect[this.counterUnits.len](), gridGroup, [
chartOptions.classNames.grid,
chartOptions.classNames[this.units.dir]
], eventEmitter);
}
if(axisOptions.showLabel) {
Chartist.createLabel(projectedValue, labelLength, index, labelValues, this, axisOptions.offset, labelOffset, labelGroup, [
chartOptions.classNames.label,
chartOptions.classNames[this.units.dir],
chartOptions.classNames[axisOptions.position]
], useForeignObject, eventEmitter);
}
}.bind(this));
}
Chartist.Axis = Chartist.Class.extend({
constructor: Axis,
createGridAndLabels: createGridAndLabels,
projectValue: function(value, index, data) {
throw new Error('Base axis can\'t be instantiated!');
}
});
Chartist.Axis.units = axisUnits;
}(window, document, Chartist));
;/**
* The auto scale axis uses standard linear scale projection of values along an axis. It uses order of magnitude to find a scale automatically and evaluates the available space in order to find the perfect amount of ticks for your chart.
* **Options**
* The following options are used by this axis in addition to the default axis options outlined in the axis configuration of the chart default settings.
* ```javascript
* var options = {
* // If high is specified then the axis will display values explicitly up to this value and the computed maximum from the data is ignored
* high: 100,
* // If low is specified then the axis will display values explicitly down to this value and the computed minimum from the data is ignored
* low: 0,
* // This option will be used when finding the right scale division settings. The amount of ticks on the scale will be determined so that as many ticks as possible will be displayed, while not violating this minimum required space (in pixel).
* scaleMinSpace: 20,
* // Can be set to true or false. If set to true, the scale will be generated with whole numbers only.
* onlyInteger: true,
* // The reference value can be used to make sure that this value will always be on the chart. This is especially useful on bipolar charts where the bipolar center always needs to be part of the chart.
* referenceValue: 5
* };
* ```
*
* @module Chartist.AutoScaleAxis
*/
/* global Chartist */
(function (window, document, Chartist) {
'use strict';
function AutoScaleAxis(axisUnit, data, chartRect, options) {
// Usually we calculate highLow based on the data but this can be overriden by a highLow object in the options
var highLow = options.highLow || Chartist.getHighLow(data.normalized, options, axisUnit.pos);
this.bounds = Chartist.getBounds(chartRect[axisUnit.rectEnd] - chartRect[axisUnit.rectStart], highLow, options.scaleMinSpace || 20, options.onlyInteger);
this.range = {
min: this.bounds.min,
max: this.bounds.max
};
Chartist.AutoScaleAxis.super.constructor.call(this,
axisUnit,
chartRect,
this.bounds.values,
options);
}
function projectValue(value) {
return this.axisLength * (+Chartist.getMultiValue(value, this.units.pos) - this.bounds.min) / this.bounds.range;
}
Chartist.AutoScaleAxis = Chartist.Axis.extend({
constructor: AutoScaleAxis,
projectValue: projectValue
});
}(window, document, Chartist));
;/**
* The fixed scale axis uses standard linear projection of values along an axis. It makes use of a divisor option to divide the range provided from the minimum and maximum value or the options high and low that will override the computed minimum and maximum.
* **Options**
* The following options are used by this axis in addition to the default axis options outlined in the axis configuration of the chart default settings.
* ```javascript
* var options = {
* // If high is specified then the axis will display values explicitly up to this value and the computed maximum from the data is ignored
* high: 100,
* // If low is specified then the axis will display values explicitly down to this value and the computed minimum from the data is ignored
* low: 0,
* // If specified then the value range determined from minimum to maximum (or low and high) will be divided by this number and ticks will be generated at those division points. The default divisor is 1.
* divisor: 4,
* // If ticks is explicitly set, then the axis will not compute the ticks with the divisor, but directly use the data in ticks to determine at what points on the axis a tick need to be generated.
* ticks: [1, 10, 20, 30]
* };
* ```
*
* @module Chartist.FixedScaleAxis
*/
/* global Chartist */
(function (window, document, Chartist) {
'use strict';
function FixedScaleAxis(axisUnit, data, chartRect, options) {
var highLow = options.highLow || Chartist.getHighLow(data.normalized, options, axisUnit.pos);
this.divisor = options.divisor || 1;
this.ticks = options.ticks || Chartist.times(this.divisor).map(function(value, index) {
return highLow.low + (highLow.high - highLow.low) / this.divisor * index;
}.bind(this));
this.ticks.sort(function(a, b) {
return a - b;
});
this.range = {
min: highLow.low,
max: highLow.high
};
Chartist.FixedScaleAxis.super.constructor.call(this,
axisUnit,
chartRect,
this.ticks,
options);
this.stepLength = this.axisLength / this.divisor;
}
function projectValue(value) {
return this.axisLength * (+Chartist.getMultiValue(value, this.units.pos) - this.range.min) / (this.range.max - this.range.min);
}
Chartist.FixedScaleAxis = Chartist.Axis.extend({
constructor: FixedScaleAxis,
projectValue: projectValue
});
}(window, document, Chartist));
;/**
* The step axis for step based charts like bar chart or step based line charts. It uses a fixed amount of ticks that will be equally distributed across the whole axis length. The projection is done using the index of the data value rather than the value itself and therefore it's only useful for distribution purpose.
* **Options**
* The following options are used by this axis in addition to the default axis options outlined in the axis configuration of the chart default settings.
* ```javascript
* var options = {
* // Ticks to be used to distribute across the axis length. As this axis type relies on the index of the value rather than the value, arbitrary data that can be converted to a string can be used as ticks.
* ticks: ['One', 'Two', 'Three'],
* // If set to true the full width will be used to distribute the values where the last value will be at the maximum of the axis length. If false the spaces between the ticks will be evenly distributed instead.
* stretch: true
* };
* ```
*
* @module Chartist.StepAxis
*/
/* global Chartist */
(function (window, document, Chartist) {
'use strict';
function StepAxis(axisUnit, data, chartRect, options) {
Chartist.StepAxis.super.constructor.call(this,
axisUnit,
chartRect,
options.ticks,
options);
this.stepLength = this.axisLength / (options.ticks.length - (options.stretch ? 1 : 0));
}
function projectValue(value, index) {
return this.stepLength * index;
}
Chartist.StepAxis = Chartist.Axis.extend({
constructor: StepAxis,
projectValue: projectValue
});
}(window, document, Chartist));
;/**
* The Chartist line chart can be used to draw Line or Scatter charts. If used in the browser you can access the global `Chartist` namespace where you find the `Line` function as a main entry point.
*
* For examples on how to use the line chart please check the examples of the `Chartist.Line` method.
*
* @module Chartist.Line
*/
/* global Chartist */
(function(window, document, Chartist){
'use strict';
/**
* Default options in line charts. Expand the code view to see a detailed list of options with comments.
*
* @memberof Chartist.Line
*/
var defaultOptions = {
// Options for X-Axis
axisX: {
// The offset of the labels to the chart area
offset: 30,
// Position where labels are placed. Can be set to `start` or `end` where `start` is equivalent to left or top on vertical axis and `end` is equivalent to right or bottom on horizontal axis.
position: 'end',
// Allows you to correct label positioning on this axis by positive or negative x and y offset.
labelOffset: {
x: 0,
y: 0
},
// If labels should be shown or not
showLabel: true,
// If the axis grid should be drawn or not
showGrid: true,
// Interpolation function that allows you to intercept the value from the axis label
labelInterpolationFnc: Chartist.noop,
// Set the axis type to be used to project values on this axis. If not defined, Chartist.StepAxis will be used for the X-Axis, where the ticks option will be set to the labels in the data and the stretch option will be set to the global fullWidth option. This type can be changed to any axis constructor available (e.g. Chartist.FixedScaleAxis), where all axis options should be present here.
type: undefined
},
// Options for Y-Axis
axisY: {
// The offset of the labels to the chart area
offset: 40,
// Position where labels are placed. Can be set to `start` or `end` where `start` is equivalent to left or top on vertical axis and `end` is equivalent to right or bottom on horizontal axis.
position: 'start',
// Allows you to correct label positioning on this axis by positive or negative x and y offset.
labelOffset: {
x: 0,
y: 0
},
// If labels should be shown or not
showLabel: true,
// If the axis grid should be drawn or not
showGrid: true,
// Interpolation function that allows you to intercept the value from the axis label
labelInterpolationFnc: Chartist.noop,
// Set the axis type to be used to project values on this axis. If not defined, Chartist.AutoScaleAxis will be used for the Y-Axis, where the high and low options will be set to the global high and low options. This type can be changed to any axis constructor available (e.g. Chartist.FixedScaleAxis), where all axis options should be present here.
type: undefined,
// This value specifies the minimum height in pixel of the scale steps
scaleMinSpace: 20,
// Use only integer values (whole numbers) for the scale steps
onlyInteger: false
},
// Specify a fixed width for the chart as a string (i.e. '100px' or '50%')
width: undefined,
// Specify a fixed height for the chart as a string (i.e. '100px' or '50%')
height: undefined,
// If the line should be drawn or not
showLine: true,
// If dots should be drawn or not
showPoint: true,
// If the line chart should draw an area
showArea: false,
// The base for the area chart that will be used to close the area shape (is normally 0)
areaBase: 0,
// Specify if the lines should be smoothed. This value can be true or false where true will result in smoothing using the default smoothing interpolation function Chartist.Interpolation.cardinal and false results in Chartist.Interpolation.none. You can also choose other smoothing / interpolation functions available in the Chartist.Interpolation module, or write your own interpolation function. Check the examples for a brief description.
lineSmooth: true,
// Overriding the natural low of the chart allows you to zoom in or limit the charts lowest displayed value
low: undefined,
// Overriding the natural high of the chart allows you to zoom in or limit the charts highest displayed value
high: undefined,
// Padding of the chart drawing area to the container element and labels as a number or padding object {top: 5, right: 5, bottom: 5, left: 5}
chartPadding: {
top: 15,
right: 15,
bottom: 5,
left: 10
},
// When set to true, the last grid line on the x-axis is not drawn and the chart elements will expand to the full available width of the chart. For the last label to be drawn correctly you might need to add chart padding or offset the last label with a draw event handler.
fullWidth: false,
// If true the whole data is reversed including labels, the series order as well as the whole series data arrays.
reverseData: false,
// Override the class names that get used to generate the SVG structure of the chart
classNames: {
chart: 'ct-chart-line',
label: 'ct-label',
labelGroup: 'ct-labels',
series: 'ct-series',
line: 'ct-line',
point: 'ct-point',
area: 'ct-area',
grid: 'ct-grid',
gridGroup: 'ct-grids',
vertical: 'ct-vertical',
horizontal: 'ct-horizontal',
start: 'ct-start',
end: 'ct-end'
}
};
/**
* Creates a new chart
*
*/
function createChart(options) {
this.data = Chartist.normalizeData(this.data);
var data = {
raw: this.data,
normalized: Chartist.getDataArray(this.data, options.reverseData, true)
};
// Create new svg object
this.svg = Chartist.createSvg(this.container, options.width, options.height, options.classNames.chart);
// Create groups for labels, grid and series
var gridGroup = this.svg.elem('g').addClass(options.classNames.gridGroup);
var seriesGroup = this.svg.elem('g');
var labelGroup = this.svg.elem('g').addClass(options.classNames.labelGroup);
var chartRect = Chartist.createChartRect(this.svg, options, defaultOptions.padding);
var axisX, axisY;
if(options.axisX.type === undefined) {
axisX = new Chartist.StepAxis(Chartist.Axis.units.x, data, chartRect, Chartist.extend({}, options.axisX, {
ticks: data.raw.labels,
stretch: options.fullWidth
}));
} else {
axisX = options.axisX.type.call(Chartist, Chartist.Axis.units.x, data, chartRect, options.axisX);
}
if(options.axisY.type === undefined) {
axisY = new Chartist.AutoScaleAxis(Chartist.Axis.units.y, data, chartRect, Chartist.extend({}, options.axisY, {
high: Chartist.isNum(options.high) ? options.high : options.axisY.high,
low: Chartist.isNum(options.low) ? options.low : options.axisY.low
}));
} else {
axisY = options.axisY.type.call(Chartist, Chartist.Axis.units.y, data, chartRect, options.axisY);
}
axisX.createGridAndLabels(gridGroup, labelGroup, this.supportsForeignObject, options, this.eventEmitter);
axisY.createGridAndLabels(gridGroup, labelGroup, this.supportsForeignObject, options, this.eventEmitter);
// Draw the series
data.raw.series.forEach(function(series, seriesIndex) {
var seriesElement = seriesGroup.elem('g');
// Write attributes to series group element. If series name or meta is undefined the attributes will not be written
seriesElement.attr({
'ct:series-name': series.name,
'ct:meta': Chartist.serialize(series.meta)
});
// Use series class from series data or if not set generate one
seriesElement.addClass([
options.classNames.series,
(series.className || options.classNames.series + '-' + Chartist.alphaNumerate(seriesIndex))
].join(' '));
var pathCoordinates = [],
pathData = [];
data.normalized[seriesIndex].forEach(function(value, valueIndex) {
var p = {
x: chartRect.x1 + axisX.projectValue(value, valueIndex, data.normalized[seriesIndex]),
y: chartRect.y1 - axisY.projectValue(value, valueIndex, data.normalized[seriesIndex])
};
pathCoordinates.push(p.x, p.y);
pathData.push({
value: value,
valueIndex: valueIndex,
meta: Chartist.getMetaData(series, valueIndex)
});
}.bind(this));
var seriesOptions = {
lineSmooth: Chartist.getSeriesOption(series, options, 'lineSmooth'),
showPoint: Chartist.getSeriesOption(series, options, 'showPoint'),
showLine: Chartist.getSeriesOption(series, options, 'showLine'),
showArea: Chartist.getSeriesOption(series, options, 'showArea'),
areaBase: Chartist.getSeriesOption(series, options, 'areaBase')
};
var smoothing = typeof seriesOptions.lineSmooth === 'function' ?
seriesOptions.lineSmooth : (seriesOptions.lineSmooth ? Chartist.Interpolation.monotoneCubic() : Chartist.Interpolation.none());
// Interpolating path where pathData will be used to annotate each path element so we can trace back the original
// index, value and meta data
var path = smoothing(pathCoordinates, pathData);
// If we should show points we need to create them now to avoid secondary loop
// Points are drawn from the pathElements returned by the interpolation function
// Small offset for Firefox to render squares correctly
if (seriesOptions.showPoint) {
path.pathElements.forEach(function(pathElement) {
var point = seriesElement.elem('line', {
x1: pathElement.x,
y1: pathElement.y,
x2: pathElement.x + 0.01,
y2: pathElement.y
}, options.classNames.point).attr({
'ct:value': [pathElement.data.value.x, pathElement.data.value.y].filter(Chartist.isNum).join(','),
'ct:meta': pathElement.data.meta
});
this.eventEmitter.emit('draw', {
type: 'point',
value: pathElement.data.value,
index: pathElement.data.valueIndex,
meta: pathElement.data.meta,
series: series,
seriesIndex: seriesIndex,
axisX: axisX,
axisY: axisY,
group: seriesElement,
element: point,
x: pathElement.x,
y: pa
gitextract_spx0x18a/
├── .dockerignore
├── .github/
│ ├── ISSUE_TEMPLATE/
│ │ ├── bug_report.md
│ │ └── config.yml
│ └── workflows/
│ ├── ci.yml
│ └── close.yml
├── .gitignore
├── .release-please-manifest.json
├── .rubocop.yml
├── .ruby-version
├── CHANGELOG.md
├── CONTRIBUTING.md
├── Dockerfile
├── Gemfile
├── MIT-LICENCE
├── Procfile.dev
├── README.md
├── Rakefile
├── SECURITY.md
├── app/
│ ├── assets/
│ │ ├── config/
│ │ │ └── manifest.js
│ │ ├── images/
│ │ │ └── .keep
│ │ ├── javascripts/
│ │ │ └── application/
│ │ │ ├── application.coffee
│ │ │ ├── elements/
│ │ │ │ ├── ajax.coffee
│ │ │ │ ├── mail_graph.coffee
│ │ │ │ ├── remembering.coffee
│ │ │ │ └── searchable.coffee
│ │ │ └── vendor/
│ │ │ ├── chartist.js
│ │ │ └── jquery.multibox.js
│ │ └── stylesheets/
│ │ └── application/
│ │ ├── application.scss
│ │ ├── components/
│ │ │ ├── _admin_stats.scss
│ │ │ ├── _button_set.scss
│ │ │ ├── _checkbox_list.scss
│ │ │ ├── _credential_list.scss
│ │ │ ├── _danger_zone.scss
│ │ │ ├── _data_table.scss
│ │ │ ├── _delivery_list.scss
│ │ │ ├── _domain_list.scss
│ │ │ ├── _endpoint_list.scss
│ │ │ ├── _error_explanation.scss
│ │ │ ├── _field_set.scss
│ │ │ ├── _flash_display.scss
│ │ │ ├── _flash_message.scss
│ │ │ ├── _footer.scss
│ │ │ ├── _grid.scss
│ │ │ ├── _headers_list.scss
│ │ │ ├── _inlineError.scss
│ │ │ ├── _invoice_list.scss
│ │ │ ├── _ip_list.scss
│ │ │ ├── _ip_pool_rule_list.scss
│ │ │ ├── _large_list.scss
│ │ │ ├── _limit.scss
│ │ │ ├── _login_form.scss
│ │ │ ├── _mail_graph.scss
│ │ │ ├── _message_activity.scss
│ │ │ ├── _message_header.scss
│ │ │ ├── _message_list.scss
│ │ │ ├── _message_properties_page.scss
│ │ │ ├── _message_search.scss
│ │ │ ├── _multibox.scss
│ │ │ ├── _nav_bar.scss
│ │ │ ├── _new_message_type.scss
│ │ │ ├── _no_data.scss
│ │ │ ├── _page_content.scss
│ │ │ ├── _page_header.scss
│ │ │ ├── _pagination.scss
│ │ │ ├── _rentention_limits.scss
│ │ │ ├── _route_list.scss
│ │ │ ├── _route_name_input.scss
│ │ │ ├── _server_header.scss
│ │ │ ├── _sidebar.scss
│ │ │ ├── _sidebar_server_list.scss
│ │ │ ├── _simple_pagination.scss
│ │ │ ├── _site_content.scss
│ │ │ ├── _site_header.scss
│ │ │ ├── _spam_check_list.scss
│ │ │ ├── _starter_credit_pack.scss
│ │ │ ├── _sub_page_box.scss
│ │ │ ├── _suppression_list.scss
│ │ │ ├── _suspension_box.scss
│ │ │ ├── _title_with_links.scss
│ │ │ ├── _user_list.scss
│ │ │ ├── _webhook_list.scss
│ │ │ └── _webhook_request_list.scss
│ │ ├── elements/
│ │ │ ├── _bar.scss
│ │ │ ├── _button.scss
│ │ │ ├── _code_block.scss
│ │ │ ├── _input.scss
│ │ │ ├── _label.scss
│ │ │ ├── _misc.scss
│ │ │ └── _spam_range.scss
│ │ ├── global/
│ │ │ ├── _fonts.scss
│ │ │ ├── _mixins.scss
│ │ │ ├── _reset.scss
│ │ │ ├── _utility.scss
│ │ │ └── _variables.scss
│ │ └── vendor/
│ │ └── _chartist.scss
│ ├── controllers/
│ │ ├── address_endpoints_controller.rb
│ │ ├── application_controller.rb
│ │ ├── concerns/
│ │ │ ├── .keep
│ │ │ └── within_organization.rb
│ │ ├── credentials_controller.rb
│ │ ├── domains_controller.rb
│ │ ├── help_controller.rb
│ │ ├── http_endpoints_controller.rb
│ │ ├── ip_addresses_controller.rb
│ │ ├── ip_pool_rules_controller.rb
│ │ ├── ip_pools_controller.rb
│ │ ├── legacy_api/
│ │ │ ├── base_controller.rb
│ │ │ ├── messages_controller.rb
│ │ │ └── send_controller.rb
│ │ ├── messages_controller.rb
│ │ ├── organization_ip_pools_controller.rb
│ │ ├── organizations_controller.rb
│ │ ├── routes_controller.rb
│ │ ├── servers_controller.rb
│ │ ├── sessions_controller.rb
│ │ ├── smtp_endpoints_controller.rb
│ │ ├── track_domains_controller.rb
│ │ ├── user_controller.rb
│ │ ├── users_controller.rb
│ │ ├── webhooks_controller.rb
│ │ └── well_known_controller.rb
│ ├── helpers/
│ │ └── application_helper.rb
│ ├── lib/
│ │ ├── dkim_header.rb
│ │ ├── dns_resolver.rb
│ │ ├── message_dequeuer/
│ │ │ ├── base.rb
│ │ │ ├── incoming_message_processor.rb
│ │ │ ├── initial_processor.rb
│ │ │ ├── outgoing_message_processor.rb
│ │ │ ├── single_message_processor.rb
│ │ │ └── state.rb
│ │ ├── message_dequeuer.rb
│ │ ├── query_string.rb
│ │ ├── received_header.rb
│ │ ├── reply_separator.rb
│ │ ├── smtp_client/
│ │ │ ├── endpoint.rb
│ │ │ ├── server.rb
│ │ │ └── ssl_modes.rb
│ │ ├── smtp_server/
│ │ │ ├── client.rb
│ │ │ └── server.rb
│ │ └── worker/
│ │ ├── jobs/
│ │ │ ├── base_job.rb
│ │ │ ├── process_queued_messages_job.rb
│ │ │ └── process_webhook_requests_job.rb
│ │ └── process.rb
│ ├── mailers/
│ │ ├── app_mailer.rb
│ │ └── application_mailer.rb
│ ├── models/
│ │ ├── additional_route_endpoint.rb
│ │ ├── address_endpoint.rb
│ │ ├── application_record.rb
│ │ ├── bounce_message.rb
│ │ ├── concerns/
│ │ │ ├── .keep
│ │ │ ├── has_authentication.rb
│ │ │ ├── has_dns_checks.rb
│ │ │ ├── has_locking.rb
│ │ │ ├── has_message.rb
│ │ │ ├── has_soft_destroy.rb
│ │ │ └── has_uuid.rb
│ │ ├── credential.rb
│ │ ├── domain.rb
│ │ ├── http_endpoint.rb
│ │ ├── incoming_message_prototype.rb
│ │ ├── ip_address.rb
│ │ ├── ip_pool.rb
│ │ ├── ip_pool_rule.rb
│ │ ├── organization.rb
│ │ ├── organization_ip_pool.rb
│ │ ├── organization_user.rb
│ │ ├── outgoing_message_prototype.rb
│ │ ├── queued_message.rb
│ │ ├── route.rb
│ │ ├── scheduled_task.rb
│ │ ├── server.rb
│ │ ├── smtp_endpoint.rb
│ │ ├── statistic.rb
│ │ ├── track_domain.rb
│ │ ├── user.rb
│ │ ├── user_invite.rb
│ │ ├── webhook.rb
│ │ ├── webhook_event.rb
│ │ ├── webhook_request.rb
│ │ └── worker_role.rb
│ ├── scheduled_tasks/
│ │ ├── action_deletions_scheduled_task.rb
│ │ ├── application_scheduled_task.rb
│ │ ├── check_all_dns_scheduled_task.rb
│ │ ├── cleanup_authie_sessions_scheduled_task.rb
│ │ ├── expire_held_messages_scheduled_task.rb
│ │ ├── process_message_retention_scheduled_task.rb
│ │ ├── prune_suppression_lists_scheduled_task.rb
│ │ ├── prune_webhook_requests_scheduled_task.rb
│ │ ├── send_notifications_scheduled_task.rb
│ │ └── tidy_queued_messages_task.rb
│ ├── senders/
│ │ ├── base_sender.rb
│ │ ├── http_sender.rb
│ │ ├── send_result.rb
│ │ └── smtp_sender.rb
│ ├── services/
│ │ └── webhook_delivery_service.rb
│ ├── util/
│ │ ├── has_prometheus_metrics.rb
│ │ ├── health_server.rb
│ │ └── user_creator.rb
│ └── views/
│ ├── address_endpoints/
│ │ ├── _form.html.haml
│ │ ├── edit.html.haml
│ │ ├── index.html.haml
│ │ └── new.html.haml
│ ├── app_mailer/
│ │ ├── password_reset.text.erb
│ │ ├── server_send_limit_approaching.text.erb
│ │ ├── server_send_limit_exceeded.text.erb
│ │ ├── server_suspended.text.erb
│ │ ├── test_message.text.erb
│ │ └── verify_domain.text.erb
│ ├── credentials/
│ │ ├── _form.html.haml
│ │ ├── edit.html.haml
│ │ ├── index.html.haml
│ │ └── new.html.haml
│ ├── domains/
│ │ ├── _nav.html.haml
│ │ ├── _verify_with_dns.html.haml
│ │ ├── _verify_with_email.html.haml
│ │ ├── index.html.haml
│ │ ├── new.html.haml
│ │ ├── setup.html.haml
│ │ └── verify.html.haml
│ ├── help/
│ │ ├── _header.html.haml
│ │ ├── incoming.html.haml
│ │ └── outgoing.html.haml
│ ├── http_endpoints/
│ │ ├── _form.html.haml
│ │ ├── edit.html.haml
│ │ ├── index.html.haml
│ │ └── new.html.haml
│ ├── ip_addresses/
│ │ ├── _form.html.haml
│ │ ├── edit.html.haml
│ │ └── new.html.haml
│ ├── ip_pool_rules/
│ │ ├── _form.html.haml
│ │ ├── edit.html.haml
│ │ ├── index.html.haml
│ │ └── new.html.haml
│ ├── ip_pools/
│ │ ├── _form.html.haml
│ │ ├── edit.html.haml
│ │ ├── index.html.haml
│ │ └── new.html.haml
│ ├── layouts/
│ │ ├── application.html.haml
│ │ └── sub.html.haml
│ ├── messages/
│ │ ├── _deliveries.html.haml
│ │ ├── _header.html.haml
│ │ ├── _index.html.haml
│ │ ├── _list.html.haml
│ │ ├── _message_header.html.haml
│ │ ├── _search.html.haml
│ │ ├── activity.html.haml
│ │ ├── attachments.html.haml
│ │ ├── headers.html.haml
│ │ ├── held.html.haml
│ │ ├── html.html.haml
│ │ ├── incoming.html.haml
│ │ ├── new.html.haml
│ │ ├── outgoing.html.haml
│ │ ├── plain.html.haml
│ │ ├── show.html.haml
│ │ ├── spam_checks.html.haml
│ │ └── suppressions.html.haml
│ ├── organization_ip_pools/
│ │ ├── _nav.html.haml
│ │ └── index.html.haml
│ ├── organizations/
│ │ ├── _nav.html.haml
│ │ ├── delete.html.haml
│ │ ├── edit.html.haml
│ │ ├── index.html.haml
│ │ └── new.html.haml
│ ├── routes/
│ │ ├── _form.html.haml
│ │ ├── _header.html.haml
│ │ ├── edit.html.haml
│ │ ├── index.html.haml
│ │ └── new.html.haml
│ ├── servers/
│ │ ├── _form.html.haml
│ │ ├── _header.html.haml
│ │ ├── _settings_header.html.haml
│ │ ├── _sidebar.html.haml
│ │ ├── advanced.html.haml
│ │ ├── delete.html.haml
│ │ ├── edit.html.haml
│ │ ├── index.html.haml
│ │ ├── limits.html.haml
│ │ ├── new.html.haml
│ │ ├── queue.html.haml
│ │ ├── retention.html.haml
│ │ ├── show.html.haml
│ │ └── spam.html.haml
│ ├── sessions/
│ │ ├── begin_password_reset.html.haml
│ │ ├── finish_password_reset.html.haml
│ │ └── new.html.haml
│ ├── shared/
│ │ └── _message_db_pagination.html.haml
│ ├── smtp_endpoints/
│ │ ├── _form.html.haml
│ │ ├── edit.html.haml
│ │ ├── index.html.haml
│ │ └── new.html.haml
│ ├── track_domains/
│ │ ├── _form.html.haml
│ │ ├── edit.html.haml
│ │ ├── index.html.haml
│ │ └── new.html.haml
│ ├── user/
│ │ └── edit.html.haml
│ ├── users/
│ │ ├── _form.html.haml
│ │ ├── edit.html.haml
│ │ ├── index.html.haml
│ │ └── new.html.haml
│ └── webhooks/
│ ├── _form.html.haml
│ ├── _header.html.haml
│ ├── edit.html.haml
│ ├── history.html.haml
│ ├── history_request.html.haml
│ ├── index.html.haml
│ └── new.html.haml
├── bin/
│ ├── bundle
│ ├── dev
│ ├── postal
│ ├── rails
│ ├── rake
│ ├── rspec
│ ├── setup
│ └── update
├── config/
│ ├── application.rb
│ ├── boot.rb
│ ├── database.yml
│ ├── environment.rb
│ ├── environments/
│ │ ├── development.rb
│ │ ├── production.rb
│ │ └── test.rb
│ ├── examples/
│ │ ├── development.yml
│ │ └── test.yml
│ ├── initializers/
│ │ ├── _wait_for_migrations.rb
│ │ ├── application_controller_renderer.rb
│ │ ├── assets.rb
│ │ ├── backtrace_silencers.rb
│ │ ├── content_security_policy.rb
│ │ ├── cookies_serializer.rb
│ │ ├── filter_parameter_logging.rb
│ │ ├── inflections.rb
│ │ ├── logging.rb
│ │ ├── mail_extensions.rb
│ │ ├── mime_types.rb
│ │ ├── new_framework_defaults_7_0.rb
│ │ ├── omniauth.rb
│ │ ├── permissions_policy.rb
│ │ ├── postal.rb
│ │ ├── record_key_for_dom.rb
│ │ ├── secret_key.rb
│ │ ├── secure_headers.rb
│ │ ├── sentry.rb
│ │ ├── session_store.rb
│ │ ├── smtp.rb
│ │ ├── smtp_extensions.rb
│ │ ├── trusted_proxies.rb
│ │ ├── wrap_parameters.rb
│ │ └── zeitwerk.rb
│ ├── locales/
│ │ └── en.yml
│ ├── puma.rb
│ └── routes.rb
├── config.ru
├── db/
│ ├── migrate/
│ │ ├── 20161003195209_create_authie_sessions.authie.rb
│ │ ├── 20161003195210_add_indexes_to_authie_sessions.authie.rb
│ │ ├── 20161003195211_add_parent_id_to_authie_sessions.authie.rb
│ │ ├── 20161003195212_add_two_factor_auth_fields_to_authie.authie.rb
│ │ ├── 20170418200606_initial_schema.rb
│ │ ├── 20170421195414_add_token_hashes_to_authie_sessions.authie.rb
│ │ ├── 20170421195415_add_index_to_token_hashes_on_authie_sessions.authie.rb
│ │ ├── 20170428153353_remove_type_from_ip_pools.rb
│ │ ├── 20180216114344_add_host_to_authie_sessions.authie.rb
│ │ ├── 20200717083943_add_uuid_to_credentials.rb
│ │ ├── 20210727210551_add_priority_to_ip_addresses.rb
│ │ ├── 20240206173036_add_privacy_mode_to_servers.rb
│ │ ├── 20240213165450_create_worker_roles.rb
│ │ ├── 20240213171830_create_scheduled_tasks.rb
│ │ ├── 20240214132253_add_lock_fields_to_webhook_requests.rb
│ │ ├── 20240223141500_add_two_factor_required_to_sessions.authie.rb
│ │ ├── 20240223141501_add_countries_to_authie_sessions.authie.rb
│ │ └── 20240311205229_add_oidc_fields_to_user.rb
│ ├── schema.rb
│ └── seeds.rb
├── doc/
│ └── config/
│ ├── configuration.md
│ ├── environment-variables.md
│ └── yaml.yml
├── docker/
│ ├── ci-config/
│ │ └── signing.key
│ └── wait-for.sh
├── docker-compose.yml
├── lib/
│ ├── assets/
│ │ └── .keep
│ ├── migration_waiter.rb
│ ├── postal/
│ │ ├── config.rb
│ │ ├── config_schema.rb
│ │ ├── error.rb
│ │ ├── helm_config_exporter.rb
│ │ ├── helpers.rb
│ │ ├── http.rb
│ │ ├── legacy_config_source.rb
│ │ ├── message_db/
│ │ │ ├── click.rb
│ │ │ ├── connection_pool.rb
│ │ │ ├── database.rb
│ │ │ ├── delivery.rb
│ │ │ ├── live_stats.rb
│ │ │ ├── load.rb
│ │ │ ├── message.rb
│ │ │ ├── migration.rb
│ │ │ ├── migrations/
│ │ │ │ ├── 01_create_migrations.rb
│ │ │ │ ├── 02_create_messages.rb
│ │ │ │ ├── 03_create_deliveries.rb
│ │ │ │ ├── 04_create_live_stats.rb
│ │ │ │ ├── 05_create_raw_message_sizes.rb
│ │ │ │ ├── 06_create_clicks.rb
│ │ │ │ ├── 07_create_loads.rb
│ │ │ │ ├── 08_create_stats.rb
│ │ │ │ ├── 09_create_links.rb
│ │ │ │ ├── 10_create_spam_checks.rb
│ │ │ │ ├── 11_add_time_to_deliveries.rb
│ │ │ │ ├── 12_add_hold_expiry.rb
│ │ │ │ ├── 13_add_index_to_message_status.rb
│ │ │ │ ├── 14_create_suppressions.rb
│ │ │ │ ├── 15_create_webhook_requests.rb
│ │ │ │ ├── 16_add_url_and_hook_to_webhooks.rb
│ │ │ │ ├── 17_add_replaced_link_count_to_messages.rb
│ │ │ │ ├── 18_add_endpoints_to_messages.rb
│ │ │ │ ├── 19_convert_database_to_utf8mb4.rb
│ │ │ │ └── 20_increase_links_url_size.rb
│ │ │ ├── provisioner.rb
│ │ │ ├── statistics.rb
│ │ │ ├── suppression_list.rb
│ │ │ └── webhooks.rb
│ │ ├── message_inspection.rb
│ │ ├── message_inspector.rb
│ │ ├── message_inspectors/
│ │ │ ├── clamav.rb
│ │ │ ├── rspamd.rb
│ │ │ └── spam_assassin.rb
│ │ ├── message_parser.rb
│ │ ├── signer.rb
│ │ ├── spam_check.rb
│ │ └── yaml_config_exporter.rb
│ ├── postal.rb
│ ├── tasks/
│ │ ├── .keep
│ │ ├── auto_annotate_models.rake
│ │ └── postal.rake
│ └── tracking_middleware.rb
├── log/
│ └── .keep
├── public/
│ ├── 404.html
│ ├── 422.html
│ ├── 500.html
│ └── robots.txt
├── release-please-config.json
├── resource/
│ └── postfix-bounce.msg
├── script/
│ ├── default_dkim_record.rb
│ ├── generate_tls_certificate.rb
│ ├── insert-bounce.rb
│ ├── make_user.rb
│ ├── queue_size.rb
│ ├── send_html_email.rb
│ ├── smtp_server.rb
│ ├── test_app_smtp.rb
│ ├── version.rb
│ └── worker.rb
├── spec/
│ ├── apis/
│ │ └── legacy_api/
│ │ ├── messages/
│ │ │ ├── deliveries_spec.rb
│ │ │ └── message_spec.rb
│ │ └── send/
│ │ ├── message_spec.rb
│ │ └── raw_spec.rb
│ ├── examples/
│ │ ├── dkim_signing/
│ │ │ ├── email1.msg
│ │ │ └── email2.msg
│ │ └── full_legacy_config_file.yml
│ ├── factories/
│ │ ├── address_endpoint_factory.rb
│ │ ├── credential_factory.rb
│ │ ├── domain_factory.rb
│ │ ├── http_endpoint_factory.rb
│ │ ├── ip_address_factory.rb
│ │ ├── ip_pool_factory.rb
│ │ ├── ip_pool_rule_factory.rb
│ │ ├── organization_factory.rb
│ │ ├── queued_message_factory.rb
│ │ ├── route_factory.rb
│ │ ├── server_factory.rb
│ │ ├── smtp_endpoint_factory.rb
│ │ ├── track_domain_factory.rb
│ │ ├── user_factory.rb
│ │ ├── webhook_factory.rb
│ │ ├── webhook_request_factory.rb
│ │ └── worker_role_factory.rb
│ ├── helpers/
│ │ ├── general_helpers.rb
│ │ ├── message_db_mocking.rb
│ │ ├── message_factory.rb
│ │ └── test_logger.rb
│ ├── lib/
│ │ ├── dkim_header_spec.rb
│ │ ├── dns_resolver_spec.rb
│ │ ├── message_dequeuer/
│ │ │ ├── base_spec.rb
│ │ │ ├── incoming_message_processor_spec.rb
│ │ │ ├── initial_message_processor_spec.rb
│ │ │ ├── outgoing_message_processor_spec.rb
│ │ │ ├── single_message_processor_spec.rb
│ │ │ └── state_spec.rb
│ │ ├── message_dequeuer_spec.rb
│ │ ├── postal/
│ │ │ ├── legacy_config_source_spec.rb
│ │ │ ├── message_db/
│ │ │ │ ├── connection_pool_spec.rb
│ │ │ │ └── database_spec.rb
│ │ │ ├── message_parser_spec.rb
│ │ │ └── signer_spec.rb
│ │ ├── postal_spec.rb
│ │ ├── query_string_spec.rb
│ │ ├── received_header_spec.rb
│ │ ├── smtp_client/
│ │ │ ├── endpoint_spec.rb
│ │ │ └── server_spec.rb
│ │ ├── smtp_server/
│ │ │ ├── client/
│ │ │ │ ├── auth_spec.rb
│ │ │ │ ├── data_spec.rb
│ │ │ │ ├── finished_spec.rb
│ │ │ │ ├── helo_spec.rb
│ │ │ │ ├── mail_from_spec.rb
│ │ │ │ ├── proxy_spec.rb
│ │ │ │ └── rcpt_to_spec.rb
│ │ │ └── client_spec.rb
│ │ └── worker/
│ │ └── jobs/
│ │ ├── process_queued_messages_job_spec.rb
│ │ └── process_webhook_requests_job_spec.rb
│ ├── models/
│ │ ├── domain_spec.rb
│ │ ├── organization_spec.rb
│ │ ├── outgoing_message_prototype_spec.rb
│ │ ├── queued_message_spec.rb
│ │ ├── server_spec.rb
│ │ ├── user/
│ │ │ ├── authentication_spec.rb
│ │ │ └── oidc_spec.rb
│ │ ├── user_spec.rb
│ │ └── worker_role_spec.rb
│ ├── rails_helper.rb
│ ├── scheduled_tasks/
│ │ └── tidy_queued_messages_task_spec.rb
│ ├── senders/
│ │ └── smtp_sender_spec.rb
│ ├── services/
│ │ └── webhook_delivery_service_spec.rb
│ └── spec_helper.rb
├── tmp/
│ └── .keep
└── vendor/
└── assets/
├── javascripts/
│ └── .keep
└── stylesheets/
└── .keep
SYMBOL INDEX (1300 symbols across 201 files)
FILE: app/assets/javascripts/application/vendor/chartist.js
function recursiveConvert (line 425) | function recursiveConvert(value) {
function recursiveHighLow (line 546) | function recursiveHighLow(data) {
function gcd (line 663) | function gcd(p, q) {
function f (line 671) | function f(x) {
function updateCurrentOptions (line 974) | function updateCurrentOptions(mediaEvent) {
function removeMediaQueryListeners (line 995) | function removeMediaQueryListeners() {
function addEventHandler (line 1546) | function addEventHandler(event, handler) {
function removeEventHandler (line 1558) | function removeEventHandler(event, handler) {
function emit (line 1581) | function emit(event, data) {
function listToArray (line 1614) | function listToArray(list) {
function extend (line 1665) | function extend(properties, superProtoOverride) {
function cloneDefinitions (line 1693) | function cloneDefinitions() {
function update (line 1739) | function update(data, options, override) {
function detach (line 1774) | function detach() {
function on (line 1794) | function on(event, handler) {
function off (line 1806) | function off(event, handler) {
function initialize (line 1811) | function initialize() {
function Base (line 1859) | function Base(query, data, defaultOptions, options, responsiveOptions) {
function Svg (line 1925) | function Svg(name, attributes, className, parent, insertFirst) {
function attr (line 1965) | function attr(attributes, ns) {
function elem (line 2001) | function elem(name, attributes, className, insertFirst) {
function parent (line 2011) | function parent() {
function root (line 2021) | function root() {
function querySelector (line 2036) | function querySelector(selector) {
function querySelectorAll (line 2048) | function querySelectorAll(selector) {
function foreignObject (line 2063) | function foreignObject(content, attributes, className, insertFirst) {
function text (line 2092) | function text(t) {
function empty (line 2103) | function empty() {
function remove (line 2117) | function remove() {
function replace (line 2129) | function replace(newElement) {
function append (line 2142) | function append(element, insertFirst) {
function classes (line 2158) | function classes() {
function addClass (line 2169) | function addClass(names) {
function removeClass (line 2188) | function removeClass(names) {
function removeAllClasses (line 2204) | function removeAllClasses() {
function height (line 2216) | function height() {
function width (line 2226) | function width() {
function animate (line 2271) | function animate(animations, guided, eventEmitter) {
function SvgList (line 2458) | function SvgList(nodeList) {
function element (line 2525) | function element(command, params, pathElements, pos, relative, data) {
function forEachParam (line 2533) | function forEachParam(pathElements, cb) {
function SvgPath (line 2549) | function SvgPath(close, options) {
function position (line 2563) | function position(pos) {
function remove (line 2579) | function remove(count) {
function move (line 2594) | function move(x, y, relative, data) {
function line (line 2612) | function line(x, y, relative, data) {
function curve (line 2634) | function curve(x1, y1, x2, y2, x, y, relative, data) {
function arc (line 2661) | function arc(rx, ry, xAr, lAf, sf, x, y, relative, data) {
function parse (line 2681) | function parse(path) {
function stringify (line 2730) | function stringify() {
function scale (line 2752) | function scale(x, y) {
function translate (line 2767) | function translate(x, y) {
function transform (line 2786) | function transform(transformFnc) {
function clone (line 2803) | function clone(close) {
function splitByCommand (line 2820) | function splitByCommand(command) {
function join (line 2846) | function join(paths, close, options) {
function Axis (line 2900) | function Axis(units, chartRect, ticks, options) {
function createGridAndLabels (line 2910) | function createGridAndLabels(gridGroup, labelGroup, useForeignObject, ch...
function AutoScaleAxis (line 3018) | function AutoScaleAxis(axisUnit, data, chartRect, options) {
function projectValue (line 3034) | function projectValue(value) {
function FixedScaleAxis (line 3067) | function FixedScaleAxis(axisUnit, data, chartRect, options) {
function projectValue (line 3090) | function projectValue(value) {
function StepAxis (line 3119) | function StepAxis(axisUnit, data, chartRect, options) {
function projectValue (line 3129) | function projectValue(value, index) {
function createChart (line 3251) | function createChart(options) {
function Line (line 3534) | function Line(query, data, options, responsiveOptions) {
function createChart (line 3658) | function createChart(options) {
function Bar (line 3964) | function Bar(query, data, options, responsiveOptions) {
function determineAnchorPosition (line 4043) | function determineAnchorPosition(center, label, direction) {
function createChart (line 4062) | function createChart(options) {
function Pie (line 4311) | function Pie(query, data, options, responsiveOptions) {
FILE: app/assets/javascripts/application/vendor/jquery.multibox.js
function Multibox (line 5) | function Multibox($el, options) {
FILE: app/controllers/address_endpoints_controller.rb
class AddressEndpointsController (line 3) | class AddressEndpointsController < ApplicationController
method index (line 10) | def index
method new (line 14) | def new
method create (line 18) | def create
method update (line 28) | def update
method destroy (line 36) | def destroy
method safe_params (line 43) | def safe_params
FILE: app/controllers/application_controller.rb
class ApplicationController (line 5) | class ApplicationController < ActionController::Base
method login_required (line 18) | def login_required
method admin_required (line 24) | def admin_required
method require_organization_owner (line 34) | def require_organization_owner
method auth_session_error (line 40) | def auth_session_error(exception)
method page_title (line 45) | def page_title
method redirect_to_with_return_to (line 50) | def redirect_to_with_return_to(url, *args)
method set_timezone (line 54) | def set_timezone
method append_info_to_payload (line 58) | def append_info_to_payload(payload)
method url_with_return_to (line 64) | def url_with_return_to(url)
method redirect_to_with_json (line 72) | def redirect_to_with_json(url, flash_messages = {})
method render_form_errors (line 88) | def render_form_errors(action_name, object)
method flash_now (line 95) | def flash_now(type, message, options = {})
method login (line 107) | def login(user)
FILE: app/controllers/concerns/within_organization.rb
type WithinOrganization (line 3) | module WithinOrganization
function organization (line 14) | def organization
function add_organization_to_page_title (line 18) | def add_organization_to_page_title
FILE: app/controllers/credentials_controller.rb
class CredentialsController (line 3) | class CredentialsController < ApplicationController
method index (line 10) | def index
method new (line 14) | def new
method create (line 18) | def create
method update (line 27) | def update
method destroy (line 35) | def destroy
FILE: app/controllers/domains_controller.rb
class DomainsController (line 3) | class DomainsController < ApplicationController
method index (line 16) | def index
method new (line 24) | def new
method create (line 28) | def create
method destroy (line 48) | def destroy
method verify (line 53) | def verify
method setup (line 95) | def setup
method check (line 101) | def check
FILE: app/controllers/help_controller.rb
class HelpController (line 3) | class HelpController < ApplicationController
method outgoing (line 9) | def outgoing
FILE: app/controllers/http_endpoints_controller.rb
class HTTPEndpointsController (line 3) | class HTTPEndpointsController < ApplicationController
method index (line 10) | def index
method new (line 14) | def new
method create (line 18) | def create
method update (line 28) | def update
method destroy (line 36) | def destroy
method safe_params (line 43) | def safe_params
FILE: app/controllers/ip_addresses_controller.rb
class IPAddressesController (line 3) | class IPAddressesController < ApplicationController
method new (line 9) | def new
method create (line 13) | def create
method update (line 22) | def update
method destroy (line 30) | def destroy
method safe_params (line 37) | def safe_params
FILE: app/controllers/ip_pool_rules_controller.rb
class IPPoolRulesController (line 3) | class IPPoolRulesController < ApplicationController
method index (line 16) | def index
method new (line 24) | def new
method create (line 28) | def create
method update (line 38) | def update
method destroy (line 46) | def destroy
method safe_params (line 53) | def safe_params
FILE: app/controllers/ip_pools_controller.rb
class IPPoolsController (line 3) | class IPPoolsController < ApplicationController
method index (line 8) | def index
method new (line 12) | def new
method create (line 16) | def create
method update (line 25) | def update
method destroy (line 33) | def destroy
method safe_params (line 42) | def safe_params
FILE: app/controllers/legacy_api/base_controller.rb
type LegacyAPI (line 3) | module LegacyAPI
class BaseController (line 28) | class BaseController < ActionController::Base
method api_params (line 45) | def api_params
method start_timer (line 62) | def start_timer
method authenticate_as_server (line 73) | def authenticate_as_server
method render_success (line 102) | def render_success(data)
method render_error (line 114) | def render_error(code, data = {})
method render_parameter_error (line 125) | def render_parameter_error(message)
FILE: app/controllers/legacy_api/messages_controller.rb
type LegacyAPI (line 3) | module LegacyAPI
class MessagesController (line 4) | class MessagesController < BaseController
method message (line 17) | def message
method deliveries (line 113) | def deliveries
FILE: app/controllers/legacy_api/send_controller.rb
type LegacyAPI (line 3) | module LegacyAPI
class SendController (line 4) | class SendController < BaseController
method message (line 39) | def message
method raw (line 83) | def raw
FILE: app/controllers/messages_controller.rb
class MessagesController (line 3) | class MessagesController < ApplicationController
method new (line 10) | def new
method create (line 26) | def create
method outgoing (line 55) | def outgoing
method incoming (line 69) | def incoming
method held (line 83) | def held
method deliveries (line 87) | def deliveries
method html_raw (line 91) | def html_raw
method spam_checks (line 95) | def spam_checks
method attachment (line 99) | def attachment
method download (line 108) | def download
method retry (line 116) | def retry
method cancel_hold (line 134) | def cancel_hold
method remove_from_queue (line 139) | def remove_from_queue
method suppressions (line 146) | def suppressions
method activity (line 150) | def activity
method get_messages (line 156) | def get_messages(scope)
class TimeUndetermined (line 213) | class TimeUndetermined < Postal::Error; end
method get_time_from_string (line 215) | def get_time_from_string(string)
FILE: app/controllers/organization_ip_pools_controller.rb
class OrganizationIPPoolsController (line 3) | class OrganizationIPPoolsController < ApplicationController
method index (line 8) | def index
method assignments (line 12) | def assignments
FILE: app/controllers/organizations_controller.rb
class OrganizationsController (line 3) | class OrganizationsController < ApplicationController
method index (line 7) | def index
method new (line 18) | def new
method edit (line 22) | def edit
method create (line 26) | def create
method update (line 36) | def update
method destroy (line 45) | def destroy
method organization (line 61) | def organization
FILE: app/controllers/routes_controller.rb
class RoutesController (line 3) | class RoutesController < ApplicationController
method index (line 10) | def index
method new (line 14) | def new
method create (line 18) | def create
method update (line 27) | def update
method destroy (line 35) | def destroy
method safe_params (line 42) | def safe_params
FILE: app/controllers/servers_controller.rb
class ServersController (line 3) | class ServersController < ApplicationController
method index (line 10) | def index
method show (line 14) | def show
method new (line 31) | def new
method create (line 35) | def create
method update (line 44) | def update
method destroy (line 67) | def destroy
method queue (line 81) | def queue
method suspend (line 86) | def suspend
method unsuspend (line 91) | def unsuspend
method safe_params (line 98) | def safe_params(*extras)
FILE: app/controllers/sessions_controller.rb
class SessionsController (line 3) | class SessionsController < ApplicationController
method create (line 10) | def create
method destroy (line 19) | def destroy
method persist (line 25) | def persist
method begin_password_reset (line 30) | def begin_password_reset
method finish_password_reset (line 45) | def finish_password_reset
method ip (line 66) | def ip
method create_from_oidc (line 70) | def create_from_oidc
method oauth_failure (line 87) | def oauth_failure
method require_local_authentication (line 93) | def require_local_authentication
FILE: app/controllers/smtp_endpoints_controller.rb
class SMTPEndpointsController (line 3) | class SMTPEndpointsController < ApplicationController
method index (line 9) | def index
method new (line 13) | def new
method create (line 17) | def create
method update (line 27) | def update
method destroy (line 35) | def destroy
method safe_params (line 42) | def safe_params
FILE: app/controllers/track_domains_controller.rb
class TrackDomainsController (line 3) | class TrackDomainsController < ApplicationController
method index (line 9) | def index
method new (line 13) | def new
method create (line 17) | def create
method update (line 26) | def update
method destroy (line 34) | def destroy
method check (line 39) | def check
method toggle_ssl (line 47) | def toggle_ssl
FILE: app/controllers/user_controller.rb
class UserController (line 3) | class UserController < ApplicationController
method new (line 7) | def new
method edit (line 14) | def edit
method create (line 18) | def create
method update (line 31) | def update
FILE: app/controllers/users_controller.rb
class UsersController (line 3) | class UsersController < ApplicationController
method index (line 8) | def index
method new (line 12) | def new
method edit (line 16) | def edit
method create (line 19) | def create
method update (line 28) | def update
method destroy (line 46) | def destroy
FILE: app/controllers/webhooks_controller.rb
class WebhooksController (line 3) | class WebhooksController < ApplicationController
method index (line 9) | def index
method new (line 13) | def new
method create (line 17) | def create
method update (line 26) | def update
method destroy (line 34) | def destroy
method history (line 39) | def history
method history_request (line 44) | def history_request
method safe_params (line 50) | def safe_params
FILE: app/controllers/well_known_controller.rb
class WellKnownController (line 3) | class WellKnownController < ApplicationController
method jwks (line 11) | def jwks
FILE: app/helpers/application_helper.rb
type ApplicationHelper (line 3) | module ApplicationHelper
function format_delivery_details (line 5) | def format_delivery_details(server, text)
function style_width (line 14) | def style_width(width, options = {})
function domain_options_for_select (line 28) | def domain_options_for_select(server, selected_domain = nil, options =...
function endpoint_options_for_select (line 53) | def endpoint_options_for_select(server, selected_value = nil, options ...
function postal_version_string (line 104) | def postal_version_string
FILE: app/lib/dkim_header.rb
class DKIMHeader (line 3) | class DKIMHeader
method initialize (line 5) | def initialize(domain, message)
method dkim_header (line 20) | def dkim_header
method headers (line 26) | def headers
method header_names (line 30) | def header_names
method normalized_headers (line 34) | def normalized_headers
method normalize_header (line 50) | def normalize_header(content)
method normalized_body (line 79) | def normalized_body
method body_hash (line 103) | def body_hash
method dkim_properties (line 107) | def dkim_properties
method dkim_header_for_signing (line 118) | def dkim_header_for_signing
method signable_header_string (line 122) | def signable_header_string
method signature (line 126) | def signature
FILE: app/lib/dns_resolver.rb
class DNSResolver (line 5) | class DNSResolver
class LocalResolversUnavailableError (line 7) | class LocalResolversUnavailableError < StandardError
method initialize (line 13) | def initialize(nameservers)
method a (line 21) | def a(name, **options)
method aaaa (line 31) | def aaaa(name, **options)
method txt (line 41) | def txt(name, **options)
method cname (line 51) | def cname(name, **options)
method mx (line 61) | def mx(name, **options)
method effective_ns (line 78) | def effective_ns(name, **options)
method ip_to_hostname (line 99) | def ip_to_hostname(ip_address, **options)
method dns (line 111) | def dns(raise_timeout_errors: false)
method get_resources (line 123) | def get_resources(name, type, **options)
method for_domain (line 136) | def for_domain(name)
method local (line 147) | def local
FILE: app/lib/message_dequeuer.rb
type MessageDequeuer (line 3) | module MessageDequeuer
function process (line 7) | def process(message, logger:)
FILE: app/lib/message_dequeuer/base.rb
type MessageDequeuer (line 3) | module MessageDequeuer
class Base (line 4) | class Base
class StopProcessing (line 6) | class StopProcessing < StandardError
method initialize (line 13) | def initialize(queued_message, logger:, state: nil)
method process (line 19) | def process
method process (line 25) | def process(message, **kwargs)
method stop_processing (line 33) | def stop_processing
method catch_stops (line 37) | def catch_stops
method remove_from_queue (line 44) | def remove_from_queue
method create_delivery (line 48) | def create_delivery(type, **kwargs)
method log (line 52) | def log(text, **tags)
method increment_live_stats (line 56) | def increment_live_stats
method hold_if_server_development_mode (line 60) | def hold_if_server_development_mode
method log_sender_result (line 70) | def log_sender_result
method handle_exception (line 86) | def handle_exception(exception)
FILE: app/lib/message_dequeuer/incoming_message_processor.rb
type MessageDequeuer (line 3) | module MessageDequeuer
class IncomingMessageProcessor (line 4) | class IncomingMessageProcessor < Base
method process (line 8) | def process
method handle_bounces (line 33) | def handle_bounces
method inspect_message (line 60) | def inspect_message
method fail_if_spam (line 82) | def fail_if_spam
method find_route (line 93) | def find_route
method hold_or_reject_spam (line 103) | def hold_or_reject_spam
method accept_mail_without_endpoints (line 122) | def accept_mail_without_endpoints
method hold_messages (line 131) | def hold_messages
method bounce_messages (line 146) | def bounce_messages
method send_message_to_sender (line 160) | def send_message_to_sender
method send_bounce_on_hard_fail (line 184) | def send_bounce_on_hard_fail
method finish_processing (line 200) | def finish_processing
FILE: app/lib/message_dequeuer/initial_processor.rb
type MessageDequeuer (line 3) | module MessageDequeuer
class InitialProcessor (line 4) | class InitialProcessor < Base
method process (line 10) | def process
method increment_dequeue_metric (line 34) | def increment_dequeue_metric
method check_message_exists (line 41) | def check_message_exists
method check_message_is_ready (line 49) | def check_message_is_ready
method find_other_messages_for_batch (line 57) | def find_other_messages_for_batch
method process_message (line 67) | def process_message(queued_message)
FILE: app/lib/message_dequeuer/outgoing_message_processor.rb
type MessageDequeuer (line 3) | module MessageDequeuer
class OutgoingMessageProcessor (line 4) | class OutgoingMessageProcessor < Base
method process (line 6) | def process
method check_domain (line 32) | def check_domain
method check_rcpt_to (line 41) | def check_rcpt_to
method add_tag (line 50) | def add_tag
method hold_if_credential_is_set_to_hold (line 58) | def hold_if_credential_is_set_to_hold
method hold_if_recipient_on_suppression_list (line 69) | def hold_if_recipient_on_suppression_list
method parse_content (line 79) | def parse_content
method inspect_message (line 86) | def inspect_message
method fail_if_spam (line 101) | def fail_if_spam
method add_outgoing_headers (line 112) | def add_outgoing_headers
method check_send_limits (line 118) | def check_send_limits
method send_message_to_sender (line 134) | def send_message_to_sender
method add_recipient_to_suppression_list_on_too_many_hard_fails (line 148) | def add_recipient_to_suppression_list_on_too_many_hard_fails
method remove_recipient_from_suppression_list_on_success (line 168) | def remove_recipient_from_suppression_list_on_success
method finish_processing (line 178) | def finish_processing
FILE: app/lib/message_dequeuer/single_message_processor.rb
type MessageDequeuer (line 3) | module MessageDequeuer
class SingleMessageProcessor (line 4) | class SingleMessageProcessor < Base
method process (line 6) | def process
method check_message_exists (line 33) | def check_message_exists
method check_server_suspension (line 41) | def check_server_suspension
method check_delivery_attempts (line 50) | def check_delivery_attempts
method check_raw_message_exists (line 73) | def check_raw_message_exists
FILE: app/lib/message_dequeuer/state.rb
type MessageDequeuer (line 3) | module MessageDequeuer
class State (line 4) | class State
method sender_for (line 8) | def sender_for(klass, *args, **kwargs)
method finished (line 17) | def finished
FILE: app/lib/query_string.rb
class QueryString (line 3) | class QueryString
method initialize (line 5) | def initialize(string)
method [] (line 9) | def [](value)
method hash (line 15) | def hash
FILE: app/lib/received_header.rb
class ReceivedHeader (line 3) | class ReceivedHeader
method generate (line 12) | def generate(server, helo, ip_address, method)
FILE: app/lib/reply_separator.rb
class ReplySeparator (line 3) | class ReplySeparator
method separate (line 19) | def self.separate(text)
FILE: app/lib/smtp_client/endpoint.rb
type SMTPClient (line 3) | module SMTPClient
class Endpoint (line 4) | class Endpoint
class SMTPSessionNotStartedError (line 6) | class SMTPSessionNotStartedError < StandardError
method initialize (line 15) | def initialize(server, ip_address)
method description (line 23) | def description
method to_s (line 30) | def to_s
method ipv6? (line 37) | def ipv6?
method ipv4? (line 44) | def ipv4?
method start_smtp_session (line 54) | def start_smtp_session(source_ip_address: nil, allow_ssl: true)
method send_message (line 100) | def send_message(raw_message, mail_from, rcpt_to, retry_on_connectio...
method reset_smtp_session (line 119) | def reset_smtp_session
method finish_smtp_session (line 128) | def finish_smtp_session
method default_helo_hostname (line 142) | def default_helo_hostname
method ssl_context_with_verify (line 148) | def ssl_context_with_verify
method ssl_context_without_verify (line 158) | def ssl_context_without_verify
FILE: app/lib/smtp_client/server.rb
type SMTPClient (line 3) | module SMTPClient
class Server (line 4) | class Server
method initialize (line 10) | def initialize(hostname, port: 25, ssl_mode: SSLModes::AUTO)
method endpoints (line 20) | def endpoints
FILE: app/lib/smtp_client/ssl_modes.rb
type SMTPClient (line 3) | module SMTPClient
type SSLModes (line 4) | module SSLModes
FILE: app/lib/smtp_server/client.rb
type SMTPServer (line 3) | module SMTPServer
class Client (line 4) | class Client
method initialize (line 20) | def initialize(ip_address)
method check_ip_address (line 36) | def check_ip_address
method transaction_reset (line 44) | def transaction_reset
method trace_id (line 51) | def trace_id
method handle (line 55) | def handle(data)
method finished? (line 80) | def finished?
method start_tls? (line 84) | def start_tls?
method handle_command (line 90) | def handle_command(data)
method logger (line 110) | def logger
method proxy (line 118) | def proxy(data)
method quit (line 134) | def quit
method starttls (line 139) | def starttls
method ehlo (line 151) | def ehlo(data)
method helo (line 163) | def helo(data)
method rset (line 171) | def rset
method noop (line 178) | def noop
method auth_plain (line 182) | def auth_plain(data)
method auth_login (line 209) | def auth_login(data)
method authenticate (line 233) | def authenticate(password)
method auth_cram_md5 (line 244) | def auth_cram_md5(data)
method mail_from (line 286) | def mail_from(data)
method rcpt_to (line 305) | def rcpt_to(data)
method data (line 409) | def data(_data)
method finished (line 464) | def finished
method in_state (line 546) | def in_state(*states)
method sanitize_input_for_log (line 550) | def sanitize_input_for_log(data)
method increment_error_count (line 563) | def increment_error_count(error)
method increment_command_count (line 567) | def increment_command_count(command)
method increment_message_count (line 571) | def increment_message_count(type)
method register_prometheus_metrics (line 580) | def register_prometheus_metrics
FILE: app/lib/smtp_server/server.rb
type SMTPServer (line 6) | module SMTPServer
class Server (line 7) | class Server
method tls_private_key (line 13) | def tls_private_key
method tls_certificates (line 17) | def tls_certificates
method initialize (line 29) | def initialize(options = {})
method run (line 36) | def run
method prepare_environment (line 45) | def prepare_environment
method ssl_context (line 60) | def ssl_context
method listen (line 72) | def listen
method unlisten (line 91) | def unlisten
method run_event_loop (line 97) | def run_event_loop
method logger (line 298) | def logger
method register_prometheus_metrics (line 302) | def register_prometheus_metrics
FILE: app/lib/worker/jobs/base_job.rb
type Worker (line 3) | module Worker
type Jobs (line 4) | module Jobs
class BaseJob (line 5) | class BaseJob
method initialize (line 7) | def initialize(logger:)
method call (line 11) | def call
method work_completed? (line 15) | def work_completed?
method work_completed! (line 21) | def work_completed!
FILE: app/lib/worker/jobs/process_queued_messages_job.rb
type Worker (line 3) | module Worker
type Jobs (line 4) | module Jobs
class ProcessQueuedMessagesJob (line 5) | class ProcessQueuedMessagesJob < BaseJob
method call (line 7) | def call
method find_ip_addresses (line 24) | def find_ip_addresses
method local_ip? (line 38) | def local_ip?(ip)
method lock_message_for_processing (line 45) | def lock_message_for_processing
method obtain_locked_messages (line 57) | def obtain_locked_messages
method process_messages (line 64) | def process_messages
FILE: app/lib/worker/jobs/process_webhook_requests_job.rb
type Worker (line 3) | module Worker
type Jobs (line 4) | module Jobs
class ProcessWebhookRequestsJob (line 5) | class ProcessWebhookRequestsJob < BaseJob
method call (line 7) | def call
method lock_request_for_processing (line 21) | def lock_request_for_processing
method obtain_locked_requests (line 32) | def obtain_locked_requests
method process_requests (line 39) | def process_requests
FILE: app/lib/worker/process.rb
type Worker (line 3) | module Worker
class Process (line 20) | class Process
method initialize (line 48) | def initialize(thread_count: Postal::Config.worker.threads,
method run (line 60) | def run
method setup_traps (line 75) | def setup_traps
method receive_signal (line 84) | def receive_signal(signal)
method shutdown_after_wait? (line 96) | def shutdown_after_wait?(wait_time)
method ensure_connection_pool_size_is_suitable (line 104) | def ensure_connection_pool_size_is_suitable
method wait_for_threads (line 120) | def wait_for_threads
method start_work_threads (line 127) | def start_work_threads
method start_work_thread (line 137) | def start_work_thread(index)
method work (line 157) | def work(thread)
method start_tasks_thread (line 190) | def start_tasks_thread
method run_tasks (line 216) | def run_tasks
method run_task (line 242) | def run_task(task)
method logger (line 276) | def logger
method capture_errors (line 284) | def capture_errors
method setup_prometheus (line 295) | def setup_prometheus
FILE: app/mailers/app_mailer.rb
class AppMailer (line 3) | class AppMailer < ApplicationMailer
method verify_domain (line 5) | def verify_domain(domain, email_address, user)
method password_reset (line 12) | def password_reset(user, return_to = nil)
method server_send_limit_approaching (line 18) | def server_send_limit_approaching(server)
method server_send_limit_exceeded (line 23) | def server_send_limit_exceeded(server)
method server_suspended (line 28) | def server_suspended(server)
method test_message (line 33) | def test_message(recipient)
FILE: app/mailers/application_mailer.rb
class ApplicationMailer (line 3) | class ApplicationMailer < ActionMailer::Base
FILE: app/models/additional_route_endpoint.rb
class AdditionalRouteEndpoint (line 15) | class AdditionalRouteEndpoint < ApplicationRecord
method find_by_endpoint (line 24) | def self.find_by_endpoint(endpoint)
method _endpoint (line 35) | def _endpoint
method _endpoint= (line 39) | def _endpoint=(value)
method validate_endpoint_belongs_to_server (line 54) | def validate_endpoint_belongs_to_server
method validate_uniqueness (line 60) | def validate_uniqueness
method validate_wildcard (line 66) | def validate_wildcard
FILE: app/models/address_endpoint.rb
class AddressEndpoint (line 16) | class AddressEndpoint < ApplicationRecord
method mark_as_used (line 28) | def mark_as_used
method update_routes (line 32) | def update_routes
method description (line 36) | def description
method domain (line 40) | def domain
FILE: app/models/application_record.rb
class ApplicationRecord (line 3) | class ApplicationRecord < ActiveRecord::Base
FILE: app/models/bounce_message.rb
class BounceMessage (line 3) | class BounceMessage
method initialize (line 5) | def initialize(server, message)
method raw_message (line 10) | def raw_message
method queue (line 21) | def queue
method postmaster_address (line 34) | def postmaster_address
method body (line 40) | def body
FILE: app/models/concerns/has_authentication.rb
type HasAuthentication (line 3) | module HasAuthentication
function authenticate (line 20) | def authenticate(email_address, password)
function authenticate_with_previous_password_first (line 29) | def authenticate_with_previous_password_first(unencrypted_password)
function begin_password_reset (line 37) | def begin_password_reset(return_to = nil)
function clear_password_reset_token_on_password_change (line 50) | def clear_password_reset_token_on_password_change
function validate_password_presence (line 57) | def validate_password_presence
FILE: app/models/concerns/has_dns_checks.rb
type HasDNSChecks (line 5) | module HasDNSChecks
function dns_ok? (line 7) | def dns_ok?
function dns_checked? (line 11) | def dns_checked?
function check_dns (line 15) | def check_dns(source = :manual)
function check_spf_record (line 45) | def check_spf_record
function check_spf_record! (line 65) | def check_spf_record!
function check_dkim_record (line 74) | def check_dkim_record
function check_dkim_record! (line 96) | def check_dkim_record!
function check_mx_records (line 105) | def check_mx_records
function check_mx_records! (line 125) | def check_mx_records!
function check_return_path_record (line 134) | def check_return_path_record
function check_return_path_record! (line 148) | def check_return_path_record!
FILE: app/models/concerns/has_locking.rb
type HasLocking (line 13) | module HasLocking
function ready? (line 22) | def ready?
function unlock (line 26) | def unlock
function locked? (line 32) | def locked?
function retry_later (line 36) | def retry_later(time = nil)
function calculate_retry_time (line 43) | def calculate_retry_time(attempts, initial_period)
FILE: app/models/concerns/has_message.rb
type HasMessage (line 3) | module HasMessage
function included (line 5) | def self.included(base)
function message (line 9) | def message
function message= (line 17) | def message=(message)
type ClassMethods (line 22) | module ClassMethods
function include_message (line 24) | def include_message
FILE: app/models/concerns/has_soft_destroy.rb
type HasSoftDestroy (line 3) | module HasSoftDestroy
function included (line 5) | def self.included(base)
function soft_destroy (line 13) | def soft_destroy
FILE: app/models/concerns/has_uuid.rb
type HasUUID (line 3) | module HasUUID
function included (line 5) | def self.included(base)
function to_param (line 11) | def to_param
FILE: app/models/credential.rb
class Credential (line 20) | class Credential < ApplicationRecord
method generate_key (line 38) | def generate_key
method to_param (line 45) | def to_param
method use (line 49) | def use
method usage_type (line 53) | def usage_type
method to_smtp_plain (line 67) | def to_smtp_plain
method ipaddr (line 71) | def ipaddr
method validate_key_cannot_be_changed (line 81) | def validate_key_cannot_be_changed
method validate_key_for_smtp_ip (line 89) | def validate_key_for_smtp_ip
FILE: app/models/domain.rb
class Domain (line 41) | class Domain < ApplicationRecord
method verified? (line 66) | def verified?
method mark_as_verified (line 70) | def mark_as_verified
method parent_domains (line 77) | def parent_domains
method generate_dkim_key (line 84) | def generate_dkim_key
method dkim_key (line 88) | def dkim_key
method to_param (line 94) | def to_param
method verification_email_addresses (line 98) | def verification_email_addresses
method spf_record (line 106) | def spf_record
method dkim_record (line 110) | def dkim_record
method dkim_identifier (line 117) | def dkim_identifier
method dkim_record_name (line 123) | def dkim_record_name
method return_path_domain (line 130) | def return_path_domain
method resolver (line 138) | def resolver
method dns_verification_string (line 144) | def dns_verification_string
method verify_with_dns (line 148) | def verify_with_dns
method update_verification_token_on_method_change (line 163) | def update_verification_token_on_method_change
FILE: app/models/http_endpoint.rb
class HTTPEndpoint (line 24) | class HTTPEndpoint < ApplicationRecord
method description (line 47) | def description
method mark_as_used (line 51) | def mark_as_used
method update_routes (line 55) | def update_routes
FILE: app/models/incoming_message_prototype.rb
class IncomingMessagePrototype (line 3) | class IncomingMessagePrototype
method initialize (line 12) | def initialize(server, ip, source_type, attributes)
method from_address (line 22) | def from_address
method route (line 26) | def route
method attachments (line 35) | def attachments
method create_messages (line 46) | def create_messages
method valid? (line 59) | def valid?
method errors (line 64) | def errors
method validate (line 68) | def validate
method raw_message (line 84) | def raw_message
FILE: app/models/ip_address.rb
class IPAddress (line 17) | class IPAddress < ApplicationRecord
method set_default_priority (line 32) | def set_default_priority
method select_by_priority (line 40) | def select_by_priority
FILE: app/models/ip_pool.rb
class IPPool (line 19) | class IPPool < ApplicationRecord
method default (line 31) | def self.default
FILE: app/models/ip_pool_rule.rb
class IPPoolRule (line 18) | class IPPoolRule < ApplicationRecord
method from (line 28) | def from
method to (line 32) | def to
method apply_to_message? (line 36) | def apply_to_message?(message)
method validate_from_and_to_addresses (line 58) | def validate_from_and_to_addresses
method validate_ip_pool_belongs_to_organization (line 64) | def validate_ip_pool_belongs_to_organization
method address_matches? (line 73) | def address_matches?(condition, address)
FILE: app/models/organization.rb
class Organization (line 26) | class Organization < ApplicationRecord
method status (line 58) | def status
method to_param (line 66) | def to_param
method suspended? (line 70) | def suspended?
method user_assignment (line 74) | def user_assignment(user)
method make_owner (line 79) | def make_owner(new_owner)
method notification_addresses (line 85) | def notification_addresses
method find_unique_permalink (line 89) | def self.find_unique_permalink(name)
method [] (line 100) | def self.[](id)
FILE: app/models/organization_ip_pool.rb
class OrganizationIPPool (line 14) | class OrganizationIPPool < ApplicationRecord
FILE: app/models/organization_user.rb
class OrganizationUser (line 16) | class OrganizationUser < ApplicationRecord
FILE: app/models/outgoing_message_prototype.rb
class OutgoingMessagePrototype (line 5) | class OutgoingMessagePrototype
method initialize (line 22) | def initialize(server, ip, source_type, attributes)
method from_address (line 36) | def from_address
method sender_address (line 40) | def sender_address
method domain (line 44) | def domain
method find_domain (line 51) | def find_domain
method to_addresses (line 59) | def to_addresses
method cc_addresses (line 63) | def cc_addresses
method bcc_addresses (line 67) | def bcc_addresses
method all_addresses (line 71) | def all_addresses
method create_messages (line 75) | def create_messages
method valid? (line 87) | def valid?
method errors (line 92) | def errors
method attachments (line 97) | def attachments
method validate (line 108) | def validate
method raw_message (line 151) | def raw_message
method create_message (line 186) | def create_message(address)
FILE: app/models/queued_message.rb
class QueuedMessage (line 29) | class QueuedMessage < ApplicationRecord
method retry_now (line 42) | def retry_now
method send_bounce (line 46) | def send_bounce
method allocate_ip_address (line 52) | def allocate_ip_address
method batchable_messages (line 62) | def batchable_messages(limit = 10)
FILE: app/models/route.rb
class Route (line 25) | class Route < ApplicationRecord
method return_path? (line 53) | def return_path?
method description (line 57) | def description
method _endpoint (line 65) | def _endpoint
method _endpoint= (line 73) | def _endpoint=(value)
method forward_address (line 91) | def forward_address
method wildcard? (line 95) | def wildcard?
method additional_route_endpoints_array (line 99) | def additional_route_endpoints_array
method additional_route_endpoints_array= (line 103) | def additional_route_endpoints_array=(array)
method save_additional_route_endpoints (line 107) | def save_additional_route_endpoints
method create_messages (line 136) | def create_messages(&block)
method build_message (line 164) | def build_message
method validate_route_is_routed (line 175) | def validate_route_is_routed
method validate_domain_belongs_to_server (line 181) | def validate_domain_belongs_to_server
method validate_endpoint_belongs_to_server (line 191) | def validate_endpoint_belongs_to_server
method validate_name_uniqueness (line 197) | def validate_name_uniqueness
method validate_return_path_route_endpoints (line 209) | def validate_return_path_route_endpoints
method validate_no_additional_routes_on_non_endpoint_route (line 216) | def validate_no_additional_routes_on_non_endpoint_route
method find_by_name_and_domain (line 224) | def find_by_name_and_domain(name, domain)
FILE: app/models/scheduled_task.rb
class ScheduledTask (line 15) | class ScheduledTask < ApplicationRecord
FILE: app/models/server.rb
class Server (line 45) | class Server < ApplicationRecord
method status (line 98) | def status
method full_permalink (line 106) | def full_permalink
method suspended? (line 110) | def suspended?
method actual_suspension_reason (line 114) | def actual_suspension_reason
method to_param (line 124) | def to_param
method message_db (line 128) | def message_db
method message_rate (line 134) | def message_rate
method held_messages (line 138) | def held_messages
method throughput_stats (line 142) | def throughput_stats
method bounce_rate (line 155) | def bounce_rate
method domain_stats (line 168) | def domain_stats
method webhook_hash (line 181) | def webhook_hash
method send_volume (line 190) | def send_volume
method send_limit_approaching? (line 194) | def send_limit_approaching?
method send_limit_exceeded? (line 200) | def send_limit_exceeded?
method send_limit_warning (line 206) | def send_limit_warning(type)
method queue_size (line 215) | def queue_size
method authenticated_domain_for_address (line 223) | def authenticated_domain_for_address(address)
method find_authenticated_domain_from_headers (line 251) | def find_authenticated_domain_from_headers(headers)
method suspend (line 269) | def suspend(reason)
method unsuspend (line 279) | def unsuspend
method ip_pool_for_message (line 285) | def ip_pool_for_message(message)
method validate_ip_pool_belongs_to_organization (line 302) | def validate_ip_pool_belongs_to_organization
method triggered_send_limit (line 310) | def triggered_send_limit(type)
method send_send_limit_notifications (line 315) | def send_send_limit_notifications
method [] (line 328) | def [](id, extra = nil)
FILE: app/models/smtp_endpoint.rb
class SMTPEndpoint (line 21) | class SMTPEndpoint < ApplicationRecord
method description (line 38) | def description
method mark_as_used (line 42) | def mark_as_used
method update_routes (line 46) | def update_routes
method to_smtp_client_server (line 50) | def to_smtp_client_server
FILE: app/models/statistic.rb
class Statistic (line 13) | class Statistic < ApplicationRecord
method global (line 15) | def self.global
FILE: app/models/track_domain.rb
class TrackDomain (line 25) | class TrackDomain < ApplicationRecord
method full_name (line 44) | def full_name
method excluded_click_domains_array (line 48) | def excluded_click_domains_array
method dns_ok? (line 52) | def dns_ok?
method check_dns (line 56) | def check_dns
method use_ssl? (line 73) | def use_ssl?
method validate_domain_belongs_to_server (line 77) | def validate_domain_belongs_to_server
FILE: app/models/user.rb
class User (line 30) | class User < ApplicationRecord
method organizations_scope (line 44) | def organizations_scope
method name (line 52) | def name
method password? (line 56) | def password?
method oidc? (line 60) | def oidc?
method to_param (line 64) | def to_param
method email_tag (line 68) | def email_tag
method [] (line 79) | def [](email)
method find_from_oidc (line 89) | def find_from_oidc(auth, logger: nil)
FILE: app/models/user_invite.rb
class UserInvite (line 19) | class UserInvite < ApplicationRecord
method md5_for_gravatar (line 32) | def md5_for_gravatar
method avatar_url (line 36) | def avatar_url
method name (line 40) | def name
method accept (line 44) | def accept(user)
method reject (line 54) | def reject
FILE: app/models/webhook.rb
class Webhook (line 24) | class Webhook < ApplicationRecord
method events (line 40) | def events
method events= (line 44) | def events=(value)
method save_events (line 50) | def save_events
method destroy_events_when_all_events_enabled (line 60) | def destroy_events_when_all_events_enabled
FILE: app/models/webhook_event.rb
class WebhookEvent (line 17) | class WebhookEvent < ApplicationRecord
FILE: app/models/webhook_request.rb
class WebhookRequest (line 26) | class WebhookRequest < ApplicationRecord
method trigger (line 41) | def trigger(server, event, payload = {})
FILE: app/models/worker_role.rb
class WorkerRole (line 16) | class WorkerRole < ApplicationRecord
method acquire (line 24) | def acquire(role)
method release (line 47) | def release(role)
FILE: app/scheduled_tasks/action_deletions_scheduled_task.rb
class ActionDeletionsScheduledTask (line 3) | class ActionDeletionsScheduledTask < ApplicationScheduledTask
method call (line 5) | def call
FILE: app/scheduled_tasks/application_scheduled_task.rb
class ApplicationScheduledTask (line 3) | class ApplicationScheduledTask
method initialize (line 5) | def initialize(logger:)
method call (line 9) | def call
method next_run_after (line 17) | def next_run_after
method quarter_past_each_hour (line 23) | def quarter_past_each_hour
method quarter_to_each_hour (line 30) | def quarter_to_each_hour
method three_am (line 37) | def three_am
FILE: app/scheduled_tasks/check_all_dns_scheduled_task.rb
class CheckAllDNSScheduledTask (line 3) | class CheckAllDNSScheduledTask < ApplicationScheduledTask
method call (line 5) | def call
FILE: app/scheduled_tasks/cleanup_authie_sessions_scheduled_task.rb
class CleanupAuthieSessionsScheduledTask (line 5) | class CleanupAuthieSessionsScheduledTask < ApplicationScheduledTask
method call (line 7) | def call
FILE: app/scheduled_tasks/expire_held_messages_scheduled_task.rb
class ExpireHeldMessagesScheduledTask (line 3) | class ExpireHeldMessagesScheduledTask < ApplicationScheduledTask
method call (line 5) | def call
FILE: app/scheduled_tasks/process_message_retention_scheduled_task.rb
class ProcessMessageRetentionScheduledTask (line 3) | class ProcessMessageRetentionScheduledTask < ApplicationScheduledTask
method call (line 5) | def call
method next_run_after (line 25) | def self.next_run_after
FILE: app/scheduled_tasks/prune_suppression_lists_scheduled_task.rb
class PruneSuppressionListsScheduledTask (line 3) | class PruneSuppressionListsScheduledTask < ApplicationScheduledTask
method call (line 5) | def call
method next_run_after (line 12) | def self.next_run_after
FILE: app/scheduled_tasks/prune_webhook_requests_scheduled_task.rb
class PruneWebhookRequestsScheduledTask (line 3) | class PruneWebhookRequestsScheduledTask < ApplicationScheduledTask
method call (line 5) | def call
method next_run_after (line 12) | def self.next_run_after
FILE: app/scheduled_tasks/send_notifications_scheduled_task.rb
class SendNotificationsScheduledTask (line 3) | class SendNotificationsScheduledTask < ApplicationScheduledTask
method call (line 5) | def call
method next_run_after (line 9) | def self.next_run_after
FILE: app/scheduled_tasks/tidy_queued_messages_task.rb
class TidyQueuedMessagesTask (line 3) | class TidyQueuedMessagesTask < ApplicationScheduledTask
method call (line 5) | def call
method next_run_after (line 14) | def self.next_run_after
FILE: app/senders/base_sender.rb
class BaseSender (line 3) | class BaseSender
method start (line 5) | def start
method send_message (line 8) | def send_message(message)
method finish (line 11) | def finish
FILE: app/senders/http_sender.rb
class HTTPSender (line 3) | class HTTPSender < BaseSender
method initialize (line 5) | def initialize(endpoint, options = {})
method send_message (line 12) | def send_message(message)
method log (line 62) | def log(text)
method parameters (line 66) | def parameters(message, options = {})
FILE: app/senders/send_result.rb
class SendResult (line 3) | class SendResult
method initialize (line 15) | def initialize
FILE: app/senders/smtp_sender.rb
class SMTPSender (line 3) | class SMTPSender < BaseSender
method initialize (line 10) | def initialize(domain, source_ip_address = nil, servers: nil, log_id: ...
method start (line 27) | def start
method send_message (line 40) | def send_message(message)
method finish (line 71) | def finish
method send_message_to_smtp_client (line 87) | def send_message_to_smtp_client(raw_message, mail_from, rcpt_to, retry...
method determine_mail_from_for_message (line 139) | def determine_mail_from_for_message(message)
method determine_rcpt_to_for_message (line 155) | def determine_rcpt_to_for_message(message)
method resolve_mx_records_for_domain (line 164) | def resolve_mx_records_for_domain
method connect_to_endpoint (line 179) | def connect_to_endpoint(endpoint, allow_ssl: true)
method create_result (line 220) | def create_result(type, start_time = nil)
method logger (line 232) | def logger
method smtp_relays (line 241) | def smtp_relays
FILE: app/services/webhook_delivery_service.rb
class WebhookDeliveryService (line 3) | class WebhookDeliveryService
method initialize (line 7) | def initialize(webhook_request:)
method call (line 11) | def call
method success? (line 21) | def success?
method generate_payload (line 27) | def generate_payload
method send_request (line 36) | def send_request
method record_attempt (line 45) | def record_attempt
method appreciate_http_result (line 68) | def appreciate_http_result
method update_webhook_request (line 80) | def update_webhook_request
method logger (line 93) | def logger
FILE: app/util/has_prometheus_metrics.rb
type HasPrometheusMetrics (line 3) | module HasPrometheusMetrics
function register_prometheus_counter (line 5) | def register_prometheus_counter(name, **kwargs)
function register_prometheus_histogram (line 10) | def register_prometheus_histogram(name, **kwargs)
function increment_prometheus_counter (line 15) | def increment_prometheus_counter(name, labels: {})
function observe_prometheus_histogram (line 22) | def observe_prometheus_histogram(name, time, labels: {})
function registry (line 31) | def registry
FILE: app/util/health_server.rb
class HealthServer (line 7) | class HealthServer
method initialize (line 9) | def initialize(name: "unnamed-process")
method call (line 13) | def call(env)
method root (line 28) | def root
method ok (line 32) | def ok
method not_found (line 36) | def not_found
method metrics (line 40) | def metrics
method hostname (line 46) | def hostname
method run (line 54) | def run(default_port:, default_bind_address:, **options)
method start (line 68) | def start(**options)
class LoggerProxy (line 76) | class LoggerProxy
method add (line 88) | def add(severity, message)
FILE: app/util/user_creator.rb
type UserCreator (line 5) | module UserCreator
function start (line 9) | def start(&block)
FILE: config/application.rb
type Postal (line 19) | module Postal
class Application (line 20) | class Application < Rails::Application
FILE: config/initializers/logging.rb
function add_exception_to_payload (line 4) | def add_exception_to_payload(payload, event)
FILE: config/initializers/mail_extensions.rb
type Mail (line 4) | module Mail
type Encodings (line 6) | module Encodings
function q_value_decode (line 9) | def self.q_value_decode(str)
function b_value_decode (line 14) | def self.b_value_decode(str)
class Message (line 21) | class Message
method plain_body (line 24) | def plain_body
method html_body (line 33) | def html_body
method parse_message (line 44) | def parse_message
method find_attachment (line 51) | def find_attachment
method decode_body_as_text (line 91) | def decode_body_as_text
class AttachmentsList (line 112) | class AttachmentsList < Array
method initialize (line 115) | def initialize(parts_list)
class Array (line 129) | class Array
method decoded (line 131) | def decoded
class NilClass (line 139) | class NilClass
method decoded (line 141) | def decoded
FILE: config/initializers/record_key_for_dom.rb
type ActionView (line 3) | module ActionView
type RecordIdentifier (line 4) | module RecordIdentifier
function dom_id (line 6) | def dom_id(record, prefix = nil)
FILE: config/initializers/smtp_extensions.rb
type Net (line 3) | module Net
class SMTP (line 4) | class SMTP
method secure_socket? (line 8) | def secure_socket?
method rset (line 20) | def rset
method rset_errors (line 25) | def rset_errors
method tcp_socket (line 31) | def tcp_socket(address, port)
class Response (line 35) | class Response
method message (line 37) | def message
FILE: db/migrate/20161003195209_create_authie_sessions.authie.rb
class CreateAuthieSessions (line 4) | class CreateAuthieSessions < ActiveRecord::Migration
method change (line 6) | def change
FILE: db/migrate/20161003195210_add_indexes_to_authie_sessions.authie.rb
class AddIndexesToAuthieSessions (line 4) | class AddIndexesToAuthieSessions < ActiveRecord::Migration
method change (line 6) | def change
FILE: db/migrate/20161003195211_add_parent_id_to_authie_sessions.authie.rb
class AddParentIdToAuthieSessions (line 4) | class AddParentIdToAuthieSessions < ActiveRecord::Migration
method change (line 6) | def change
FILE: db/migrate/20161003195212_add_two_factor_auth_fields_to_authie.authie.rb
class AddTwoFactorAuthFieldsToAuthie (line 4) | class AddTwoFactorAuthFieldsToAuthie < ActiveRecord::Migration
method change (line 6) | def change
FILE: db/migrate/20170418200606_initial_schema.rb
class InitialSchema (line 3) | class InitialSchema < ActiveRecord::Migration
method up (line 5) | def up
FILE: db/migrate/20170421195414_add_token_hashes_to_authie_sessions.authie.rb
class AddTokenHashesToAuthieSessions (line 4) | class AddTokenHashesToAuthieSessions < ActiveRecord::Migration
method change (line 6) | def change
FILE: db/migrate/20170421195415_add_index_to_token_hashes_on_authie_sessions.authie.rb
class AddIndexToTokenHashesOnAuthieSessions (line 4) | class AddIndexToTokenHashesOnAuthieSessions < ActiveRecord::Migration
method change (line 6) | def change
FILE: db/migrate/20170428153353_remove_type_from_ip_pools.rb
class RemoveTypeFromIPPools (line 3) | class RemoveTypeFromIPPools < ActiveRecord::Migration[5.0]
method change (line 5) | def change
FILE: db/migrate/20180216114344_add_host_to_authie_sessions.authie.rb
class AddHostToAuthieSessions (line 4) | class AddHostToAuthieSessions < ActiveRecord::Migration[4.2]
method change (line 6) | def change
FILE: db/migrate/20200717083943_add_uuid_to_credentials.rb
class AddUUIDToCredentials (line 3) | class AddUUIDToCredentials < ActiveRecord::Migration[5.2]
method change (line 5) | def change
FILE: db/migrate/20210727210551_add_priority_to_ip_addresses.rb
class AddPriorityToIPAddresses (line 3) | class AddPriorityToIPAddresses < ActiveRecord::Migration[5.2]
method change (line 5) | def change
FILE: db/migrate/20240206173036_add_privacy_mode_to_servers.rb
class AddPrivacyModeToServers (line 3) | class AddPrivacyModeToServers < ActiveRecord::Migration[6.1]
method change (line 5) | def change
FILE: db/migrate/20240213165450_create_worker_roles.rb
class CreateWorkerRoles (line 3) | class CreateWorkerRoles < ActiveRecord::Migration[6.1]
method change (line 5) | def change
FILE: db/migrate/20240213171830_create_scheduled_tasks.rb
class CreateScheduledTasks (line 3) | class CreateScheduledTasks < ActiveRecord::Migration[6.1]
method change (line 5) | def change
FILE: db/migrate/20240214132253_add_lock_fields_to_webhook_requests.rb
class AddLockFieldsToWebhookRequests (line 3) | class AddLockFieldsToWebhookRequests < ActiveRecord::Migration[6.1]
method change (line 5) | def change
FILE: db/migrate/20240223141500_add_two_factor_required_to_sessions.authie.rb
class AddTwoFactorRequiredToSessions (line 4) | class AddTwoFactorRequiredToSessions < ActiveRecord::Migration[6.1]
method change (line 6) | def change
FILE: db/migrate/20240223141501_add_countries_to_authie_sessions.authie.rb
class AddCountriesToAuthieSessions (line 4) | class AddCountriesToAuthieSessions < ActiveRecord::Migration[6.1]
method change (line 6) | def change
FILE: db/migrate/20240311205229_add_oidc_fields_to_user.rb
class AddOIDCFieldsToUser (line 3) | class AddOIDCFieldsToUser < ActiveRecord::Migration[7.0]
method change (line 5) | def change
FILE: lib/migration_waiter.rb
class MigrationWaiter (line 8) | class MigrationWaiter
method wait (line 15) | def wait
method wait_if_appropriate (line 36) | def wait_if_appropriate
method console? (line 46) | def console?
method rake_task? (line 50) | def rake_task?
method rails_command? (line 54) | def rails_command?
FILE: lib/postal.rb
type Postal (line 3) | module Postal
FILE: lib/postal/config.rb
type Postal (line 20) | module Postal
function config_file_path (line 29) | def config_file_path
function initialize_config (line 33) | def initialize_config
function host_with_protocol (line 78) | def host_with_protocol
function logger (line 82) | def logger
function process_name (line 90) | def process_name
function locker_name (line 98) | def locker_name
function locker_name_with_suffix (line 105) | def locker_name_with_suffix(suffix)
function signer (line 109) | def signer
function rp_dkim_dns_record (line 116) | def rp_dkim_dns_record
function ip_pools? (line 121) | def ip_pools?
function graylog_logging_destination (line 125) | def graylog_logging_destination
function change_database_connection_pool_size (line 144) | def change_database_connection_pool_size(new_size)
function branch (line 158) | def branch
function version (line 167) | def version
function read_version_file (line 175) | def read_version_file(file)
FILE: lib/postal/config_schema.rb
type Postal (line 5) | module Postal
function substitute_config_file_root (line 596) | def substitute_config_file_root(string)
FILE: lib/postal/error.rb
type Postal (line 3) | module Postal
class Error (line 5) | class Error < StandardError
type Errors (line 8) | module Errors
class AuthenticationError (line 9) | class AuthenticationError < Error
method initialize (line 13) | def initialize(error)
method to_s (line 18) | def to_s
FILE: lib/postal/helm_config_exporter.rb
type Postal (line 5) | module Postal
class HelmConfigExporter (line 6) | class HelmConfigExporter < Konfig::Exporters::Abstract
method export (line 8) | def export
FILE: lib/postal/helpers.rb
type Postal (line 3) | module Postal
type Helpers (line 4) | module Helpers
function strip_name_from_address (line 6) | def self.strip_name_from_address(address)
FILE: lib/postal/http.rb
type Postal (line 6) | module Postal
type HTTP (line 7) | module HTTP
function get (line 9) | def self.get(url, options = {})
function post (line 13) | def self.post(url, options = {})
function request (line 17) | def self.request(method, url, options = {})
FILE: lib/postal/legacy_config_source.rb
type Postal (line 6) | module Postal
class LegacyConfigSource (line 7) | class LegacyConfigSource < Konfig::Sources::Abstract
method initialize (line 106) | def initialize(config)
method get (line 111) | def get(path, attribute: nil)
FILE: lib/postal/message_db/click.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
class Click (line 5) | class Click
method initialize (line 7) | def initialize(attributes, link)
FILE: lib/postal/message_db/connection_pool.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
class ConnectionPool (line 5) | class ConnectionPool
method initialize (line 9) | def initialize
method use (line 14) | def use
method checkout (line 43) | def checkout
method checkin (line 52) | def checkin(connection)
method add_new_connection (line 58) | def add_new_connection
method establish_connection (line 64) | def establish_connection
FILE: lib/postal/message_db/database.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
class Database (line 5) | class Database
method connection_pool (line 9) | def connection_pool
method initialize (line 15) | def initialize(organization_id, server_id, database_name: nil)
method server (line 27) | def server
method schema_version (line 34) | def schema_version
method message (line 46) | def message(*args)
method messages (line 53) | def messages(*args)
method messages_with_pagination (line 57) | def messages_with_pagination(*args)
method new_message (line 65) | def new_message(attributes = {})
method total_size (line 72) | def total_size
method live_stats (line 79) | def live_stats
method statistics (line 86) | def statistics
method provisioner (line 93) | def provisioner
method suppression_list (line 100) | def suppression_list
method webhooks (line 107) | def webhooks
method raw_table_name_for_date (line 114) | def raw_table_name_for_date(date)
method insert_raw_message (line 121) | def insert_raw_message(data, date = Time.now.utc.to_date)
method select (line 149) | def select(table, options = {})
method select_with_pagination (line 188) | def select_with_pagination(table, page, options = {})
method update (line 213) | def update(table, attributes, options = {})
method insert (line 229) | def insert(table, attributes)
method insert_multi (line 242) | def insert_multi(table, keys, values)
method delete (line 262) | def delete(table, options = {})
method database_name (line 274) | def database_name
class ResultForExplainPrinter (line 281) | class ResultForExplainPrinter
method initialize (line 286) | def initialize(result)
method stringify_keys (line 298) | def stringify_keys(hash)
method escape (line 302) | def escape(value)
method query (line 316) | def query(query)
method query_on_connection (line 324) | def query_on_connection(connection, query)
method logger (line 340) | def logger
method with_mysql (line 344) | def with_mysql(&block)
method build_where_string (line 348) | def build_where_string(attributes, joiner = ", ")
method hash_to_sql (line 352) | def hash_to_sql(hash, joiner = ", ")
FILE: lib/postal/message_db/delivery.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
class Delivery (line 5) | class Delivery
method create (line 7) | def self.create(message, attributes = {})
method initialize (line 24) | def initialize(message, attributes)
method method_missing (line 29) | def method_missing(name, value = nil, &block)
method respond_to_missing? (line 35) | def respond_to_missing?(name, include_private = false)
method timestamp (line 39) | def timestamp
method update_statistics (line 43) | def update_statistics
method send_webhooks (line 53) | def send_webhooks
method webhook_hash (line 59) | def webhook_hash
method webhook_event (line 72) | def webhook_event
FILE: lib/postal/message_db/live_stats.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
class LiveStats (line 5) | class LiveStats
method initialize (line 7) | def initialize(database)
method increment (line 14) | def increment(type)
method total (line 26) | def total(minutes, options = {})
FILE: lib/postal/message_db/load.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
class Load (line 5) | class Load
method initialize (line 7) | def initialize(attributes)
FILE: lib/postal/message_db/message.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
class Message (line 5) | class Message
class NotFound (line 7) | class NotFound < Postal::Error
method find_one (line 10) | def self.find_one(database, query)
method find (line 17) | def self.find(database, options = {})
method find_with_pagination (line 29) | def self.find_with_pagination(database, page, options = {})
method initialize (line 37) | def initialize(database, attributes)
method reload (line 42) | def reload
method server (line 49) | def server
method credential (line 56) | def credential
method route (line 63) | def route
method endpoint (line 70) | def endpoint
method domain (line 81) | def domain
method copy_attributes_from_raw_message (line 88) | def copy_attributes_from_raw_message
method timestamp (line 101) | def timestamp
method last_delivery_attempt (line 108) | def last_delivery_attempt
method hold_expiry (line 115) | def hold_expiry
method read? (line 122) | def read?
method create_delivery (line 129) | def create_delivery(status, options = {})
method deliveries (line 139) | def deliveries
method clicks (line 148) | def clicks
method loads (line 165) | def loads
method activity_entries (line 177) | def activity_entries
method method_missing (line 184) | def method_missing(name, value = nil, &block)
method respond_to_missing? (line 192) | def respond_to_missing?(name, include_private = false)
method persisted? (line 200) | def persisted?
method save (line 207) | def save(queue_on_create: true)
method update (line 216) | def update(attributes_to_change)
method delete (line 228) | def delete
method raw_headers (line 237) | def raw_headers
method raw_body (line 248) | def raw_body
method raw_message (line 259) | def raw_message
method raw_message= (line 266) | def raw_message=(raw)
method save_raw_message (line 273) | def save_raw_message
method raw_message? (line 294) | def raw_message?
method plain_body (line 301) | def plain_body
method html_body (line 308) | def html_body
method html_body_without_tracking_image (line 315) | def html_body_without_tracking_image
method attachments (line 322) | def attachments
method headers (line 329) | def headers
method recipient_domain (line 346) | def recipient_domain
method add_to_message_queue (line 353) | def add_to_message_queue(**options)
method batch_key (line 366) | def batch_key
method queued_message (line 383) | def queued_message
method spam_status (line 390) | def spam_status
method held? (line 399) | def held?
method has_outgoing_headers? (line 406) | def has_outgoing_headers?
method add_outgoing_headers (line 413) | def add_outgoing_headers
method append_headers (line 426) | def append_headers(*headers)
method webhook_hash (line 438) | def webhook_hash
method bounce! (line 456) | def bounce!(bounce_message)
method send_bounces? (line 468) | def send_bounces?
method create_load (line 475) | def create_load(request)
method create_link (line 489) | def create_link(url)
method original_messages (line 499) | def original_messages
method rcpt_to_return_path? (line 513) | def rcpt_to_return_path?
method inspect_message (line 520) | def inspect_message
method spam_checks (line 536) | def spam_checks
method cancel_hold (line 543) | def cancel_hold
method parse_content (line 552) | def parse_content
method parsed? (line 568) | def parsed?
method should_parse? (line 575) | def should_parse?
method _update (line 581) | def _update
method _create (line 585) | def _create(queue: true)
method mail (line 597) | def mail
FILE: lib/postal/message_db/migration.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
class Migration (line 5) | class Migration
method initialize (line 7) | def initialize(database)
method up (line 11) | def up
method run (line 14) | def self.run(database, start_from: database.schema_version, silent...
FILE: lib/postal/message_db/migrations/01_create_migrations.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
type Migrations (line 5) | module Migrations
class CreateMigrations (line 6) | class CreateMigrations < Postal::MessageDB::Migration
method up (line 8) | def up
FILE: lib/postal/message_db/migrations/02_create_messages.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
type Migrations (line 5) | module Migrations
class CreateMessages (line 6) | class CreateMessages < Postal::MessageDB::Migration
method up (line 8) | def up
FILE: lib/postal/message_db/migrations/03_create_deliveries.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
type Migrations (line 5) | module Migrations
class CreateDeliveries (line 6) | class CreateDeliveries < Postal::MessageDB::Migration
method up (line 8) | def up
FILE: lib/postal/message_db/migrations/04_create_live_stats.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
type Migrations (line 5) | module Migrations
class CreateLiveStats (line 6) | class CreateLiveStats < Postal::MessageDB::Migration
method up (line 8) | def up
FILE: lib/postal/message_db/migrations/05_create_raw_message_sizes.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
type Migrations (line 5) | module Migrations
class CreateRawMessageSizes (line 6) | class CreateRawMessageSizes < Postal::MessageDB::Migration
method up (line 8) | def up
FILE: lib/postal/message_db/migrations/06_create_clicks.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
type Migrations (line 5) | module Migrations
class CreateClicks (line 6) | class CreateClicks < Postal::MessageDB::Migration
method up (line 8) | def up
FILE: lib/postal/message_db/migrations/07_create_loads.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
type Migrations (line 5) | module Migrations
class CreateLoads (line 6) | class CreateLoads < Postal::MessageDB::Migration
method up (line 8) | def up
FILE: lib/postal/message_db/migrations/08_create_stats.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
type Migrations (line 5) | module Migrations
class CreateStats (line 6) | class CreateStats < Postal::MessageDB::Migration
method up (line 8) | def up
FILE: lib/postal/message_db/migrations/09_create_links.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
type Migrations (line 5) | module Migrations
class CreateLinks (line 6) | class CreateLinks < Postal::MessageDB::Migration
method up (line 8) | def up
FILE: lib/postal/message_db/migrations/10_create_spam_checks.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
type Migrations (line 5) | module Migrations
class CreateSpamChecks (line 6) | class CreateSpamChecks < Postal::MessageDB::Migration
method up (line 8) | def up
FILE: lib/postal/message_db/migrations/11_add_time_to_deliveries.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
type Migrations (line 5) | module Migrations
class AddTimeToDeliveries (line 6) | class AddTimeToDeliveries < Postal::MessageDB::Migration
method up (line 8) | def up
FILE: lib/postal/message_db/migrations/12_add_hold_expiry.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
type Migrations (line 5) | module Migrations
class AddHoldExpiry (line 6) | class AddHoldExpiry < Postal::MessageDB::Migration
method up (line 8) | def up
FILE: lib/postal/message_db/migrations/13_add_index_to_message_status.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
type Migrations (line 5) | module Migrations
class AddIndexToMessageStatus (line 6) | class AddIndexToMessageStatus < Postal::MessageDB::Migration
method up (line 8) | def up
FILE: lib/postal/message_db/migrations/14_create_suppressions.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
type Migrations (line 5) | module Migrations
class CreateSuppressions (line 6) | class CreateSuppressions < Postal::MessageDB::Migration
method up (line 8) | def up
FILE: lib/postal/message_db/migrations/15_create_webhook_requests.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
type Migrations (line 5) | module Migrations
class CreateWebhookRequests (line 6) | class CreateWebhookRequests < Postal::MessageDB::Migration
method up (line 8) | def up
FILE: lib/postal/message_db/migrations/16_add_url_and_hook_to_webhooks.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
type Migrations (line 5) | module Migrations
class AddUrlAndHookToWebhooks (line 6) | class AddUrlAndHookToWebhooks < Postal::MessageDB::Migration
method up (line 8) | def up
FILE: lib/postal/message_db/migrations/17_add_replaced_link_count_to_messages.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
type Migrations (line 5) | module Migrations
class AddReplacedLinkCountToMessages (line 6) | class AddReplacedLinkCountToMessages < Postal::MessageDB::Migration
method up (line 8) | def up
FILE: lib/postal/message_db/migrations/18_add_endpoints_to_messages.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
type Migrations (line 5) | module Migrations
class AddEndpointsToMessages (line 6) | class AddEndpointsToMessages < Postal::MessageDB::Migration
method up (line 8) | def up
FILE: lib/postal/message_db/migrations/19_convert_database_to_utf8mb4.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
type Migrations (line 5) | module Migrations
class ConvertDatabaseToUtf8mb4 (line 6) | class ConvertDatabaseToUtf8mb4 < Postal::MessageDB::Migration
method up (line 8) | def up
FILE: lib/postal/message_db/migrations/20_increase_links_url_size.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
type Migrations (line 5) | module Migrations
class IncreaseLinksUrlSize (line 6) | class IncreaseLinksUrlSize < Postal::MessageDB::Migration
method up (line 8) | def up
FILE: lib/postal/message_db/provisioner.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
class Provisioner (line 5) | class Provisioner
method initialize (line 7) | def initialize(database)
method provision (line 14) | def provision
method migrate (line 23) | def migrate(start_from: @database.schema_version, silent: false)
method exists? (line 30) | def exists?
method create (line 37) | def create
method drop (line 47) | def drop
method create_table (line 57) | def create_table(table_name, options)
method drop_table (line 64) | def drop_table(table_name)
method clean (line 72) | def clean
method create_raw_table (line 83) | def create_raw_table(table)
method raw_tables (line 98) | def raw_tables(max_age = 30)
method remove_raw_tables_older_than (line 114) | def remove_raw_tables_older_than(max_age = 30)
method remove_raw_table (line 123) | def remove_raw_table(table)
method remove_messages (line 132) | def remove_messages(max_age = 60)
method remove_raw_tables_until_less_than_size (line 147) | def remove_raw_tables_until_less_than_size(size)
method create_table_query (line 163) | def create_table_query(table_name, options)
FILE: lib/postal/message_db/statistics.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
class Statistics (line 5) | class Statistics
method initialize (line 7) | def initialize(database)
method increment_one (line 17) | def increment_one(type, field, time = Time.now)
method increment_all (line 33) | def increment_all(time, field)
method get (line 42) | def get(type, counters, start_date = Time.now, quantity = 10)
FILE: lib/postal/message_db/suppression_list.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
class SuppressionList (line 5) | class SuppressionList
method initialize (line 7) | def initialize(database)
method add (line 11) | def add(type, address, options = {})
method get (line 22) | def get(type, address)
method all_with_pagination (line 26) | def all_with_pagination(page)
method remove (line 30) | def remove(type, address)
method prune (line 34) | def prune
FILE: lib/postal/message_db/webhooks.rb
type Postal (line 3) | module Postal
type MessageDB (line 4) | module MessageDB
class Webhooks (line 5) | class Webhooks
method initialize (line 7) | def initialize(database)
method record (line 11) | def record(attributes = {})
method list (line 15) | def list(page = 1)
method find (line 21) | def find(uuid)
method prune (line 26) | def prune
class RequestNotFound (line 32) | class RequestNotFound < Postal::Error
class Request (line 35) | class Request
method initialize (line 37) | def initialize(attributes)
method [] (line 41) | def [](name)
method timestamp (line 45) | def timestamp
method event (line 49) | def event
method status_code (line 53) | def status_code
method url (line 57) | def url
method uuid (line 61) | def uuid
method payload (line 65) | def payload
method pretty_payload (line 69) | def pretty_payload
method body (line 76) | def body
method attempt (line 80) | def attempt
method will_retry? (line 84) | def will_retry?
FILE: lib/postal/message_inspection.rb
type Postal (line 3) | module Postal
class MessageInspection (line 4) | class MessageInspection
method initialize (line 12) | def initialize(message, scope)
method spam_score (line 19) | def spam_score
method scan (line 25) | def scan
method scan (line 33) | def scan(message, scope)
FILE: lib/postal/message_inspector.rb
type Postal (line 3) | module Postal
class MessageInspector (line 4) | class MessageInspector
method initialize (line 6) | def initialize(config)
method inspect_message (line 12) | def inspect_message(message, scope, inspection)
method logger (line 17) | def logger
method inspectors (line 25) | def inspectors
FILE: lib/postal/message_inspectors/clamav.rb
type Postal (line 3) | module Postal
type MessageInspectors (line 4) | module MessageInspectors
class Clamav (line 5) | class Clamav < MessageInspector
method inspect_message (line 7) | def inspect_message(inspection)
FILE: lib/postal/message_inspectors/rspamd.rb
type Postal (line 5) | module Postal
type MessageInspectors (line 6) | module MessageInspectors
class Rspamd (line 7) | class Rspamd < MessageInspector
class Error (line 9) | class Error < StandardError
method inspect_message (line 12) | def inspect_message(inspection)
method request (line 28) | def request(message, scope)
FILE: lib/postal/message_inspectors/spam_assassin.rb
type Postal (line 3) | module Postal
type MessageInspectors (line 4) | module MessageInspectors
class SpamAssassin (line 5) | class SpamAssassin < MessageInspector
method inspect_message (line 12) | def inspect_message(inspection)
FILE: lib/postal/message_parser.rb
type Postal (line 3) | module Postal
class MessageParser (line 4) | class MessageParser
method initialize (line 8) | def initialize(message)
method actioned? (line 23) | def actioned?
method new_body (line 27) | def new_body
method new_headers (line 31) | def new_headers
method generate (line 37) | def generate
method parse_parts (line 68) | def parse_parts(parts)
method parse (line 87) | def parse(part, type = nil)
method insert_links (line 99) | def insert_links(part, type = nil)
method insert_tracking_image (line 138) | def insert_tracking_image(part)
method domain (line 148) | def domain
method track_domain? (line 152) | def track_domain?(domain)
FILE: lib/postal/signer.rb
type Postal (line 4) | module Postal
class Signer (line 5) | class Signer
method initialize (line 11) | def initialize(private_key)
method public_key (line 23) | def public_key
method sign (line 31) | def sign(data)
method sign64 (line 39) | def sign64(data)
method jwk (line 46) | def jwk
method sha1_sign (line 54) | def sha1_sign(data)
method sha1_sign64 (line 62) | def sha1_sign64(data)
FILE: lib/postal/spam_check.rb
type Postal (line 3) | module Postal
class SpamCheck (line 4) | class SpamCheck
method initialize (line 8) | def initialize(code, score, description = nil)
method to_hash (line 14) | def to_hash
FILE: lib/postal/yaml_config_exporter.rb
type Postal (line 5) | module Postal
class YamlConfigExporter (line 6) | class YamlConfigExporter < Konfig::Exporters::Abstract
method export (line 8) | def export
FILE: lib/tracking_middleware.rb
class TrackingMiddleware (line 3) | class TrackingMiddleware
method initialize (line 7) | def initialize(app = nil)
method call (line 11) | def call(env)
method dispatch_image_request (line 34) | def dispatch_image_request(request, server_token, message_token)
method dispatch_redirect_request (line 75) | def dispatch_redirect_request(request, server_token, link_token)
method get_message_db_from_server_token (line 115) | def get_message_db_from_server_token(token)
FILE: spec/helpers/general_helpers.rb
type GeneralHelpers (line 3) | module GeneralHelpers
function create_plain_text_message (line 5) | def create_plain_text_message(server, text, to = "test@example.com", o...
FILE: spec/helpers/message_db_mocking.rb
type GlobalMessageDB (line 3) | module GlobalMessageDB
function find_or_create (line 7) | def find_or_create
function exists? (line 14) | def exists?
FILE: spec/helpers/message_factory.rb
class MessageFactory (line 5) | class MessageFactory
method initialize (line 7) | def initialize(server)
method incoming (line 11) | def incoming(route: nil, &block)
method outgoing (line 25) | def outgoing(domain: nil, credential: nil, &block)
method incoming (line 45) | def incoming(server, **kwargs, &block)
method outgoing (line 49) | def outgoing(server, **kwargs, &block)
method create_message (line 57) | def create_message
method create_mail (line 69) | def create_mail(to, from)
FILE: spec/helpers/test_logger.rb
class TestLogger (line 3) | class TestLogger
method initialize (line 5) | def initialize
method print! (line 11) | def print!
method add (line 15) | def add(level, message, **tags)
method tagged (line 31) | def tagged(**tags, &block)
method log_line (line 35) | def log_line(match)
method has_logged? (line 43) | def has_logged?(match)
FILE: spec/lib/message_dequeuer/base_spec.rb
type MessageDequeuer (line 5) | module MessageDequeuer
FILE: spec/lib/message_dequeuer/incoming_message_processor_spec.rb
type MessageDequeuer (line 5) | module MessageDequeuer
FILE: spec/lib/message_dequeuer/initial_message_processor_spec.rb
type MessageDequeuer (line 5) | module MessageDequeuer
FILE: spec/lib/message_dequeuer/outgoing_message_processor_spec.rb
type MessageDequeuer (line 5) | module MessageDequeuer
FILE: spec/lib/message_dequeuer/single_message_processor_spec.rb
type MessageDequeuer (line 5) | module MessageDequeuer
FILE: spec/lib/message_dequeuer/state_spec.rb
type MessageDequeuer (line 5) | module MessageDequeuer
FILE: spec/lib/postal/legacy_config_source_spec.rb
type Postal (line 5) | module Postal
FILE: spec/lib/postal/signer_spec.rb
type Postal (line 4) | module Postal
FILE: spec/lib/smtp_client/endpoint_spec.rb
type SMTPClient (line 5) | module SMTPClient
FILE: spec/lib/smtp_client/server_spec.rb
type SMTPClient (line 5) | module SMTPClient
FILE: spec/lib/smtp_server/client/auth_spec.rb
type SMTPServer (line 5) | module SMTPServer
FILE: spec/lib/smtp_server/client/data_spec.rb
type SMTPServer (line 5) | module SMTPServer
FILE: spec/lib/smtp_server/client/finished_spec.rb
type SMTPServer (line 5) | module SMTPServer
FILE: spec/lib/smtp_server/client/helo_spec.rb
type SMTPServer (line 5) | module SMTPServer
FILE: spec/lib/smtp_server/client/mail_from_spec.rb
type SMTPServer (line 5) | module SMTPServer
FILE: spec/lib/smtp_server/client/proxy_spec.rb
type SMTPServer (line 5) | module SMTPServer
FILE: spec/lib/smtp_server/client/rcpt_to_spec.rb
type SMTPServer (line 5) | module SMTPServer
FILE: spec/lib/smtp_server/client_spec.rb
type SMTPServer (line 5) | module SMTPServer
FILE: spec/lib/worker/jobs/process_queued_messages_job_spec.rb
type Worker (line 5) | module Worker
type Jobs (line 6) | module Jobs
FILE: spec/lib/worker/jobs/process_webhook_requests_job_spec.rb
type Worker (line 5) | module Worker
type Jobs (line 6) | module Jobs
Condensed preview — 525 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,381K chars).
[
{
"path": ".dockerignore",
"chars": 204,
"preview": ".byebug_history\n.cache\n.git/*\n.github/*\n.vscode/*\n.yardoc/*\n/.bundle\nconfig/postal/*\ndoc/*\nDockerfile\nlog/*\nnode_modules"
},
{
"path": ".github/ISSUE_TEMPLATE/bug_report.md",
"chars": 766,
"preview": "---\nname: 🐛 Bug report\nabout: Create a report to help us improve Postal and fix issues.\ntitle: ''\nlabels: ''\nassignees: "
},
{
"path": ".github/ISSUE_TEMPLATE/config.yml",
"chars": 651,
"preview": "blank_issues_enabled: false\ncontact_links:\n - name: 💻 Installation help\n url: https://github.com/postalhq/postal/dis"
},
{
"path": ".github/workflows/ci.yml",
"chars": 4264,
"preview": "---\nname: CI\non: [push]\n\njobs:\n release-please:\n runs-on: ubuntu-latest\n if: github.ref == 'refs/heads/main'\n "
},
{
"path": ".github/workflows/close.yml",
"chars": 1166,
"preview": "name: 'Close stale issues and PRs'\non:\n schedule:\n - cron: '30 1 * * *'\n workflow_dispatch: \npermissions:\n issues:"
},
{
"path": ".gitignore",
"chars": 672,
"preview": "# See https://help.github.com/articles/ignoring-files for more about ignoring files.\n#\n# If you find yourself ignoring t"
},
{
"path": ".release-please-manifest.json",
"chars": 19,
"preview": "{\n \".\": \"3.3.5\"\n}\n"
},
{
"path": ".rubocop.yml",
"chars": 4695,
"preview": "AllCops:\n TargetRubyVersion: 3.0\n NewCops: enable\n Exclude:\n - \"bin/*\"\n - \"db/schema.rb\"\n # Fixes missing ge"
},
{
"path": ".ruby-version",
"chars": 6,
"preview": "3.4.6\n"
},
{
"path": "CHANGELOG.md",
"chars": 36349,
"preview": "# CHANGELOG\n\nThis file contains all the latest changes and updates to Postal.\n\n## [3.3.5](https://github.com/postalserve"
},
{
"path": "CONTRIBUTING.md",
"chars": 1935,
"preview": "# Contributing to Postal\n\nThis doc explains how to go about running Postal in development to allow you to make contribut"
},
{
"path": "Dockerfile",
"chars": 1848,
"preview": "FROM ruby:3.4.6-slim-bookworm AS base\n\nSHELL [\"/bin/bash\", \"-o\", \"pipefail\", \"-c\"]\nRUN apt-get update \\\n && apt-get ins"
},
{
"path": "Gemfile",
"chars": 1280,
"preview": "# frozen_string_literal: true\n\nsource \"https://rubygems.org\"\ngem \"abbrev\"\ngem \"authie\"\ngem \"autoprefixer-rails\"\ngem \"bcr"
},
{
"path": "MIT-LICENCE",
"chars": 1125,
"preview": "Copyright 2017-2024 Krystal Hosting Ltd\nCopyright 2024 Adam Cooke\nCopyright 2024 Charlie Smurthwaite\n\nPermission is here"
},
{
"path": "Procfile.dev",
"chars": 151,
"preview": "web: unset PORT; bundle exec puma -C config/puma.rb\nworker: bundle exec ruby script/worker.rb\nsmtp: unset PORT; bundle e"
},
{
"path": "README.md",
"chars": 699,
"preview": "\n\n**Postal** i"
},
{
"path": "Rakefile",
"chars": 258,
"preview": "# frozen_string_literal: true\n\n# Add your own tasks in files placed in lib/tasks ending in .rake,\n# for example lib/task"
},
{
"path": "SECURITY.md",
"chars": 453,
"preview": "# Security Policy\n\n## Supported Versions\n\nWe only support updates to the 3.x versions of Postal.\n\n| Version | Supported "
},
{
"path": "app/assets/config/manifest.js",
"chars": 174,
"preview": "//= link_tree ../images\n//= link_directory ../javascripts .js\n//= link_directory ../stylesheets .css\n//= link applicatio"
},
{
"path": "app/assets/images/.keep",
"chars": 0,
"preview": ""
},
{
"path": "app/assets/javascripts/application/application.coffee",
"chars": 2286,
"preview": "#= require jquery\n#= require jquery_ujs\n#= require turbolinks\n#= require_tree ./vendor/.\n#= require_self\n#= require_tree"
},
{
"path": "app/assets/javascripts/application/elements/ajax.coffee",
"chars": 1677,
"preview": "onStart = (event) ->\n $('.flashMessage').remove()\n $('input, select, textarea').blur()\n $target = $(event.target)\n i"
},
{
"path": "app/assets/javascripts/application/elements/mail_graph.coffee",
"chars": 737,
"preview": "$(document).on 'turbolinks:load', ->\n\n mailGraph = $('.mailGraph')\n\n if mailGraph.length\n data = JSON.parse(mailGra"
},
{
"path": "app/assets/javascripts/application/elements/remembering.coffee",
"chars": 218,
"preview": "$ ->\n $(document).on 'click', '.js-remember a', ->\n $parent = $(this).parents('.js-remember')\n value = $(this).at"
},
{
"path": "app/assets/javascripts/application/elements/searchable.coffee",
"chars": 3204,
"preview": "ENTER = 13\nDOWN_ARROW = 40\nUP_ARROW = 38\n\nfilterList = ($container, query) ->\n $items = getItems($container)\n index = "
},
{
"path": "app/assets/javascripts/application/vendor/chartist.js",
"chars": 172291,
"preview": "(function (root, factory) {\n if (typeof define === 'function' && define.amd) {\n // AMD. Register as an anonymous mod"
},
{
"path": "app/assets/javascripts/application/vendor/jquery.multibox.js",
"chars": 4582,
"preview": "(function ($) {\n\n 'use strict';\n\n function Multibox($el, options) {\n this.$el = $el;\n this.options = options;\n "
},
{
"path": "app/assets/stylesheets/application/application.scss",
"chars": 766,
"preview": "@import 'global/reset';\n@import 'global/variables';\n@import 'global/mixins';\n@import 'global/fonts';\n\n@import 'vendor/*'"
},
{
"path": "app/assets/stylesheets/application/components/_admin_stats.scss",
"chars": 195,
"preview": ".adminStats {\n display:flex;\n}\n\n.adminStats__stat {\n flex:1 1 auto;\n text-align: center;\n dt {\n font-weight:300;\n"
},
{
"path": "app/assets/stylesheets/application/components/_button_set.scss",
"chars": 112,
"preview": ".buttonSet {\n .button {\n margin-right:7px;\n }\n}\n\n\n.buttonSet--center {\n .button {\n margin:0 5px;\n }\n}\n"
},
{
"path": "app/assets/stylesheets/application/components/_checkbox_list.scss",
"chars": 639,
"preview": ".checkboxList {\n background:#fff;\n border:1px solid #e4e8ef;\n font:inherit;\n width:100%;\n color:$darkBlue;\n font-w"
},
{
"path": "app/assets/stylesheets/application/components/_credential_list.scss",
"chars": 1693,
"preview": ".credentialList {\n border-radius:4px;\n overflow:hidden;\n box-shadow:0 0 10px rgba(0,0,0,0.2);\n}\n\n.credentialList__ite"
},
{
"path": "app/assets/stylesheets/application/components/_danger_zone.scss",
"chars": 126,
"preview": ".dangerZone {\n border:3px dashed $red;\n border-radius:4px;\n padding:25px;\n color:$red;\n background:lighten($red, 42"
},
{
"path": "app/assets/stylesheets/application/components/_data_table.scss",
"chars": 1195,
"preview": ".dataTable {\n width:100%;\n border:1px solid #ddd;\n font-size:14px;\n box-shadow:0 0 5px rgba(0,0,0,0.3);\n\n}\n\n.dataTab"
},
{
"path": "app/assets/stylesheets/application/components/_delivery_list.scss",
"chars": 1306,
"preview": ".deliveryList {\n color:$darkBlue;\n border-radius:4px;\n overflow:hidden;\n box-shadow:0 0 10px rgba(0,0,0,0.2);\n}\n\n.de"
},
{
"path": "app/assets/stylesheets/application/components/_domain_list.scss",
"chars": 1811,
"preview": ".domainList {\n border-radius:4px;\n overflow:hidden;\n box-shadow:0 0 10px rgba(0,0,0,0.2);\n}\n\n.domainList__item {\n di"
},
{
"path": "app/assets/stylesheets/application/components/_endpoint_list.scss",
"chars": 720,
"preview": ".endpointList {\n border-radius:4px;\n overflow:hidden;\n box-shadow:0 0 10px rgba(0,0,0,0.2);\n}\n\n.endpointList__item {\n"
},
{
"path": "app/assets/stylesheets/application/components/_error_explanation.scss",
"chars": 466,
"preview": ".errorExplanation {\n border:1px solid $orange;\n margin-bottom:25px;\n color:$orange;\n padding:15px;\n box-shadow:0 0 "
},
{
"path": "app/assets/stylesheets/application/components/_field_set.scss",
"chars": 1775,
"preview": ".fieldSet {\n\n}\n\n.fieldSet__field {\n display:flex;\n}\n\n.fieldSet__field + .fieldSet__field {\n margin-top:20px;\n}\n\n.field"
},
{
"path": "app/assets/stylesheets/application/components/_flash_display.scss",
"chars": 0,
"preview": ""
},
{
"path": "app/assets/stylesheets/application/components/_flash_message.scss",
"chars": 484,
"preview": "html.main .flashMessage {\n position:fixed;\n background:$red;\n z-index:5000;\n left:25px;\n top:25px;\n width:300px;\n "
},
{
"path": "app/assets/stylesheets/application/components/_footer.scss",
"chars": 368,
"preview": ".footer__links {\n display:flex;\n margin-left:auto;\n align-items: center;\n font-size:13px;\n color:#999;\n li {\n h"
},
{
"path": "app/assets/stylesheets/application/components/_grid.scss",
"chars": 1045,
"preview": ".row {\n clear:both;\n margin-left:-20px;\n margin-right:-20px;\n @include clearfix;\n}\n\n.row--noPadding {\n margin-left:"
},
{
"path": "app/assets/stylesheets/application/components/_headers_list.scss",
"chars": 354,
"preview": ".headersList {\n\n}\n\n.headersList__item {\n display:flex;\n font-family:'Droid Sans Mono', fixed;\n font-size:12px;\n just"
},
{
"path": "app/assets/stylesheets/application/components/_inlineError.scss",
"chars": 87,
"preview": ".inlineError {\n background:$red;\n color:#fff;\n padding:15px;\n border-radius:4px;\n}\n"
},
{
"path": "app/assets/stylesheets/application/components/_invoice_list.scss",
"chars": 651,
"preview": ".invoiceList {\n border-radius:4px;\n overflow:hidden;\n box-shadow:0 0 10px rgba(0,0,0,0.2);\n}\n\n.invoiceList__item {\n "
},
{
"path": "app/assets/stylesheets/application/components/_ip_list.scss",
"chars": 688,
"preview": ".ipList {\n border-radius:4px;\n overflow:hidden;\n box-shadow:0 0 10px rgba(0,0,0,0.2);\n}\n\n.ipList__item {\n display:bl"
},
{
"path": "app/assets/stylesheets/application/components/_ip_pool_rule_list.scss",
"chars": 741,
"preview": ".ipPoolRuleList {\n border-radius:4px;\n overflow:hidden;\n box-shadow:0 0 10px rgba(0,0,0,0.2);\n}\n\n.ipPoolRuleList__ite"
},
{
"path": "app/assets/stylesheets/application/components/_large_list.scss",
"chars": 723,
"preview": ".largeList {\n font-size:16px;\n color:$darkBlue;\n border-radius:4px;\n overflow:hidden;\n box-shadow:0 0 10px rgba(0,0"
},
{
"path": "app/assets/stylesheets/application/components/_limit.scss",
"chars": 526,
"preview": ".limits {\n font-size:16px;\n color:$darkBlue;\n border-radius:4px;\n background:#fff;\n overflow:hidden;\n box-shadow:0"
},
{
"path": "app/assets/stylesheets/application/components/_login_form.scss",
"chars": 456,
"preview": ".loginForm {}\n\n\n.loginForm__input {\n margin-bottom: 15px;\n}\n\n.loginForm__submit {\n display: flex;\n justify-content: s"
},
{
"path": "app/assets/stylesheets/application/components/_mail_graph.scss",
"chars": 1120,
"preview": ".mailGraph {\n}\n\n.mailGraph__startTime {\n\n}\n\n.mailGraph__graph {\n min-height:230px;\n margin-bottom:4px;\n .ct-series-a "
},
{
"path": "app/assets/stylesheets/application/components/_message_activity.scss",
"chars": 875,
"preview": ".messageActivity {\n\n}\n\n.messageActivity__event {\n display:flex;\n}\n\n.messageActivity__event + .messageActivity__event {\n"
},
{
"path": "app/assets/stylesheets/application/components/_message_header.scss",
"chars": 760,
"preview": ".messageHeader {\n margin:20px 35px;\n}\n\n.messageHeader__subject {\n font-size:18px;\n font-weight:700;\n margin-bottom:6"
},
{
"path": "app/assets/stylesheets/application/components/_message_list.scss",
"chars": 1309,
"preview": ".messageList {\n box-shadow:0 0 10px rgba(0,0,0,0.15);\n border-radius:4px;\n overflow:hidden;\n}\n\n.messageList__message "
},
{
"path": "app/assets/stylesheets/application/components/_message_properties_page.scss",
"chars": 821,
"preview": ".messagePropertiesPage {\n display:flex;\n justify-content:space-between;\n}\n\n.messagePropertiesPage__left {\n width:45%;"
},
{
"path": "app/assets/stylesheets/application/components/_message_search.scss",
"chars": 1645,
"preview": ".messageSearch {\n margin-bottom:25px;\n position:relative;\n}\n\n.messageSearch__help {\n position:absolute;\n z-index:100"
},
{
"path": "app/assets/stylesheets/application/components/_multibox.scss",
"chars": 210,
"preview": ".multibox {\n display: flex;\n justify-content: space-between;\n margin: 40px 0;\n}\n\n.multibox__input {\n width:80px;\n h"
},
{
"path": "app/assets/stylesheets/application/components/_nav_bar.scss",
"chars": 969,
"preview": ".navBar {\n background:$veryDarkBlue;\n padding:10px 35px;\n color:#fff;\n ul {\n display:flex;\n }\n}\n\n.navBar--second"
},
{
"path": "app/assets/stylesheets/application/components/_new_message_type.scss",
"chars": 502,
"preview": ".newMessageType {\n background-repeat:no-repeat;\n background-size:20px;\n background-position:15px 15px;\n background-c"
},
{
"path": "app/assets/stylesheets/application/components/_no_data.scss",
"chars": 503,
"preview": ".noData {\n text-align:center;\n border-radius:4px;\n padding:30px;\n padding-top:50px;\n box-shadow:0 0 10px rgba(0,0,0"
},
{
"path": "app/assets/stylesheets/application/components/_page_content.scss",
"chars": 1414,
"preview": ".pageContent {\n margin:35px;\n}\n\n.pageContent__intro {\n font-size:20px;\n line-height:30px;\n font-weight:300;\n color:"
},
{
"path": "app/assets/stylesheets/application/components/_page_header.scss",
"chars": 183,
"preview": ".pageHeader {\n background:$darkBlue;\n padding:22px 25px;\n}\n\n.pageHeader__title {\n font-size:26px;\n font-weight:300;\n"
},
{
"path": "app/assets/stylesheets/application/components/_pagination.scss",
"chars": 483,
"preview": "nav.pagination {\n font-size:12px;\n text-align:center;\n margin:25px 0;\n span.page.current, a {\n color:$blue;\n d"
},
{
"path": "app/assets/stylesheets/application/components/_rentention_limits.scss",
"chars": 532,
"preview": ".retentionLimits {\n}\n\n.retentionLimits__limit {\n display:flex;\n align-items: center;\n}\n\n.retentionLimits__limit + .ret"
},
{
"path": "app/assets/stylesheets/application/components/_route_list.scss",
"chars": 1190,
"preview": ".routeList {\n border-radius:4px;\n overflow:hidden;\n box-shadow:0 0 10px rgba(0,0,0,0.2);\n}\n\n.routeList__item {\n back"
},
{
"path": "app/assets/stylesheets/application/components/_route_name_input.scss",
"chars": 204,
"preview": ".routeNameInput {\n display:flex;\n align-items:center;\n}\n\n.routeNameInput__at {\n margin:0 7px;\n font-size:18px;\n col"
},
{
"path": "app/assets/stylesheets/application/components/_server_header.scss",
"chars": 2274,
"preview": ".serverHeader {\n background:$darkBlue;\n padding:25px;\n display:flex;\n color:#fff;\n position:relative;\n}\n\n.serverHea"
},
{
"path": "app/assets/stylesheets/application/components/_sidebar.scss",
"chars": 984,
"preview": ".sidebar {\n width:250px;\n background:#fff;\n flex: 0 0 auto;\n z-index:200;\n box-shadow:5px 0 8px -2px rgba(0,0,0,0.1"
},
{
"path": "app/assets/stylesheets/application/components/_sidebar_server_list.scss",
"chars": 610,
"preview": ".sidebarServerList {\n font-size:12px;\n color:$darkBlue;\n}\n\n.sidebarServerList__item {\n border-bottom:1px solid #e6ebf"
},
{
"path": "app/assets/stylesheets/application/components/_simple_pagination.scss",
"chars": 662,
"preview": ".simplePagination {\n display:flex;\n margin:25px 0;\n justify-content:space-between;\n font-size:12px;\n}\n\n.simplePagina"
},
{
"path": "app/assets/stylesheets/application/components/_site_content.scss",
"chars": 304,
"preview": ".siteContent {\n align-items: stretch;\n display: flex;\n flex: 1 1 auto;\n overflow: hidden;\n}\n\n.siteContent__main {\n "
},
{
"path": "app/assets/stylesheets/application/components/_site_header.scss",
"chars": 2146,
"preview": ".siteHeader {\n width:100%;\n background:$blue;\n flex: 0 0 auto;\n color:#fff;\n z-index:1000;\n}\n\n.siteHeader__inside {"
},
{
"path": "app/assets/stylesheets/application/components/_spam_check_list.scss",
"chars": 1007,
"preview": ".spamCheckList {\n border-radius:4px;\n overflow:hidden;\n box-shadow:0 0 10px rgba(0,0,0,0.2);\n}\n\n.spamCheckList__item "
},
{
"path": "app/assets/stylesheets/application/components/_starter_credit_pack.scss",
"chars": 408,
"preview": ".starterCreditPack {\n border-radius:4px;\n overflow:hidden;\n box-shadow:0 0 10px rgba(0,0,0,0.2);\n background:image-u"
},
{
"path": "app/assets/stylesheets/application/components/_sub_page_box.scss",
"chars": 539,
"preview": ".subPageBox {\n background:#fff;\n border-radius:4px;\n box-shadow:0 0 30px rgba(0,0,0,0.15);\n width:300px;\n margin:au"
},
{
"path": "app/assets/stylesheets/application/components/_suppression_list.scss",
"chars": 634,
"preview": ".suppressionList {\n border-radius:4px;\n overflow:hidden;\n box-shadow:0 0 10px rgba(0,0,0,0.2);\n}\n\n.suppressionList__i"
},
{
"path": "app/assets/stylesheets/application/components/_suspension_box.scss",
"chars": 208,
"preview": ".suspensionBox {\n background:#e2383a;\n border-radius:4px;\n color:#fff;\n line-height:1.5;\n padding:25px;\n font-size"
},
{
"path": "app/assets/stylesheets/application/components/_title_with_links.scss",
"chars": 360,
"preview": ".titleWithLinks {\n display:flex;\n color:$darkBlue;\n align-items:center;\n}\n\n.titleWithLinks__title {\n flex: 1 1 auto;"
},
{
"path": "app/assets/stylesheets/application/components/_user_list.scss",
"chars": 959,
"preview": ".userList {\n border-radius: 4px;\n color: $darkBlue;\n overflow: hidden;\n box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);\n}\n\n"
},
{
"path": "app/assets/stylesheets/application/components/_webhook_list.scss",
"chars": 998,
"preview": ".webhookList {\n border-radius:4px;\n overflow:hidden;\n box-shadow:0 0 10px rgba(0,0,0,0.2);\n}\n\n.webhookList__item {\n "
},
{
"path": "app/assets/stylesheets/application/components/_webhook_request_list.scss",
"chars": 986,
"preview": ".webhookRequestList {\n border-radius:4px;\n overflow:hidden;\n box-shadow:0 0 10px rgba(0,0,0,0.2);\n}\n\n.webhookRequestL"
},
{
"path": "app/assets/stylesheets/application/elements/_bar.scss",
"chars": 236,
"preview": ".bar {\n background:$darkBlue;\n border-radius:10px;\n display:inline-block;\n height:5px;\n width:100%;\n overflow:hidd"
},
{
"path": "app/assets/stylesheets/application/elements/_button.scss",
"chars": 2159,
"preview": ".button {\n display: inline-block;\n font: inherit;\n border-radius: 4px;\n appearance: none;\n background: $blue;\n col"
},
{
"path": "app/assets/stylesheets/application/elements/_code_block.scss",
"chars": 154,
"preview": ".codeBlock {\n background:#909db0;\n color:#fff;\n padding:25px;\n border-radius:4px;\n}\n\n.codeBlock--whitespace {\n whit"
},
{
"path": "app/assets/stylesheets/application/elements/_input.scss",
"chars": 1012,
"preview": ".input {\n border:0;\n padding:0;\n margin:0;\n background:#fff;\n border:1px solid #e4e8ef;\n padding:8px 10px;\n font:"
},
{
"path": "app/assets/stylesheets/application/elements/_label.scss",
"chars": 1940,
"preview": ".label {\n display: inline-block;\n background: #000;\n color: #fff;\n font-size: 9px;\n text-transform: uppercase;\n bo"
},
{
"path": "app/assets/stylesheets/application/elements/_misc.scss",
"chars": 302,
"preview": ".returnPathTag {\n background:image-url('icons/return-path.svg') no-repeat 0 4px / 10px;\n padding-left:14px;\n}\n\n.return"
},
{
"path": "app/assets/stylesheets/application/elements/_spam_range.scss",
"chars": 6894,
"preview": ".spamRangeLabel {\n font-size:12px;\n text-align:right;\n margin-top:7px;\n}\n\n.spamRange {\n -webkit-appearance: none; /*"
},
{
"path": "app/assets/stylesheets/application/global/_fonts.scss",
"chars": 1990,
"preview": "@font-face {\n font-family: \"Droid Sans Mono\";\n src: font-url(\"DroidSansMono.eot\");\n src: font-url(\"DroidSansMono.eot?"
},
{
"path": "app/assets/stylesheets/application/global/_mixins.scss",
"chars": 302,
"preview": "@mixin scrollbars($size: 6px, $thumb: #979ea6, $track: #efefef) {\n &::-webkit-scrollbar {\n height: $size; // Horizon"
},
{
"path": "app/assets/stylesheets/application/global/_reset.scss",
"chars": 2914,
"preview": "html, body, body div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, abbr, address, cite, code, del, "
},
{
"path": "app/assets/stylesheets/application/global/_utility.scss",
"chars": 335,
"preview": ".u-margin {\n margin-bottom:25px;\n}\n\n.u-margin-half {\n margin-bottom:10px;\n}\n\n.u-center {\n text-align:center;\n}\n\n.u-gr"
},
{
"path": "app/assets/stylesheets/application/global/_variables.scss",
"chars": 488,
"preview": "$backgroundGrey: #fafafa;\n$blue: #0e69d5;\n$darkBlue: #3c4249;\n$veryDarkBlue: #2b2e32;\n$lightBlue: #eaf3fe;\n$subBlue: #90"
},
{
"path": "app/assets/stylesheets/application/vendor/_chartist.scss",
"chars": 13771,
"preview": ".ct-label {\n fill: rgba(0, 0, 0, 0.4);\n color: rgba(0, 0, 0, 0.4);\n font-size: 0.75rem;\n line-height: 1; }\n\n.ct-char"
},
{
"path": "app/controllers/address_endpoints_controller.rb",
"chars": 1264,
"preview": "# frozen_string_literal: true\n\nclass AddressEndpointsController < ApplicationController\n\n include WithinOrganization\n\n "
},
{
"path": "app/controllers/application_controller.rb",
"chars": 2862,
"preview": "# frozen_string_literal: true\n\nrequire \"authie/session\"\n\nclass ApplicationController < ActionController::Base\n\n protect"
},
{
"path": "app/controllers/concerns/.keep",
"chars": 0,
"preview": ""
},
{
"path": "app/controllers/concerns/within_organization.rb",
"chars": 413,
"preview": "# frozen_string_literal: true\n\nmodule WithinOrganization\n\n extend ActiveSupport::Concern\n\n included do\n helper_meth"
},
{
"path": "app/controllers/credentials_controller.rb",
"chars": 1067,
"preview": "# frozen_string_literal: true\n\nclass CredentialsController < ApplicationController\n\n include WithinOrganization\n\n befo"
},
{
"path": "app/controllers/domains_controller.rb",
"chars": 3905,
"preview": "# frozen_string_literal: true\n\nclass DomainsController < ApplicationController\n\n include WithinOrganization\n\n before_a"
},
{
"path": "app/controllers/help_controller.rb",
"chars": 280,
"preview": "# frozen_string_literal: true\n\nclass HelpController < ApplicationController\n\n include WithinOrganization\n\n before_acti"
},
{
"path": "app/controllers/http_endpoints_controller.rb",
"chars": 1278,
"preview": "# frozen_string_literal: true\n\nclass HTTPEndpointsController < ApplicationController\n\n include WithinOrganization\n\n be"
},
{
"path": "app/controllers/ip_addresses_controller.rb",
"chars": 923,
"preview": "# frozen_string_literal: true\n\nclass IPAddressesController < ApplicationController\n\n before_action :admin_required\n be"
},
{
"path": "app/controllers/ip_pool_rules_controller.rb",
"chars": 1417,
"preview": "# frozen_string_literal: true\n\nclass IPPoolRulesController < ApplicationController\n\n include WithinOrganization\n\n befo"
},
{
"path": "app/controllers/ip_pools_controller.rb",
"chars": 1163,
"preview": "# frozen_string_literal: true\n\nclass IPPoolsController < ApplicationController\n\n before_action :admin_required\n before"
},
{
"path": "app/controllers/legacy_api/base_controller.rb",
"chars": 4600,
"preview": "# frozen_string_literal: true\n\nmodule LegacyAPI\n # The Legacy API is the Postal v1 API which existed from the start wit"
},
{
"path": "app/controllers/legacy_api/messages_controller.rb",
"chars": 4859,
"preview": "# frozen_string_literal: true\n\nmodule LegacyAPI\n class MessagesController < BaseController\n\n # Returns details about"
},
{
"path": "app/controllers/legacy_api/send_controller.rb",
"chars": 5923,
"preview": "# frozen_string_literal: true\n\nmodule LegacyAPI\n class SendController < BaseController\n\n ERROR_MESSAGES = {\n \"N"
},
{
"path": "app/controllers/messages_controller.rb",
"chars": 8376,
"preview": "# frozen_string_literal: true\n\nclass MessagesController < ApplicationController\n\n include WithinOrganization\n\n before_"
},
{
"path": "app/controllers/organization_ip_pools_controller.rb",
"chars": 453,
"preview": "# frozen_string_literal: true\n\nclass OrganizationIPPoolsController < ApplicationController\n\n include WithinOrganization"
},
{
"path": "app/controllers/organizations_controller.rb",
"chars": 2238,
"preview": "# frozen_string_literal: true\n\nclass OrganizationsController < ApplicationController\n\n before_action :admin_required, o"
},
{
"path": "app/controllers/routes_controller.rb",
"chars": 1069,
"preview": "# frozen_string_literal: true\n\nclass RoutesController < ApplicationController\n\n include WithinOrganization\n\n before_ac"
},
{
"path": "app/controllers/servers_controller.rb",
"chars": 3201,
"preview": "# frozen_string_literal: true\n\nclass ServersController < ApplicationController\n\n include WithinOrganization\n\n before_a"
},
{
"path": "app/controllers/sessions_controller.rb",
"chars": 3206,
"preview": "# frozen_string_literal: true\n\nclass SessionsController < ApplicationController\n\n layout \"sub\"\n\n before_action :requir"
},
{
"path": "app/controllers/smtp_endpoints_controller.rb",
"chars": 1232,
"preview": "# frozen_string_literal: true\n\nclass SMTPEndpointsController < ApplicationController\n\n include WithinOrganization\n bef"
},
{
"path": "app/controllers/track_domains_controller.rb",
"chars": 1829,
"preview": "# frozen_string_literal: true\n\nclass TrackDomainsController < ApplicationController\n\n include WithinOrganization\n befo"
},
{
"path": "app/controllers/user_controller.rb",
"chars": 1851,
"preview": "# frozen_string_literal: true\n\nclass UserController < ApplicationController\n\n skip_before_action :login_required, only:"
},
{
"path": "app/controllers/users_controller.rb",
"chars": 1599,
"preview": "# frozen_string_literal: true\n\nclass UsersController < ApplicationController\n\n before_action :admin_required\n before_a"
},
{
"path": "app/controllers/webhooks_controller.rb",
"chars": 1291,
"preview": "# frozen_string_literal: true\n\nclass WebhooksController < ApplicationController\n\n include WithinOrganization\n before_a"
},
{
"path": "app/controllers/well_known_controller.rb",
"chars": 299,
"preview": "# frozen_string_literal: true\n\nclass WellKnownController < ApplicationController\n\n layout false\n\n skip_before_action :"
},
{
"path": "app/helpers/application_helper.rb",
"chars": 3787,
"preview": "# frozen_string_literal: true\n\nmodule ApplicationHelper\n\n def format_delivery_details(server, text)\n text = h(text)\n"
},
{
"path": "app/lib/dkim_header.rb",
"chars": 3801,
"preview": "# frozen_string_literal: true\n\nclass DKIMHeader\n\n def initialize(domain, message)\n if domain && domain.dkim_status ="
},
{
"path": "app/lib/dns_resolver.rb",
"chars": 4068,
"preview": "# frozen_string_literal: true\n\nrequire \"resolv\"\n\nclass DNSResolver\n\n class LocalResolversUnavailableError < StandardErr"
},
{
"path": "app/lib/message_dequeuer/base.rb",
"chars": 2916,
"preview": "# frozen_string_literal: true\n\nmodule MessageDequeuer\n class Base\n\n class StopProcessing < StandardError\n end\n\n "
},
{
"path": "app/lib/message_dequeuer/incoming_message_processor.rb",
"chars": 7596,
"preview": "# frozen_string_literal: true\n\nmodule MessageDequeuer\n class IncomingMessageProcessor < Base\n\n attr_reader :route\n\n "
},
{
"path": "app/lib/message_dequeuer/initial_processor.rb",
"chars": 2075,
"preview": "# frozen_string_literal: true\n\nmodule MessageDequeuer\n class InitialProcessor < Base\n\n include HasPrometheusMetrics\n"
},
{
"path": "app/lib/message_dequeuer/outgoing_message_processor.rb",
"chars": 7170,
"preview": "# frozen_string_literal: true\n\nmodule MessageDequeuer\n class OutgoingMessageProcessor < Base\n\n def process\n cat"
},
{
"path": "app/lib/message_dequeuer/single_message_processor.rb",
"chars": 2838,
"preview": "# frozen_string_literal: true\n\nmodule MessageDequeuer\n class SingleMessageProcessor < Base\n\n def process\n catch"
},
{
"path": "app/lib/message_dequeuer/state.rb",
"chars": 506,
"preview": "# frozen_string_literal: true\n\nmodule MessageDequeuer\n class State\n\n attr_accessor :send_result\n\n def sender_for("
},
{
"path": "app/lib/message_dequeuer.rb",
"chars": 214,
"preview": "# frozen_string_literal: true\n\nmodule MessageDequeuer\n\n class << self\n\n def process(message, logger:)\n processo"
},
{
"path": "app/lib/query_string.rb",
"chars": 803,
"preview": "# frozen_string_literal: true\n\nclass QueryString\n\n def initialize(string)\n @string = string.strip + \" \"\n end\n\n def"
},
{
"path": "app/lib/received_header.rb",
"chars": 736,
"preview": "# frozen_string_literal: true\n\nclass ReceivedHeader\n\n OUR_HOSTNAMES = {\n smtp: Postal::Config.postal.smtp_hostname,\n"
},
{
"path": "app/lib/reply_separator.rb",
"chars": 850,
"preview": "# frozen_string_literal: true\n\nclass ReplySeparator\n\n RULES = [\n /^-{2,10} $.*/m,\n /^>*\\s*----- ?Original Message"
},
{
"path": "app/lib/smtp_client/endpoint.rb",
"chars": 4967,
"preview": "# frozen_string_literal: true\n\nmodule SMTPClient\n class Endpoint\n\n class SMTPSessionNotStartedError < StandardError\n"
},
{
"path": "app/lib/smtp_client/server.rb",
"chars": 721,
"preview": "# frozen_string_literal: true\n\nmodule SMTPClient\n class Server\n\n attr_reader :hostname\n attr_reader :port\n att"
},
{
"path": "app/lib/smtp_client/ssl_modes.rb",
"chars": 156,
"preview": "# frozen_string_literal: true\n\nmodule SMTPClient\n module SSLModes\n\n AUTO = \"Auto\"\n STARTTLS = \"STARTLS\"\n TLS ="
},
{
"path": "app/lib/smtp_server/client.rb",
"chars": 18728,
"preview": "# frozen_string_literal: true\n\nmodule SMTPServer\n class Client\n\n extend HasPrometheusMetrics\n include HasPromethe"
},
{
"path": "app/lib/smtp_server/server.rb",
"chars": 12210,
"preview": "# frozen_string_literal: true\n\nrequire \"ipaddr\"\nrequire \"nio\"\n\nmodule SMTPServer\n class Server\n\n include HasPromethe"
},
{
"path": "app/lib/worker/jobs/base_job.rb",
"chars": 390,
"preview": "# frozen_string_literal: true\n\nmodule Worker\n module Jobs\n class BaseJob\n\n def initialize(logger:)\n @log"
},
{
"path": "app/lib/worker/jobs/process_queued_messages_job.rb",
"chars": 2121,
"preview": "# frozen_string_literal: true\n\nmodule Worker\n module Jobs\n class ProcessQueuedMessagesJob < BaseJob\n\n def call\n"
},
{
"path": "app/lib/worker/jobs/process_webhook_requests_job.rb",
"chars": 1269,
"preview": "# frozen_string_literal: true\n\nmodule Worker\n module Jobs\n class ProcessWebhookRequestsJob < BaseJob\n\n def call"
},
{
"path": "app/lib/worker/process.rb",
"chars": 10785,
"preview": "# frozen_string_literal: true\n\nmodule Worker\n # The Postal Worker process is responsible for handling all background ta"
},
{
"path": "app/mailers/app_mailer.rb",
"chars": 1151,
"preview": "# frozen_string_literal: true\n\nclass AppMailer < ApplicationMailer\n\n def verify_domain(domain, email_address, user)\n "
},
{
"path": "app/mailers/application_mailer.rb",
"chars": 186,
"preview": "# frozen_string_literal: true\n\nclass ApplicationMailer < ActionMailer::Base\n\n default from: \"#{Postal::Config.smtp.from"
},
{
"path": "app/models/additional_route_endpoint.rb",
"chars": 1874,
"preview": "# frozen_string_literal: true\n\n# == Schema Information\n#\n# Table name: additional_route_endpoints\n#\n# id :in"
},
{
"path": "app/models/address_endpoint.rb",
"chars": 979,
"preview": "# frozen_string_literal: true\n\n# == Schema Information\n#\n# Table name: address_endpoints\n#\n# id :integer "
},
{
"path": "app/models/application_record.rb",
"chars": 166,
"preview": "# frozen_string_literal: true\n\nclass ApplicationRecord < ActiveRecord::Base\n\n self.abstract_class = true\n self.inherit"
},
{
"path": "app/models/bounce_message.rb",
"chars": 1703,
"preview": "# frozen_string_literal: true\n\nclass BounceMessage\n\n def initialize(server, message)\n @server = server\n @message "
},
{
"path": "app/models/concerns/.keep",
"chars": 0,
"preview": ""
},
{
"path": "app/models/concerns/has_authentication.rb",
"chars": 1833,
"preview": "# frozen_string_literal: true\n\nmodule HasAuthentication\n\n extend ActiveSupport::Concern\n\n included do\n has_secure_p"
},
{
"path": "app/models/concerns/has_dns_checks.rb",
"chars": 4302,
"preview": "# frozen_string_literal: true\n\nrequire \"resolv\"\n\nmodule HasDNSChecks\n\n def dns_ok?\n spf_status == \"OK\" && dkim_statu"
},
{
"path": "app/models/concerns/has_locking.rb",
"chars": 1473,
"preview": "# frozen_string_literal: true\n\n# This concern provides functionality for locking items along with additional functionali"
},
{
"path": "app/models/concerns/has_message.rb",
"chars": 1145,
"preview": "# frozen_string_literal: true\n\nmodule HasMessage\n\n def self.included(base)\n base.extend ClassMethods\n end\n\n def me"
},
{
"path": "app/models/concerns/has_soft_destroy.rb",
"chars": 384,
"preview": "# frozen_string_literal: true\n\nmodule HasSoftDestroy\n\n def self.included(base)\n base.define_callbacks :soft_destroy\n"
},
{
"path": "app/models/concerns/has_uuid.rb",
"chars": 199,
"preview": "# frozen_string_literal: true\n\nmodule HasUUID\n\n def self.included(base)\n base.class_eval do\n random_string :uui"
},
{
"path": "app/models/credential.rb",
"chars": 1923,
"preview": "# frozen_string_literal: true\n\n# == Schema Information\n#\n# Table name: credentials\n#\n# id :integer n"
},
{
"path": "app/models/domain.rb",
"chars": 4522,
"preview": "# frozen_string_literal: true\n\n# == Schema Information\n#\n# Table name: domains\n#\n# id :integer "
},
{
"path": "app/models/http_endpoint.rb",
"chars": 1533,
"preview": "# frozen_string_literal: true\n\n# == Schema Information\n#\n# Table name: http_endpoints\n#\n# id :integer "
},
{
"path": "app/models/incoming_message_prototype.rb",
"chars": 2426,
"preview": "# frozen_string_literal: true\n\nclass IncomingMessagePrototype\n\n attr_accessor :to\n attr_accessor :from\n attr_accessor"
},
{
"path": "app/models/ip_address.rb",
"chars": 961,
"preview": "# frozen_string_literal: true\n\n# == Schema Information\n#\n# Table name: ip_addresses\n#\n# id :integer no"
},
{
"path": "app/models/ip_pool.rb",
"chars": 777,
"preview": "# frozen_string_literal: true\n\n# == Schema Information\n#\n# Table name: ip_pools\n#\n# id :integer not nu"
},
{
"path": "app/models/ip_pool_rule.rb",
"chars": 2120,
"preview": "# frozen_string_literal: true\n\n# == Schema Information\n#\n# Table name: ip_pool_rules\n#\n# id :integer n"
},
{
"path": "app/models/organization.rb",
"chars": 2791,
"preview": "# frozen_string_literal: true\n\n# == Schema Information\n#\n# Table name: organizations\n#\n# id :integer "
},
{
"path": "app/models/organization_ip_pool.rb",
"chars": 405,
"preview": "# frozen_string_literal: true\n\n# == Schema Information\n#\n# Table name: organization_ip_pools\n#\n# id :integ"
},
{
"path": "app/models/organization_user.rb",
"chars": 504,
"preview": "# frozen_string_literal: true\n\n# == Schema Information\n#\n# Table name: organization_users\n#\n# id :integer "
},
{
"path": "app/models/outgoing_message_prototype.rb",
"chars": 4988,
"preview": "# frozen_string_literal: true\n\nrequire \"resolv\"\n\nclass OutgoingMessagePrototype\n\n attr_accessor :from\n attr_accessor :"
},
{
"path": "app/models/queued_message.rb",
"chars": 2110,
"preview": "# frozen_string_literal: true\n\n# == Schema Information\n#\n# Table name: queued_messages\n#\n# id :integer "
},
{
"path": "app/models/route.rb",
"chars": 6415,
"preview": "# frozen_string_literal: true\n\n# == Schema Information\n#\n# Table name: routes\n#\n# id :integer not n"
},
{
"path": "app/models/scheduled_task.rb",
"chars": 314,
"preview": "# frozen_string_literal: true\n\n# == Schema Information\n#\n# Table name: scheduled_tasks\n#\n# id :bigint "
},
{
"path": "app/models/server.rb",
"chars": 10338,
"preview": "# frozen_string_literal: true\n\n# == Schema Information\n#\n# Table name: servers\n#\n# id :"
},
{
"path": "app/models/smtp_endpoint.rb",
"chars": 1296,
"preview": "# frozen_string_literal: true\n\n# == Schema Information\n#\n# Table name: smtp_endpoints\n#\n# id :integer "
},
{
"path": "app/models/statistic.rb",
"chars": 392,
"preview": "# frozen_string_literal: true\n\n# == Schema Information\n#\n# Table name: statistics\n#\n# id :integer "
},
{
"path": "app/models/track_domain.rb",
"chars": 2492,
"preview": "# frozen_string_literal: true\n\n# == Schema Information\n#\n# Table name: track_domains\n#\n# id :intege"
},
{
"path": "app/models/user.rb",
"chars": 4049,
"preview": "# frozen_string_literal: true\n\n# == Schema Information\n#\n# Table name: users\n#\n# id :inte"
},
{
"path": "app/models/user_invite.rb",
"chars": 1270,
"preview": "# frozen_string_literal: true\n\n# == Schema Information\n#\n# Table name: user_invites\n#\n# id :integer "
},
{
"path": "app/models/webhook.rb",
"chars": 1436,
"preview": "# frozen_string_literal: true\n\n# == Schema Information\n#\n# Table name: webhooks\n#\n# id :integer not "
},
{
"path": "app/models/webhook_event.rb",
"chars": 571,
"preview": "# frozen_string_literal: true\n\n# == Schema Information\n#\n# Table name: webhook_events\n#\n# id :integer "
},
{
"path": "app/models/webhook_request.rb",
"chars": 1283,
"preview": "# frozen_string_literal: true\n\n# == Schema Information\n#\n# Table name: webhook_requests\n#\n# id :integer "
},
{
"path": "app/models/worker_role.rb",
"chars": 1665,
"preview": "# frozen_string_literal: true\n\n# == Schema Information\n#\n# Table name: worker_roles\n#\n# id :bigint n"
},
{
"path": "app/scheduled_tasks/action_deletions_scheduled_task.rb",
"chars": 418,
"preview": "# frozen_string_literal: true\n\nclass ActionDeletionsScheduledTask < ApplicationScheduledTask\n\n def call\n Organizatio"
},
{
"path": "app/scheduled_tasks/application_scheduled_task.rb",
"chars": 770,
"preview": "# frozen_string_literal: true\n\nclass ApplicationScheduledTask\n\n def initialize(logger:)\n @logger = logger\n end\n\n d"
},
{
"path": "app/scheduled_tasks/check_all_dns_scheduled_task.rb",
"chars": 531,
"preview": "# frozen_string_literal: true\n\nclass CheckAllDNSScheduledTask < ApplicationScheduledTask\n\n def call\n Domain.where.no"
},
{
"path": "app/scheduled_tasks/cleanup_authie_sessions_scheduled_task.rb",
"chars": 176,
"preview": "# frozen_string_literal: true\n\nrequire \"authie/session\"\n\nclass CleanupAuthieSessionsScheduledTask < ApplicationScheduled"
},
{
"path": "app/scheduled_tasks/expire_held_messages_scheduled_task.rb",
"chars": 331,
"preview": "# frozen_string_literal: true\n\nclass ExpireHeldMessagesScheduledTask < ApplicationScheduledTask\n\n def call\n Server.a"
},
{
"path": "app/scheduled_tasks/process_message_retention_scheduled_task.rb",
"chars": 1219,
"preview": "# frozen_string_literal: true\n\nclass ProcessMessageRetentionScheduledTask < ApplicationScheduledTask\n\n def call\n Ser"
},
{
"path": "app/scheduled_tasks/prune_suppression_lists_scheduled_task.rb",
"chars": 310,
"preview": "# frozen_string_literal: true\n\nclass PruneSuppressionListsScheduledTask < ApplicationScheduledTask\n\n def call\n Serve"
},
{
"path": "app/scheduled_tasks/prune_webhook_requests_scheduled_task.rb",
"chars": 312,
"preview": "# frozen_string_literal: true\n\nclass PruneWebhookRequestsScheduledTask < ApplicationScheduledTask\n\n def call\n Server"
},
{
"path": "app/scheduled_tasks/send_notifications_scheduled_task.rb",
"chars": 214,
"preview": "# frozen_string_literal: true\n\nclass SendNotificationsScheduledTask < ApplicationScheduledTask\n\n def call\n Server.se"
},
{
"path": "app/scheduled_tasks/tidy_queued_messages_task.rb",
"chars": 419,
"preview": "# frozen_string_literal: true\n\nclass TidyQueuedMessagesTask < ApplicationScheduledTask\n\n def call\n QueuedMessage.wit"
},
{
"path": "app/senders/base_sender.rb",
"chars": 127,
"preview": "# frozen_string_literal: true\n\nclass BaseSender\n\n def start\n end\n\n def send_message(message)\n end\n\n def finish\n en"
},
{
"path": "app/senders/http_sender.rb",
"chars": 4259,
"preview": "# frozen_string_literal: true\n\nclass HTTPSender < BaseSender\n\n def initialize(endpoint, options = {})\n super()\n @"
},
{
"path": "app/senders/send_result.rb",
"chars": 355,
"preview": "# frozen_string_literal: true\n\nclass SendResult\n\n attr_accessor :type\n attr_accessor :details\n attr_accessor :retry\n "
},
{
"path": "app/senders/smtp_sender.rb",
"chars": 8844,
"preview": "# frozen_string_literal: true\n\nclass SMTPSender < BaseSender\n\n attr_reader :endpoints\n\n # @param domain [String] the d"
},
{
"path": "app/services/webhook_delivery_service.rb",
"chars": 2667,
"preview": "# frozen_string_literal: true\n\nclass WebhookDeliveryService\n\n RETRIES = { 1 => 2.minutes, 2 => 3.minutes, 3 => 6.minute"
},
{
"path": "app/util/has_prometheus_metrics.rb",
"chars": 771,
"preview": "# frozen_string_literal: true\n\nmodule HasPrometheusMetrics\n\n def register_prometheus_counter(name, **kwargs)\n counte"
},
{
"path": "app/util/health_server.rb",
"chars": 2771,
"preview": "# frozen_string_literal: true\n\nrequire \"socket\"\nrequire \"rackup/handler/webrick\"\nrequire \"prometheus/client/formats/text"
},
{
"path": "app/util/user_creator.rb",
"chars": 1025,
"preview": "# frozen_string_literal: true\n\nrequire \"highline\"\n\nmodule UserCreator\n\n class << self\n\n def start(&block)\n cli "
},
{
"path": "app/views/address_endpoints/_form.html.haml",
"chars": 985,
"preview": "= form_for [organization, @server, @address_endpoint], :remote => true do |f|\n = f.error_messages\n %fieldset.fieldSet\n"
},
{
"path": "app/views/address_endpoints/edit.html.haml",
"chars": 333,
"preview": "- page_title << @server.name\n- page_title << \"Routing\"\n- page_title << \"Address Endpoints\"\n- page_title << \"Edit\"\n\n= ren"
}
]
// ... and 325 more files (download for full content)
About this extraction
This page contains the full source code of the postalserver/postal GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 525 files (1.2 MB), approximately 346.2k tokens, and a symbol index with 1300 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.