Skip to content
Open
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
9 changes: 9 additions & 0 deletions app/controllers/messages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,15 @@ def get_messages(scope)
options[:where].delete(:spam)
options[:where].delete(:scope)
end
[[:subject, :subject], [:to, :rcpt_to], [:from, :mail_from]].each do |qs_key, where_key|
if qs[qs_key]
if qs[qs_key].include?('%')
options[:where][where_key] = { like: qs[qs_key] }
else
options[:where][where_key] = qs[qs_key]
end
end
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: [email protected]
%dd Returns all mail addressed to the address provided.
%dt to: [email protected] or to: %rachel%
%dd Returns all mail addressed to the address provided. Use % as wildcard anywhere.
%dl.messageSearch__definition
%dt from: [email protected]
%dd Returns all mail sent from to the address provided.
%dt from: [email protected] 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