Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • anatoli/postal
1 result
Show changes
Commits on Source (4)
Loading
Loading
@@ -33,7 +33,7 @@ controller :send do
error 'AttachmentMissingData', "An attachment is missing data"
# Return
returns Hash
# Action
# Action
action do
attributes = {}
attributes[:to] = params.to
Loading
Loading
@@ -87,7 +87,7 @@ controller :send do
error 'UnauthenticatedFromAddress'
end
 
# Store the result ready to return
# Store the result ready to return
result = {:message_id => nil, :messages => {}}
params.rcpt_to.uniq.each do |rcpt_to|
message = identity.server.message_db.new_message
Loading
Loading
Loading
Loading
@@ -66,7 +66,6 @@ class Server < ApplicationRecord
 
random_string :token, :type => :chars, :length => 6, :unique => true, :upper_letters_only => true
default_value :permalink, -> { name ? name.parameterize : nil}
default_value :send_limit, -> { 100 }
default_value :raw_message_retention_days, -> { 30 }
default_value :raw_message_retention_size, -> { 2048 }
default_value :message_retention_days, -> { 60 }
Loading
Loading
@@ -196,11 +195,11 @@ class Server < ApplicationRecord
end
 
def send_limit_approaching?
send_volume >= self.send_limit * 0.90
self.send_limit && (send_volume >= self.send_limit * 0.90)
end
 
def send_limit_exceeded?
send_volume >= self.send_limit
self.send_limit && send_volume >= self.send_limit
end
 
def send_limit_warning(type)
Loading
Loading
Loading
Loading
@@ -11,7 +11,7 @@
%fieldset.fieldSet.fieldSet--wide
.fieldSet__field
= f.label :send_limit, :class => 'fieldSet__label'
.fieldSet__input= f.text_field :send_limit, :autofocus => true, :class => 'input input--text'
.fieldSet__input= f.text_field :send_limit, :class => 'input input--text', :placeholder => "No limit"
.fieldSet__field
= f.label :allow_sender, "Allow sender header", :class => 'fieldSet__label'
.fieldSet__input= f.select :allow_sender, [["No", false], ["Yes - can use Sender header", true]], {}, :class => 'input input--select'
Loading
Loading
Loading
Loading
@@ -14,7 +14,7 @@ module Postal
end
 
def to_hash
@hash ||= @string.scan(/([a-z]+)\:\s*(?:(\d{2,4}\-\d{2}-\d{2}\s\d{2}\:\d{2})|\"(.*?)\"|(.*?))[\s\z]/).each_with_object({}) do |(key, date, string_with_spaces, value), hash|
@hash ||= @string.scan(/([a-z]+)\:\s*(?:(\d{2,4}\-\d{2}-\d{2}\s\d{2}\:\d{2})|\"(.*?)\"|(.*?))(\s|\z)/).each_with_object({}) do |(key, date, string_with_spaces, value), hash|
if date
actual_value = date
elsif string_with_spaces
Loading
Loading
Loading
Loading
@@ -256,7 +256,7 @@ module Postal
uname, domain = rcpt_to.split('@', 2)
uname, tag = uname.split('+', 2)
 
if domain =~ /\A#{Regexp.escape(Postal.config.dns.custom_return_path_prefix)}\./
if domain == Postal.config.dns.return_path || domain =~ /\A#{Regexp.escape(Postal.config.dns.custom_return_path_prefix)}\./
# This is a return path
@state = :rcpt_to_received
if server = ::Server.where(:token => uname).first
Loading
Loading
require 'rails_helper'
describe Postal::QueryString do
it "should work with a single item" do
qs = Postal::QueryString.new("to: test@example.com")
expect(qs.to_hash['to']).to eq 'test@example.com'
end
it "should work with a multiple items" do
qs = Postal::QueryString.new("to: test@example.com from: another@example.com")
expect(qs.to_hash['to']).to eq 'test@example.com'
expect(qs.to_hash['from']).to eq 'another@example.com'
end
it "should not require a space after the field name" do
qs = Postal::QueryString.new("to:test@example.com from:another@example.com")
expect(qs.to_hash['to']).to eq 'test@example.com'
expect(qs.to_hash['from']).to eq 'another@example.com'
end
it "should return nil when it receives blank" do
qs = Postal::QueryString.new("to:[blank]")
expect(qs.to_hash['to']).to eq nil
end
it "should handle dates with spaces" do
qs = Postal::QueryString.new("date: 2017-02-12 15:20")
expect(qs.to_hash['date']).to eq("2017-02-12 15:20")
end
it "should return an array for multiple items" do
qs = Postal::QueryString.new("to: test@example.com to: another@example.com")
expect(qs.to_hash['to']).to be_a(Array)
expect(qs.to_hash['to'][0]).to eq 'test@example.com'
expect(qs.to_hash['to'][1]).to eq 'another@example.com'
end
it "should work with a z in the string" do
qs = Postal::QueryString.new("to: testaz@example.com")
expect(qs.to_hash['to']).to eq "testaz@example.com"
end
end