source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | heartcombo/devise | https://github.com/heartcombo/devise | app/controllers/devise_controller.rb | Ruby | mit | 24,345 | main | 6,982 | # frozen_string_literal: true
# All Devise controllers are inherited from here.
class DeviseController < Devise.parent_controller.constantize
include Devise::Controllers::ScopedViews
if respond_to?(:helper)
helper DeviseHelper
end
if respond_to?(:helper_method)
helpers = %w(resource scope_name resour... |
github | heartcombo/devise | https://github.com/heartcombo/devise | app/controllers/devise/omniauth_callbacks_controller.rb | Ruby | mit | 24,345 | main | 1,235 | # frozen_string_literal: true
class Devise::OmniauthCallbacksController < DeviseController
prepend_before_action { request.env["devise.skip_timeout"] = true }
def passthru
render status: 404, plain: "Not found. Authentication passthru."
end
def failure
set_flash_message! :alert, :failure, kind: OmniA... |
github | heartcombo/devise | https://github.com/heartcombo/devise | app/controllers/devise/sessions_controller.rb | Ruby | mit | 24,345 | main | 2,635 | # frozen_string_literal: true
class Devise::SessionsController < DeviseController
prepend_before_action :require_no_authentication, only: [:new, :create]
prepend_before_action :allow_params_authentication!, only: :create
prepend_before_action :verify_signed_out_user, only: :destroy
prepend_before_action(only: ... |
github | heartcombo/devise | https://github.com/heartcombo/devise | app/controllers/devise/unlocks_controller.rb | Ruby | mit | 24,345 | main | 1,541 | # frozen_string_literal: true
class Devise::UnlocksController < DeviseController
prepend_before_action :require_no_authentication
# GET /resource/unlock/new
def new
self.resource = resource_class.new
end
# POST /resource/unlock
def create
self.resource = resource_class.send_unlock_instructions(re... |
github | heartcombo/devise | https://github.com/heartcombo/devise | app/controllers/devise/passwords_controller.rb | Ruby | mit | 24,345 | main | 2,894 | # frozen_string_literal: true
class Devise::PasswordsController < DeviseController
prepend_before_action :require_no_authentication
# Render the #edit only if coming from a reset password email link
append_before_action :assert_reset_token_passed, only: :edit
# GET /resource/password/new
def new
self.re... |
github | heartcombo/devise | https://github.com/heartcombo/devise | app/controllers/devise/confirmations_controller.rb | Ruby | mit | 24,345 | main | 1,675 | # frozen_string_literal: true
class Devise::ConfirmationsController < DeviseController
# GET /resource/confirmation/new
def new
self.resource = resource_class.new
end
# POST /resource/confirmation
def create
self.resource = resource_class.send_confirmation_instructions(resource_params)
yield res... |
github | heartcombo/devise | https://github.com/heartcombo/devise | app/controllers/devise/registrations_controller.rb | Ruby | mit | 24,345 | main | 5,613 | # frozen_string_literal: true
class Devise::RegistrationsController < DeviseController
prepend_before_action :require_no_authentication, only: [:new, :create, :cancel]
prepend_before_action :authenticate_scope!, only: [:edit, :update, :destroy]
prepend_before_action :set_minimum_password_length, only: [:new, :ed... |
github | heartcombo/devise | https://github.com/heartcombo/devise | app/mailers/devise/mailer.rb | Ruby | mit | 24,345 | main | 804 | # frozen_string_literal: true
if defined?(ActionMailer)
class Devise::Mailer < Devise.parent_mailer.constantize
include Devise::Mailers::Helpers
def confirmation_instructions(record, token, opts = {})
@token = token
devise_mail(record, :confirmation_instructions, opts)
end
def reset_pas... |
github | postalserver/postal | https://github.com/postalserver/postal | Rakefile | Ruby | mit | 16,477 | main | 258 | # 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 |
github | postalserver/postal | https://github.com/postalserver/postal | Gemfile | Ruby | mit | 16,477 | main | 1,280 | # 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 "klo... |
github | postalserver/postal | https://github.com/postalserver/postal | config/application.rb | Ruby | mit | 16,477 | main | 1,309 | # frozen_string_literal: true
require_relative "boot"
require "rails"
require "active_model/railtie"
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "sprockets/railtie"
# Require the gems listed in Gemfile, including any gems
#... |
github | postalserver/postal | https://github.com/postalserver/postal | config/routes.rb | Ruby | mit | 16,477 | main | 3,531 | # frozen_string_literal: true
Rails.application.routes.draw do
# Legacy API Routes
match "/api/v1/send/message" => "legacy_api/send#message", via: [:get, :post, :patch, :put]
match "/api/v1/send/raw" => "legacy_api/send#raw", via: [:get, :post, :patch, :put]
match "/api/v1/messages/message" => "legacy_api/mess... |
github | postalserver/postal | https://github.com/postalserver/postal | config/puma.rb | Ruby | mit | 16,477 | main | 480 | # frozen_string_literal: true
require_relative "../lib/postal/config"
threads_count = Postal::Config.web_server.max_threads
threads threads_count, threads_count
bind_address = ENV.fetch("BIND_ADDRESS", Postal::Config.web_server.default_bind_address)
bind_port = ENV.fetch("PORT", Postal::Config.web_server... |
github | postalserver/postal | https://github.com/postalserver/postal | config/boot.rb | Ruby | mit | 16,477 | main | 270 | # frozen_string_literal: true
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
require "bundler/setup" # Set up gems listed in the Gemfile.
require_relative "../lib/postal/config"
ENV["RAILS_ENV"] = Postal::Config.rails.environment || "development" |
github | postalserver/postal | https://github.com/postalserver/postal | config/initializers/smtp_extensions.rb | Ruby | mit | 16,477 | main | 892 | # frozen_string_literal: true
module Net
class SMTP
attr_accessor :source_address
def secure_socket?
return false unless @socket
@socket.io.is_a?(OpenSSL::SSL::SSLSocket)
end
#
# We had an issue where a message was sent to a server and was greylisted. It returned
# a Net::SMTP... |
github | postalserver/postal | https://github.com/postalserver/postal | config/initializers/assets.rb | Ruby | mit | 16,477 | main | 517 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = "1.0"
# Add additional assets to the asset load path
# Rails.application.config.assets.paths << Emoji.images... |
github | postalserver/postal | https://github.com/postalserver/postal | config/initializers/smtp.rb | Ruby | mit | 16,477 | main | 474 | # frozen_string_literal: true
require "postal/config"
config = Postal::Config.smtp
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
address: config.host,
user_name: config.username,
password: config.password,
port: config.port,
authentication: config.authentication_type&.to_s... |
github | postalserver/postal | https://github.com/postalserver/postal | config/initializers/cookies_serializer.rb | Ruby | mit | 16,477 | main | 275 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Specify a serializer for the signed and encrypted cookie jars.
# Valid options are :json, :marshal, and :hybrid.
Rails.application.config.action_dispatch.cookies_serializer = :json |
github | postalserver/postal | https://github.com/postalserver/postal | config/initializers/trusted_proxies.rb | Ruby | mit | 16,477 | main | 277 | # frozen_string_literal: true
Rack::Request.ip_filter = lambda { |ip|
if Postal::Config.postal.trusted_proxies&.any? { |net| net.include?(ip) } ||
ip.match(/\A127\.0\.0\.1\Z|\A::1\Z|\Afd[0-9a-f]{2}:.+|\Alocalhost\Z|\Aunix\Z|\Aunix:/i)
true
else
false
end
} |
github | postalserver/postal | https://github.com/postalserver/postal | config/initializers/wrap_parameters.rb | Ruby | mit | 16,477 | main | 516 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_con... |
github | postalserver/postal | https://github.com/postalserver/postal | config/initializers/zeitwerk.rb | Ruby | mit | 16,477 | main | 286 | # frozen_string_literal: true
Rails.autoloaders.each do |autoloader|
# Ignore the message DB migrations directory as it doesn't follow
# Zeitwerk's conventions and is always loaded and executed in order.
autoloader.ignore(Rails.root.join("lib/postal/message_db/migrations"))
end |
github | postalserver/postal | https://github.com/postalserver/postal | config/initializers/record_key_for_dom.rb | Ruby | mit | 16,477 | main | 338 | # frozen_string_literal: true
module ActionView
module RecordIdentifier
def dom_id(record, prefix = nil)
if record.new_record?
dom_class(record, prefix || NEW)
else
id = record.respond_to?(:uuid) ? record.uuid : record.id
"#{dom_class(record, prefix)}#{JOIN}#{id}"
end
... |
github | postalserver/postal | https://github.com/postalserver/postal | config/initializers/new_framework_defaults_7_0.rb | Ruby | mit | 16,477 | main | 7,609 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
#
# This file eases your Rails 7.0 framework defaults upgrade.
#
# Uncomment each configuration one by one to switch to the new default.
# Once your application is ready to run with all new defaults, you can remove
# this file and... |
github | postalserver/postal | https://github.com/postalserver/postal | config/initializers/secure_headers.rb | Ruby | mit | 16,477 | main | 273 | # frozen_string_literal: true
SecureHeaders::Configuration.default do |config|
config.hsts = SecureHeaders::OPT_OUT
config.csp[:default_src] = []
config.csp[:script_src] = ["'self'"]
config.csp[:child_src] = ["'self'"]
config.csp[:connect_src] = ["'self'"]
end |
github | postalserver/postal | https://github.com/postalserver/postal | config/initializers/omniauth.rb | Ruby | mit | 16,477 | main | 1,097 | # frozen_string_literal: true
config = Postal::Config.oidc
if config.enabled?
client_options = { identifier: config.identifier, secret: config.secret }
client_options[:redirect_uri] = "#{Postal::Config.postal.web_protocol}://#{Postal::Config.postal.web_hostname}/auth/oidc/callback"
unless config.discovery?
... |
github | postalserver/postal | https://github.com/postalserver/postal | config/initializers/secret_key.rb | Ruby | mit | 16,477 | main | 325 | # frozen_string_literal: true
if Postal::Config.rails.secret_key
Rails.application.credentials.secret_key_base = Postal::Config.rails.secret_key
else
warn "No secret key was specified in the Postal config file. Using one for just this session"
Rails.application.credentials.secret_key_base = SecureRandom.hex(128)... |
github | postalserver/postal | https://github.com/postalserver/postal | config/initializers/backtrace_silencers.rb | Ruby | mit | 16,477 | main | 434 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if ... |
github | postalserver/postal | https://github.com/postalserver/postal | config/initializers/logging.rb | Ruby | mit | 16,477 | main | 1,729 | # frozen_string_literal: true
begin
def add_exception_to_payload(payload, event)
return unless exception = event.payload[:exception_object]
payload[:exception_class] = exception.class.name
payload[:exception_message] = exception.message
payload[:exception_backtrace] = exception.backtrace[0, 4].join(... |
github | postalserver/postal | https://github.com/postalserver/postal | config/initializers/content_security_policy.rb | Ruby | mit | 16,477 | main | 1,074 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Define an application-wide content security policy.
# See the Securing Rails Applications Guide for more information:
# https://guides.rubyonrails.org/security.html#content-security-policy-header
# Rails.application.configure ... |
github | postalserver/postal | https://github.com/postalserver/postal | config/initializers/inflections.rb | Ruby | mit | 16,477 | main | 961 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflec... |
github | postalserver/postal | https://github.com/postalserver/postal | config/initializers/filter_parameter_logging.rb | Ruby | mit | 16,477 | main | 428 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Configure parameters to be filtered from the log file. Use this to limit dissemination of
# sensitive information. See the ActiveSupport::ParameterFilter documentation for supported
# notations and behaviors.
Rails.application... |
github | postalserver/postal | https://github.com/postalserver/postal | config/initializers/permissions_policy.rb | Ruby | mit | 16,477 | main | 414 | # frozen_string_literal: true
# Define an application-wide HTTP permissions policy. For further
# information see https://developers.google.com/web/updates/2018/06/feature-policy
#
# Rails.application.config.permissions_policy do |f|
# f.camera :none
# f.gyroscope :none
# f.microphone :none
# f.usb ... |
github | postalserver/postal | https://github.com/postalserver/postal | config/initializers/mail_extensions.rb | Ruby | mit | 16,477 | main | 3,519 | # frozen_string_literal: true
require "mail"
module Mail
module Encodings
# Handle windows-1258 as windows-1252 when decoding
def self.q_value_decode(str)
str = str.sub(/=\?windows-?1258\?/i, '\=?windows-1252?')
Utilities.q_value_decode(str)
end
def self.b_value_decode(str)
str =... |
github | postalserver/postal | https://github.com/postalserver/postal | config/environments/test.rb | Ruby | mit | 16,477 | main | 1,783 | # frozen_string_literal: true
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "s... |
github | postalserver/postal | https://github.com/postalserver/postal | config/environments/production.rb | Ruby | mit | 16,477 | main | 3,112 | # frozen_string_literal: true
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.enable_reloading = false
# Eager load code on boot. This eager loads most of Rails and
# your application in memor... |
github | postalserver/postal | https://github.com/postalserver/postal | config/environments/development.rb | Ruby | mit | 16,477 | main | 1,917 | # frozen_string_literal: true
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don... |
github | postalserver/postal | https://github.com/postalserver/postal | app/senders/http_sender.rb | Ruby | mit | 16,477 | main | 4,259 | # frozen_string_literal: true
class HTTPSender < BaseSender
def initialize(endpoint, options = {})
super()
@endpoint = endpoint
@options = options
@log_id = SecureRandom.alphanumeric(8).upcase
end
def send_message(message)
start_time = Time.now
result = SendResult.new
result.log_id ... |
github | postalserver/postal | https://github.com/postalserver/postal | app/senders/smtp_sender.rb | Ruby | mit | 16,477 | main | 8,844 | # frozen_string_literal: true
class SMTPSender < BaseSender
attr_reader :endpoints
# @param domain [String] the domain to send mesages to
# @param source_ip_address [IPAddress] the IP address to send messages from
# @param log_id [String] an ID to use when logging requests
def initialize(domain, source_ip_... |
github | postalserver/postal | https://github.com/postalserver/postal | app/senders/send_result.rb | Ruby | mit | 16,477 | main | 355 | # frozen_string_literal: true
class SendResult
attr_accessor :type
attr_accessor :details
attr_accessor :retry
attr_accessor :output
attr_accessor :secure
attr_accessor :connect_error
attr_accessor :log_id
attr_accessor :time
attr_accessor :suppress_bounce
def initialize
@details = ""
yie... |
github | postalserver/postal | https://github.com/postalserver/postal | app/mailers/app_mailer.rb | Ruby | mit | 16,477 | main | 1,151 | # frozen_string_literal: true
class AppMailer < ApplicationMailer
def verify_domain(domain, email_address, user)
@domain = domain
@email_address = email_address
@user = user
mail to: email_address, subject: "Verify your ownership of #{@domain.name}"
end
def password_reset(user, return_to = nil)... |
github | postalserver/postal | https://github.com/postalserver/postal | app/lib/received_header.rb | Ruby | mit | 16,477 | main | 736 | # frozen_string_literal: true
class ReceivedHeader
OUR_HOSTNAMES = {
smtp: Postal::Config.postal.smtp_hostname,
http: Postal::Config.postal.web_hostname
}.freeze
class << self
def generate(server, helo, ip_address, method)
our_hostname = OUR_HOSTNAMES[method]
if our_hostname.nil?
... |
github | postalserver/postal | https://github.com/postalserver/postal | app/lib/dns_resolver.rb | Ruby | mit | 16,477 | main | 4,068 | # frozen_string_literal: true
require "resolv"
class DNSResolver
class LocalResolversUnavailableError < StandardError
end
attr_reader :nameservers
attr_reader :timeout
def initialize(nameservers)
@nameservers = nameservers
end
# Return all A records for the given name
#
# @param [String] nam... |
github | postalserver/postal | https://github.com/postalserver/postal | app/lib/message_dequeuer.rb | Ruby | mit | 16,477 | main | 214 | # frozen_string_literal: true
module MessageDequeuer
class << self
def process(message, logger:)
processor = InitialProcessor.new(message, logger: logger)
processor.process
end
end
end |
github | postalserver/postal | https://github.com/postalserver/postal | app/lib/dkim_header.rb | Ruby | mit | 16,477 | main | 3,801 | # frozen_string_literal: true
class DKIMHeader
def initialize(domain, message)
if domain && domain.dkim_status == "OK"
@domain_name = domain.name
@dkim_key = domain.dkim_key
@dkim_identifier = domain.dkim_identifier
else
@domain_name = Postal::Config.dns.return_path_domain
@dki... |
github | postalserver/postal | https://github.com/postalserver/postal | app/lib/query_string.rb | Ruby | mit | 16,477 | main | 803 | # frozen_string_literal: true
class QueryString
def initialize(string)
@string = string.strip + " "
end
def [](value)
hash[value.to_s]
end
delegate :empty?, to: :hash
def hash
@hash ||= @string.scan(/([a-z]+):\s*(?:(\d{2,4}-\d{2}-\d{2}\s\d{2}:\d{2})|"(.*?)"|(.*?))(\s|\z)/).each_with_object(... |
github | postalserver/postal | https://github.com/postalserver/postal | app/lib/reply_separator.rb | Ruby | mit | 16,477 | main | 850 | # frozen_string_literal: true
class ReplySeparator
RULES = [
/^-{2,10} $.*/m,
/^>*\s*----- ?Original Message ?-----.*/m,
/^>*\s*From:[^\r\n]*[\r\n]+Sent:.*/m,
/^>*\s*From:[^\r\n]*[\r\n]+Date:.*/m,
/^>*\s*-----Urspr.ngliche Nachricht----- .*/m,
/^>*\s*Le[^\r\n]{10,200}a .crit ?:\s*$.*/,
/... |
github | postalserver/postal | https://github.com/postalserver/postal | app/lib/smtp_server/server.rb | Ruby | mit | 16,477 | main | 12,210 | # frozen_string_literal: true
require "ipaddr"
require "nio"
module SMTPServer
class Server
include HasPrometheusMetrics
class << self
def tls_private_key
@tls_private_key ||= OpenSSL::PKey.read(File.read(Postal::Config.smtp_server.tls_private_key_path))
end
def tls_certificate... |
github | postalserver/postal | https://github.com/postalserver/postal | app/lib/smtp_server/client.rb | Ruby | mit | 16,477 | main | 18,728 | # frozen_string_literal: true
module SMTPServer
class Client
extend HasPrometheusMetrics
include HasPrometheusMetrics
CRAM_MD5_DIGEST = OpenSSL::Digest.new("md5")
LOG_REDACTION_STRING = "[redacted]"
attr_reader :logging_enabled
attr_reader :credential
attr_reader :ip_address
attr_r... |
github | postalserver/postal | https://github.com/postalserver/postal | app/lib/worker/process.rb | Ruby | mit | 16,477 | main | 10,785 | # frozen_string_literal: true
module Worker
# The Postal Worker process is responsible for handling all background tasks. This includes processing of all
# messages, webhooks and other administrative tasks. There are two main types of background work which is completed,
# jobs and scheduled tasks.
#
# The 'J... |
github | postalserver/postal | https://github.com/postalserver/postal | app/lib/worker/jobs/process_queued_messages_job.rb | Ruby | mit | 16,477 | main | 2,121 | # frozen_string_literal: true
module Worker
module Jobs
class ProcessQueuedMessagesJob < BaseJob
def call
@lock_time = Time.current
@locker = Postal.locker_name_with_suffix(SecureRandom.hex(8))
find_ip_addresses
lock_message_for_processing
obtain_locked_messages
... |
github | postalserver/postal | https://github.com/postalserver/postal | app/lib/worker/jobs/base_job.rb | Ruby | mit | 16,477 | main | 390 | # frozen_string_literal: true
module Worker
module Jobs
class BaseJob
def initialize(logger:)
@logger = logger
end
def call
# Override me.
end
def work_completed?
@work_completed == true
end
private
def work_completed!
@work_com... |
github | postalserver/postal | https://github.com/postalserver/postal | app/lib/worker/jobs/process_webhook_requests_job.rb | Ruby | mit | 16,477 | main | 1,269 | # frozen_string_literal: true
module Worker
module Jobs
class ProcessWebhookRequestsJob < BaseJob
def call
@lock_time = Time.current
@locker = Postal.locker_name_with_suffix(SecureRandom.hex(8))
lock_request_for_processing
obtain_locked_requests
process_requests
... |
github | postalserver/postal | https://github.com/postalserver/postal | app/lib/smtp_client/endpoint.rb | Ruby | mit | 16,477 | main | 4,967 | # frozen_string_literal: true
module SMTPClient
class Endpoint
class SMTPSessionNotStartedError < StandardError
end
attr_reader :server
attr_reader :ip_address
attr_accessor :smtp_client
# @param server [Server] the server that this IP address is for
# @param ip_address [String] the IP... |
github | postalserver/postal | https://github.com/postalserver/postal | app/lib/smtp_client/server.rb | Ruby | mit | 16,477 | main | 721 | # frozen_string_literal: true
module SMTPClient
class Server
attr_reader :hostname
attr_reader :port
attr_accessor :ssl_mode
def initialize(hostname, port: 25, ssl_mode: SSLModes::AUTO)
@hostname = hostname
@port = port
@ssl_mode = ssl_mode
end
# Return all IP addresses f... |
github | postalserver/postal | https://github.com/postalserver/postal | app/lib/message_dequeuer/state.rb | Ruby | mit | 16,477 | main | 506 | # frozen_string_literal: true
module MessageDequeuer
class State
attr_accessor :send_result
def sender_for(klass, *args, **kwargs)
@cached_senders ||= {}
@cached_senders[[klass, args, kwargs]] ||= begin
klass_instance = klass.new(*args, **kwargs)
klass_instance.start
kla... |
github | postalserver/postal | https://github.com/postalserver/postal | app/lib/message_dequeuer/base.rb | Ruby | mit | 16,477 | main | 2,916 | # frozen_string_literal: true
module MessageDequeuer
class Base
class StopProcessing < StandardError
end
attr_reader :queued_message
attr_reader :logger
attr_reader :state
def initialize(queued_message, logger:, state: nil)
@queued_message = queued_message
@logger = logger
... |
github | postalserver/postal | https://github.com/postalserver/postal | app/lib/message_dequeuer/outgoing_message_processor.rb | Ruby | mit | 16,477 | main | 7,170 | # frozen_string_literal: true
module MessageDequeuer
class OutgoingMessageProcessor < Base
def process
catch_stops do
check_domain
check_rcpt_to
add_tag
hold_if_credential_is_set_to_hold
hold_if_recipient_on_suppression_list
parse_content
inspect_mes... |
github | postalserver/postal | https://github.com/postalserver/postal | app/lib/message_dequeuer/incoming_message_processor.rb | Ruby | mit | 16,477 | main | 7,596 | # frozen_string_literal: true
module MessageDequeuer
class IncomingMessageProcessor < Base
attr_reader :route
def process
log "message is incoming"
catch_stops do
handle_bounces
increment_live_stats
inspect_message
fail_if_spam
hold_if_server_development... |
github | postalserver/postal | https://github.com/postalserver/postal | app/lib/message_dequeuer/single_message_processor.rb | Ruby | mit | 16,477 | main | 2,838 | # frozen_string_literal: true
module MessageDequeuer
class SingleMessageProcessor < Base
def process
catch_stops do
check_message_exists
check_server_suspension
check_delivery_attempts
check_raw_message_exists
processor = nil
case queued_message.message.sco... |
github | postalserver/postal | https://github.com/postalserver/postal | app/lib/message_dequeuer/initial_processor.rb | Ruby | mit | 16,477 | main | 2,075 | # frozen_string_literal: true
module MessageDequeuer
class InitialProcessor < Base
include HasPrometheusMetrics
attr_accessor :send_result
def process
logger.tagged(original_queued_message: @queued_message.id) do
logger.info "starting message unqueue"
begin
catch_stops ... |
github | postalserver/postal | https://github.com/postalserver/postal | app/services/webhook_delivery_service.rb | Ruby | mit | 16,477 | main | 2,667 | # frozen_string_literal: true
class WebhookDeliveryService
RETRIES = { 1 => 2.minutes, 2 => 3.minutes, 3 => 6.minutes, 4 => 10.minutes, 5 => 15.minutes }.freeze
def initialize(webhook_request:)
@webhook_request = webhook_request
end
def call
logger.tagged(webhook: @webhook_request.webhook_id, webhoo... |
github | postalserver/postal | https://github.com/postalserver/postal | app/scheduled_tasks/prune_webhook_requests_scheduled_task.rb | Ruby | mit | 16,477 | main | 312 | # frozen_string_literal: true
class PruneWebhookRequestsScheduledTask < ApplicationScheduledTask
def call
Server.all.each do |s|
logger.info "Pruning webhook requests for server #{s.id}"
s.message_db.webhooks.prune
end
end
def self.next_run_after
quarter_to_each_hour
end
end |
github | postalserver/postal | https://github.com/postalserver/postal | app/scheduled_tasks/prune_suppression_lists_scheduled_task.rb | Ruby | mit | 16,477 | main | 310 | # frozen_string_literal: true
class PruneSuppressionListsScheduledTask < ApplicationScheduledTask
def call
Server.all.each do |s|
logger.info "Pruning suppression lists for server #{s.id}"
s.message_db.suppression_list.prune
end
end
def self.next_run_after
three_am
end
end |
github | postalserver/postal | https://github.com/postalserver/postal | app/scheduled_tasks/action_deletions_scheduled_task.rb | Ruby | mit | 16,477 | main | 418 | # frozen_string_literal: true
class ActionDeletionsScheduledTask < ApplicationScheduledTask
def call
Organization.deleted.each do |org|
logger.info "permanently removing organization #{org.id} (#{org.permalink})"
org.destroy
end
Server.deleted.each do |server|
logger.info "permanently... |
github | postalserver/postal | https://github.com/postalserver/postal | app/scheduled_tasks/expire_held_messages_scheduled_task.rb | Ruby | mit | 16,477 | main | 331 | # frozen_string_literal: true
class ExpireHeldMessagesScheduledTask < ApplicationScheduledTask
def call
Server.all.each do |server|
messages = server.message_db.messages(where: {
status: "Held",
hold_expiry: { less_than: Time.now.to_f }
})
messages.each(&:cancel_hold)
end
... |
github | postalserver/postal | https://github.com/postalserver/postal | app/scheduled_tasks/send_notifications_scheduled_task.rb | Ruby | mit | 16,477 | main | 214 | # frozen_string_literal: true
class SendNotificationsScheduledTask < ApplicationScheduledTask
def call
Server.send_send_limit_notifications
end
def self.next_run_after
1.minute.from_now
end
end |
github | postalserver/postal | https://github.com/postalserver/postal | app/scheduled_tasks/tidy_queued_messages_task.rb | Ruby | mit | 16,477 | main | 419 | # frozen_string_literal: true
class TidyQueuedMessagesTask < ApplicationScheduledTask
def call
QueuedMessage.with_stale_lock.in_batches do |messages|
messages.each do |message|
logger.info "removing queued message #{message.id} (locked at #{message.locked_at} by #{message.locked_by})"
mess... |
github | postalserver/postal | https://github.com/postalserver/postal | app/scheduled_tasks/application_scheduled_task.rb | Ruby | mit | 16,477 | main | 770 | # frozen_string_literal: true
class ApplicationScheduledTask
def initialize(logger:)
@logger = logger
end
def call
raise NotImplementedError
end
attr_reader :logger
class << self
def next_run_after
quarter_past_each_hour
end
private
def quarter_past_each_hour
time... |
github | postalserver/postal | https://github.com/postalserver/postal | app/scheduled_tasks/process_message_retention_scheduled_task.rb | Ruby | mit | 16,477 | main | 1,219 | # frozen_string_literal: true
class ProcessMessageRetentionScheduledTask < ApplicationScheduledTask
def call
Server.all.each do |server|
if server.raw_message_retention_days
# If the server has a maximum number of retained raw messages, remove any that are older than this
logger.info "Tidy... |
github | postalserver/postal | https://github.com/postalserver/postal | app/scheduled_tasks/check_all_dns_scheduled_task.rb | Ruby | mit | 16,477 | main | 531 | # frozen_string_literal: true
class CheckAllDNSScheduledTask < ApplicationScheduledTask
def call
Domain.where.not(dns_checked_at: nil).where("dns_checked_at <= ?", 1.hour.ago).each do |domain|
logger.info "checking DNS for domain: #{domain.name}"
domain.check_dns(:auto)
end
TrackDomain.wher... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/webhook_event.rb | Ruby | mit | 16,477 | main | 571 | # frozen_string_literal: true
# == Schema Information
#
# Table name: webhook_events
#
# id :integer not null, primary key
# webhook_id :integer
# event :string(255)
# created_at :datetime
#
# Indexes
#
# index_webhook_events_on_webhook_id (webhook_id)
#
class WebhookEvent < ApplicationRec... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/user_invite.rb | Ruby | mit | 16,477 | main | 1,270 | # frozen_string_literal: true
# == Schema Information
#
# Table name: user_invites
#
# id :integer not null, primary key
# uuid :string(255)
# email_address :string(255)
# expires_at :datetime
# created_at :datetime
# updated_at :datetime
#
# Indexes
#
# index_user_invites_... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/organization_ip_pool.rb | Ruby | mit | 16,477 | main | 405 | # frozen_string_literal: true
# == Schema Information
#
# Table name: organization_ip_pools
#
# id :integer not null, primary key
# organization_id :integer
# ip_pool_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
class Organizat... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/organization.rb | Ruby | mit | 16,477 | main | 2,791 | # frozen_string_literal: true
# == Schema Information
#
# Table name: organizations
#
# id :integer not null, primary key
# uuid :string(255)
# name :string(255)
# permalink :string(255)
# time_zone :string(255)
# created_at :datetime
# up... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/bounce_message.rb | Ruby | mit | 16,477 | main | 1,703 | # frozen_string_literal: true
class BounceMessage
def initialize(server, message)
@server = server
@message = message
end
def raw_message
mail = Mail.new
mail.to = @message.mail_from
mail.from = "Mail Delivery Service <#{@message.route.description}>"
mail.subject = "Mail Delivery Failed... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/ip_pool_rule.rb | Ruby | mit | 16,477 | main | 2,120 | # frozen_string_literal: true
# == Schema Information
#
# Table name: ip_pool_rules
#
# id :integer not null, primary key
# uuid :string(255)
# owner_type :string(255)
# owner_id :integer
# ip_pool_id :integer
# from_text :text(65535)
# to_text :text(65535)
# created_at :datetime ... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/address_endpoint.rb | Ruby | mit | 16,477 | main | 979 | # frozen_string_literal: true
# == Schema Information
#
# Table name: address_endpoints
#
# id :integer not null, primary key
# server_id :integer
# uuid :string(255)
# address :string(255)
# last_used_at :datetime
# created_at :datetime not null
# updated_at :date... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/statistic.rb | Ruby | mit | 16,477 | main | 392 | # frozen_string_literal: true
# == Schema Information
#
# Table name: statistics
#
# id :integer not null, primary key
# total_incoming :bigint default(0)
# total_messages :bigint default(0)
# total_outgoing :bigint default(0)
#
class Statistic < ApplicationRecor... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/webhook_request.rb | Ruby | mit | 16,477 | main | 1,283 | # frozen_string_literal: true
# == Schema Information
#
# Table name: webhook_requests
#
# id :integer not null, primary key
# attempts :integer default(0)
# error :text(65535)
# event :string(255)
# locked_at :datetime
# locked_by :string(255)
# payload :text(6... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/ip_address.rb | Ruby | mit | 16,477 | main | 961 | # frozen_string_literal: true
# == Schema Information
#
# Table name: ip_addresses
#
# id :integer not null, primary key
# ip_pool_id :integer
# ipv4 :string(255)
# ipv6 :string(255)
# created_at :datetime
# updated_at :datetime
# hostname :string(255)
# priority :integer
#
cl... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/queued_message.rb | Ruby | mit | 16,477 | main | 2,110 | # frozen_string_literal: true
# == Schema Information
#
# Table name: queued_messages
#
# id :integer not null, primary key
# server_id :integer
# message_id :integer
# domain :string(255)
# locked_by :string(255)
# locked_at :datetime
# retry_after :datetime
# creat... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/webhook.rb | Ruby | mit | 16,477 | main | 1,436 | # frozen_string_literal: true
# == Schema Information
#
# Table name: webhooks
#
# id :integer not null, primary key
# server_id :integer
# uuid :string(255)
# name :string(255)
# url :string(255)
# last_used_at :datetime
# all_events :boolean default(FA... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/organization_user.rb | Ruby | mit | 16,477 | main | 504 | # frozen_string_literal: true
# == Schema Information
#
# Table name: organization_users
#
# id :integer not null, primary key
# organization_id :integer
# user_id :integer
# created_at :datetime
# admin :boolean default(FALSE)
# all_servers :boolean ... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/smtp_endpoint.rb | Ruby | mit | 16,477 | main | 1,296 | # frozen_string_literal: true
# == Schema Information
#
# Table name: smtp_endpoints
#
# id :integer not null, primary key
# server_id :integer
# uuid :string(255)
# name :string(255)
# hostname :string(255)
# ssl_mode :string(255)
# port :inte... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/domain.rb | Ruby | mit | 16,477 | main | 4,522 | # frozen_string_literal: true
# == Schema Information
#
# Table name: domains
#
# id :integer not null, primary key
# server_id :integer
# uuid :string(255)
# name :string(255)
# verification_token :string(255)
# verification_metho... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/credential.rb | Ruby | mit | 16,477 | main | 1,923 | # frozen_string_literal: true
# == Schema Information
#
# Table name: credentials
#
# id :integer not null, primary key
# server_id :integer
# key :string(255)
# type :string(255)
# name :string(255)
# options :text(65535)
# last_used_at :datetime
# created_a... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/user.rb | Ruby | mit | 16,477 | main | 4,049 | # frozen_string_literal: true
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# admin :boolean default(FALSE)
# email_address :string(255)
# email_verification_token :string(255... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/route.rb | Ruby | mit | 16,477 | main | 6,415 | # frozen_string_literal: true
# == Schema Information
#
# Table name: routes
#
# id :integer not null, primary key
# uuid :string(255)
# server_id :integer
# domain_id :integer
# endpoint_id :integer
# endpoint_type :string(255)
# name :string(255)
# spam_mode ... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/track_domain.rb | Ruby | mit | 16,477 | main | 2,492 | # frozen_string_literal: true
# == Schema Information
#
# Table name: track_domains
#
# id :integer not null, primary key
# uuid :string(255)
# server_id :integer
# domain_id :integer
# name :string(255)
# dns_checked_at ... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/incoming_message_prototype.rb | Ruby | mit | 16,477 | main | 2,426 | # frozen_string_literal: true
class IncomingMessagePrototype
attr_accessor :to
attr_accessor :from
attr_accessor :route_id
attr_accessor :subject
attr_accessor :plain_body
attr_accessor :attachments
def initialize(server, ip, source_type, attributes)
@server = server
@ip = ip
@source_type =... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/ip_pool.rb | Ruby | mit | 16,477 | main | 777 | # frozen_string_literal: true
# == Schema Information
#
# Table name: ip_pools
#
# id :integer not null, primary key
# name :string(255)
# uuid :string(255)
# created_at :datetime
# updated_at :datetime
# default :boolean default(FALSE)
#
# Indexes
#
# index_ip_pools_on_... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/scheduled_task.rb | Ruby | mit | 16,477 | main | 314 | # frozen_string_literal: true
# == Schema Information
#
# Table name: scheduled_tasks
#
# id :bigint not null, primary key
# name :string(255)
# next_run_after :datetime
#
# Indexes
#
# index_scheduled_tasks_on_name (name) UNIQUE
#
class ScheduledTask < ApplicationRecord
end |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/http_endpoint.rb | Ruby | mit | 16,477 | main | 1,533 | # frozen_string_literal: true
# == Schema Information
#
# Table name: http_endpoints
#
# id :integer not null, primary key
# server_id :integer
# uuid :string(255)
# name :string(255)
# url :string(255)
# encoding :strin... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/additional_route_endpoint.rb | Ruby | mit | 16,477 | main | 1,874 | # frozen_string_literal: true
# == Schema Information
#
# Table name: additional_route_endpoints
#
# id :integer not null, primary key
# route_id :integer
# endpoint_type :string(255)
# endpoint_id :integer
# created_at :datetime not null
# updated_at :datetime no... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/worker_role.rb | Ruby | mit | 16,477 | main | 1,665 | # frozen_string_literal: true
# == Schema Information
#
# Table name: worker_roles
#
# id :bigint not null, primary key
# acquired_at :datetime
# role :string(255)
# worker :string(255)
#
# Indexes
#
# index_worker_roles_on_role (role) UNIQUE
#
class WorkerRole < ApplicationRecord
... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/server.rb | Ruby | mit | 16,477 | main | 10,338 | # frozen_string_literal: true
# == Schema Information
#
# Table name: servers
#
# id :integer not null, primary key
# allow_sender :boolean default(FALSE)
# deleted_at :datetime
# domains_not_to_click_track :tex... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/outgoing_message_prototype.rb | Ruby | mit | 16,477 | main | 4,988 | # frozen_string_literal: true
require "resolv"
class OutgoingMessagePrototype
attr_accessor :from
attr_accessor :sender
attr_accessor :to
attr_accessor :cc
attr_accessor :bcc
attr_accessor :subject
attr_accessor :reply_to
attr_accessor :custom_headers
attr_accessor :plain_body
attr_accessor :html... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/concerns/has_message.rb | Ruby | mit | 16,477 | main | 1,145 | # frozen_string_literal: true
module HasMessage
def self.included(base)
base.extend ClassMethods
end
def message
return @message if instance_variable_defined?("@message")
@message = server.message_db.message(message_id)
rescue Postal::MessageDB::Message::NotFound
@message = nil
end
def ... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/concerns/has_locking.rb | Ruby | mit | 16,477 | main | 1,473 | # frozen_string_literal: true
# This concern provides functionality for locking items along with additional functionality to handle
# the concept of retrying items after a certain period of time. The following database columns are
# required on the model
#
# * locked_by - A string column to store the name of the proce... |
github | postalserver/postal | https://github.com/postalserver/postal | app/models/concerns/has_dns_checks.rb | Ruby | mit | 16,477 | main | 4,302 | # frozen_string_literal: true
require "resolv"
module HasDNSChecks
def dns_ok?
spf_status == "OK" && dkim_status == "OK" && %w[OK Missing].include?(mx_status) && %w[OK Missing].include?(return_path_status)
end
def dns_checked?
spf_status.present?
end
def check_dns(source = :manual)
check_spf_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.