dmails: remove ability to mark dmails as spam.
Instead of marking messages as spam, users can either report the message or mark it as deleted.
This commit is contained in:
@@ -61,7 +61,7 @@ class DmailsController < ApplicationController
|
||||
|
||||
def dmail_params(context)
|
||||
permitted_params = %i[title body to_name to_id] if context == :create
|
||||
permitted_params = %i[is_spam is_read is_deleted] if context == :update
|
||||
permitted_params = %i[is_read is_deleted] if context == :update
|
||||
|
||||
params.fetch(:dmail, {}).permit(permitted_params)
|
||||
end
|
||||
|
||||
@@ -23,7 +23,6 @@ class Dmail < ApplicationRecord
|
||||
scope :deleted, -> { where(is_deleted: true) }
|
||||
scope :read, -> { where(is_read: true) }
|
||||
scope :unread, -> { where(is_read: false) }
|
||||
scope :spam, -> { where(is_spam: true) }
|
||||
scope :visible, -> { where(owner: CurrentUser.user) }
|
||||
scope :sent, -> { where("dmails.owner_id = dmails.from_id") }
|
||||
scope :received, -> { where("dmails.owner_id = dmails.to_id") }
|
||||
@@ -126,8 +125,6 @@ class Dmail < ApplicationRecord
|
||||
active.received.unread
|
||||
when "sent"
|
||||
active.sent
|
||||
when "spam"
|
||||
active.spam
|
||||
when "deleted"
|
||||
deleted
|
||||
else
|
||||
@@ -138,7 +135,7 @@ class Dmail < ApplicationRecord
|
||||
def search(params)
|
||||
q = super
|
||||
|
||||
q = q.search_attributes(params, :to, :from, :is_spam, :is_read, :is_deleted, :title, :body)
|
||||
q = q.search_attributes(params, :to, :from, :is_read, :is_deleted, :title, :body)
|
||||
q = q.text_attribute_matches(:title, params[:title_matches])
|
||||
q = q.text_attribute_matches(:body, params[:message_matches], index_column: :message_index)
|
||||
|
||||
@@ -186,7 +183,7 @@ class Dmail < ApplicationRecord
|
||||
end
|
||||
|
||||
def send_email
|
||||
if is_recipient? && !is_spam? && to.receive_email_notifications? && to.email =~ /@/
|
||||
if is_recipient? && !is_deleted? && to.receive_email_notifications? && to.email =~ /@/
|
||||
UserMailer.dmail_notice(self).deliver_now
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
<%= subnav_link_to "Received", dmails_path(search: { folder: "received" }) %>
|
||||
<%= subnav_link_to "Unread", dmails_path(search: { folder: "unread" }) %>
|
||||
<%= subnav_link_to "Sent", dmails_path(search: { folder: "sent" }) %>
|
||||
<%= subnav_link_to "Spam", dmails_path(search: { folder: "spam" }) %>
|
||||
<%= subnav_link_to "Deleted", dmails_path(search: { folder: "deleted" }) %>
|
||||
<li>|</li>
|
||||
<%= subnav_link_to "New", new_dmail_path %>
|
||||
|
||||
@@ -28,11 +28,6 @@
|
||||
<%= link_to "Respond", new_dmail_path(:respond_to_id => @dmail) %>
|
||||
| <%= link_to "Forward", new_dmail_path(:respond_to_id => @dmail, :forward => true) %>
|
||||
| <%= link_to "Share", dmail_path(@dmail, key: @dmail.key), title: "Anyone with this link will be able to view this dmail." %>
|
||||
<% if @dmail.is_spam? %>
|
||||
| <%= link_to "Not spam", dmail_path(@dmail, format: :js), remote: :true, method: :put, "data-params": "dmail[is_spam]=false" %>
|
||||
<% else %>
|
||||
| <%= link_to "Spam", dmail_path(@dmail, format: :js), remote: :true, method: :put, "data-params": "dmail[is_spam]=true" %>
|
||||
<% end %>
|
||||
<% if @dmail.reportable_by?(CurrentUser.user) %>
|
||||
| <%= link_to "Report", new_moderation_report_path(moderation_report: { model_type: "Dmail", model_id: @dmail.id }), remote: true, title: "Report this dmail to the moderators" %>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user