ispmail-on-rails 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/virtual_alias.rb +2 -2
- data/app/validators/alias_validator.rb +6 -4
- data/lib/ispmail/on/rails/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8345a509dd8e2149a30780a79ba40a60061a1668
|
4
|
+
data.tar.gz: 88f2515e20acb051baf91fdbfbd8d9b195809c4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fedb1a4435987c5c2230d7837a9fb37f6dab9384acbeb9c4e6a4e24fee0bb09b69d643e34008106dfbecb6a4a3f7659387966d99d6d5bc57c6d46f939a23bfe
|
7
|
+
data.tar.gz: 74fc26fac57282d7f77c30a5270607bfc706bbe9b0ca9482db2a32533836eb998d7fa0b1a7a8cdc05e495415e58c65a2164c91448ff5eeb098b9b22a74724767
|
data/app/models/virtual_alias.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class VirtualAlias < ActiveRecord::Base
|
2
2
|
validates :source, presence: true, domain_name: true, email: true
|
3
|
-
validates :destination, presence: true, alias: true
|
3
|
+
validates :destination, presence: true, alias: true
|
4
4
|
validates :domain_id, presence: true
|
5
5
|
|
6
6
|
belongs_to :virtual_domain, foreign_key: :domain_id
|
@@ -14,7 +14,7 @@ class VirtualAlias < ActiveRecord::Base
|
|
14
14
|
def complete_emails
|
15
15
|
self.source += "@#{virtual_domain.name}" unless source =~ /@/
|
16
16
|
self.destination += "@#{virtual_domain.name}" unless destination =~ /@/
|
17
|
-
self.destination = destination.split(/,| /).select {|ds| !ds.empty? }.map(&:strip).join(", ")
|
17
|
+
self.destination = destination.split(/,| /).select {|ds| !ds.empty? }.map(&:strip).sort.join(", ")
|
18
18
|
end
|
19
19
|
|
20
20
|
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
# Validates that a string contains only valid email addresses, separated by comma
|
2
2
|
class AliasValidator < EmailValidator
|
3
3
|
def validate_each(record, attribute, value)
|
4
|
-
destinations = value.split(",")
|
5
|
-
unless destinations.map {|destination|
|
6
|
-
self.class.valid? destination.strip
|
7
|
-
}.all?
|
4
|
+
destinations = value.split(", ")
|
5
|
+
unless destinations.map {|destination| self.class.valid?(destination) }.all?
|
8
6
|
record.errors[attribute] << (options[:message] || "is not a valid list of email addresses")
|
9
7
|
end
|
8
|
+
existing = VirtualAlias.where(source: record.source, destination: record.destination).count
|
9
|
+
if existing != 0
|
10
|
+
record.errors[attribute] << (options[:message] || "is already present")
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|