Run rubocop --fix-layout and remove encoding comments

This commit is contained in:
Patrick Gansterer 2021-03-01 15:27:26 +01:00
parent fa63e6e81d
commit ea2862fdef
283 changed files with 1164 additions and 1969 deletions

View file

@ -1,4 +1,3 @@
# encoding: utf-8
class Admin::MessagegroupsController < Admin::BaseController
inherit_resources

View file

@ -1,5 +1,4 @@
class MessageThreadsController < ApplicationController
before_action -> { require_plugin_enabled FoodsoftMessages }
def index

View file

@ -1,5 +1,4 @@
class MessagegroupsController < ApplicationController
def index
@messagegroups = Messagegroup.order("name")
end

View file

@ -1,5 +1,4 @@
class MessagesController < ApplicationController
before_action -> { require_plugin_enabled FoodsoftMessages }
# Renders the "inbox" action.
@ -22,7 +21,7 @@ class MessagesController < ApplicationController
@message.private = original_message.private
@message.subject = I18n.t('messages.model.reply_subject', :subject => original_message.subject)
@message.body = I18n.t('messages.model.reply_header', :user => original_message.sender.display, :when => I18n.l(original_message.created_at, :format => :short)) + "\n"
original_message.body.each_line{ |l| @message.body += I18n.t('messages.model.reply_indent', :line => l) }
original_message.body.each_line { |l| @message.body += I18n.t('messages.model.reply_indent', :line => l) }
else
redirect_to new_message_url, alert: I18n.t('messages.new.error_private')
end

View file

@ -15,7 +15,6 @@ module MessagesHelper
link_text = content_tag :i, nil, class: 'icon-envelope'
link_text << " #{options[:text]}" if options[:text].present?
link_to(link_text.html_safe, new_message_path(message: messages_params), class: 'btn',
title: I18n.t('helpers.submit.message.create'))
title: I18n.t('helpers.submit.message.create'))
end
end

View file

@ -1,7 +1,6 @@
require "email_reply_trimmer"
class MessagesMailReceiver
def self.regexp
/(?<message_id>\d+)\.(?<user_id>\d+)\.(?<hash>\w+)/
end
@ -37,9 +36,9 @@ class MessagesMailReceiver
raise BlankBodyException if body.empty?
message = @user.send_messages.new body: body,
group: @message.group,
private: @message.private,
received_email: data
group: @message.group,
private: @message.private,
received_email: data
if @message.reply_to
message.reply_to_message = @message.reply_to_message
else
@ -73,11 +72,8 @@ class MessagesMailReceiver
end
class BlankBodyException < MidiSmtpServer::SmtpdException
def initialize(msg = nil)
super msg, 541, 'The recipient address rejected your message because of a blank plain body'
end
end
end

View file

@ -10,8 +10,8 @@ class Message < ApplicationRecord
attr_accessor :send_method, :recipient_tokens, :order_id
scope :threads, -> { where(:reply_to => nil) }
scope :thread, -> (id) { where("id = ? OR reply_to = ?", id, id) }
scope :readable_for, -> (user) {
scope :thread, ->(id) { where("id = ? OR reply_to = ?", id, id) }
scope :readable_for, ->(user) {
user_id = user.try(&:id)
joins(:message_recipients)
@ -128,12 +128,13 @@ class Message < ApplicationRecord
def can_toggle_private?(user)
return true if sender == user
return false if private?
user.role_admin?
end
private
def create_salt
self.salt = [Array.new(6){rand(256).chr}.join].pack("m").chomp
self.salt = [Array.new(6) { rand(256).chr }.join].pack("m").chomp
end
end

View file

@ -1,6 +1,4 @@
# encoding: utf-8
class Messagegroup < Group
validates_uniqueness_of :name
protected