diff --git a/app/helpers/dmails_helper.rb b/app/helpers/dmails_helper.rb
index 869a21820..3e700b95d 100644
--- a/app/helpers/dmails_helper.rb
+++ b/app/helpers/dmails_helper.rb
@@ -2,11 +2,23 @@ module DmailsHelper
def dmails_current_folder_path
case cookies[:dmail_folder]
when "sent"
- dmails_path(:search => {:owner_id => CurrentUser.id, :from_id => CurrentUser.id}, :folder => "sent")
- when "all"
- dmails_path(:search => {:owner_id => CurrentUser.id}, :folder => "all")
+ sent_dmails_path
+ when "received"
+ received_dmails_path
else
- dmails_path(:search => {:owner_id => CurrentUser.id, :to_id => CurrentUser.id}, :folder => "received")
+ all_dmails_path
end
end
+
+ def all_dmails_path(params = {})
+ dmails_path(folder: "all", **params)
+ end
+
+ def sent_dmails_path(params = {})
+ dmails_path(search: {from_id: CurrentUser.id}, folder: "sent", **params)
+ end
+
+ def received_dmails_path(params = {})
+ dmails_path(search: {to_id: CurrentUser.id}, folder: "received", **params)
+ end
end
diff --git a/app/models/dmail.rb b/app/models/dmail.rb
index 4a235a830..b60b207f5 100644
--- a/app/models/dmail.rb
+++ b/app/models/dmail.rb
@@ -86,18 +86,6 @@ class Dmail < ActiveRecord::Base
end
module SearchMethods
- def for(user)
- where("owner_id = ?", user)
- end
-
- def inbox
- where("to_id = owner_id")
- end
-
- def sent
- where("from_id = owner_id")
- end
-
def active
where("is_deleted = ?", false)
end
@@ -139,10 +127,6 @@ class Dmail < ActiveRecord::Base
q = q.search_message(params[:message_matches])
end
- if params[:owner_id].present?
- q = q.for(params[:owner_id].to_i)
- end
-
if params[:to_name].present?
q = q.to_name_matches(params[:to_name])
end
diff --git a/app/views/dmails/_secondary_links.html.erb b/app/views/dmails/_secondary_links.html.erb
index 7b7206f31..9ea0bbe68 100644
--- a/app/views/dmails/_secondary_links.html.erb
+++ b/app/views/dmails/_secondary_links.html.erb
@@ -1,9 +1,9 @@
<% content_for(:secondary_links) do %>