Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions app/controllers/messages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,18 @@ def get_messages(scope)
options[:where].delete(:spam)
options[:where].delete(:scope)
end
if qs[:subject]
options[:where][:subject] = {}
options[:where][:subject][:like] = qs[:subject]
end
if qs[:to]
options[:where][:rcpt_to] = {}
options[:where][:rcpt_to][:like] = qs[:to]
end
if qs[:from]
options[:where][:mail_from] = {}
options[:where][:mail_from][:like] = qs[:from]
end
options[:where][:tag] = qs[:tag] if qs[:tag]
options[:where][:id] = qs[:id] if qs[:id]
options[:where][:spam] = true if qs[:spam] == "yes" || qs[:spam] == "y"
Expand Down
11 changes: 7 additions & 4 deletions app/views/messages/_search.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
as shown opposite into the box above and press enter.
.messageSearch__right
%dl.messageSearch__definition
%dt to: rachel@example.com
%dd Returns all mail addressed to the address provided.
%dt to: rachel@example.com or to: %rachel%
%dd Returns all mail addressed to the address provided. Use % as wildcard anywhere.
%dl.messageSearch__definition
%dt from: tom@example.com
%dd Returns all mail sent from to the address provided.
%dt from: tom@example.com or from: %@example.com
%dd Returns all mail sent from to the address provided. Use % as wildcard anywhere.
%dl.messageSearch__definition
%dt subject: "any string" or subject: "%any string%"
%dd Returns all mail which subject contains the substring provided. Use % as wildcard anywhere.
%dl.messageSearch__definition
%dt status: pending
%dd Returns all messages with the status provided. The suitable statuses are: <code>pending</code>, <code>sent</code>, <code>held</code>, <code>softfail</code>, <code>hardfail</code> and <code>bounced</code>.
Expand Down
2 changes: 2 additions & 0 deletions lib/postal/message_db/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,8 @@ def hash_to_sql(hash, joiner = ", ")
sql << "`#{key}` <= #{escape(inner_value)}"
when :greater_than_or_equal_to
sql << "`#{key}` >= #{escape(inner_value)}"
when :like
sql << "`#{key}` LIKE #{escape(inner_value)}"
end
end
sql.empty? ? "1=1" : sql.join(joiner)
Expand Down
Loading